-
Notifications
You must be signed in to change notification settings - Fork 101
feat(vote): extract the vote state logic in an opt in svelte module #2152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: beta
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: ee21670 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for stacks ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for stacks-svelte ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
mukunku
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
SPARK-155
This PR is making our Vote.svelte component much dumber than it was and leave to consumers the job of managing the state (e.g. react to downvote and upvote clicks and update the other props accordingly).
There are also part of the vote state logic though (such as optimistic updates) that will end up being repeated over and over by product teams with potentially slightly different behavior which would only end up confusing the user.
For this reason we also distribute a svelte module (
vote-state.svelte.ts) which contains acreateVoteStatefactory which takes initial state values and return reactive props that can be spread in the Vote component.Example
Storybook preview