Skip to content
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

feat(dev): Vote components #1488

Merged
merged 27 commits into from
Jun 25, 2023
Merged

Conversation

jsit
Copy link
Contributor

@jsit jsit commented Jun 22, 2023

This PR componentizes the Votes buttons, both "regular" and "compact," in the Post Listing view and Comment Nodes.

Should be tested thoroughly, as voting is a pretty important function.

jsit added 4 commits June 22, 2023 13:36
* origin/main: (26 commits)
  Adding jsit to codeowners.
  Cleanup, only check for /u/ if /c/ and /m/ checks fail
  Rename function to be more generic, since it parses users
  Typescript linter fixes
  bandaid fix our video embeds
  Remove pipe from community link regex
  Add missing classes
  Use shorter regex in community link parser
  Move regex pattern to config
  Update community link markdown parsing
  Fix avatar alignment issue (LemmyNet#1475)
  Omit user-scalable to use default
  Update getHttpBase dependency reference
  Enable users to zoom on mobile
  rethink it a bit
  rethink it a bit
  add fallback style tag
  Add community link class
  prettier
  Add local community link parser plugin for Markdown-It
  ...
jsit added 3 commits June 22, 2023 17:30
* origin/main:
  fix: Add post body preview to desktop post listing view
  fix: Fix i18n UserService import issue
enableDownvotes?: boolean;
upvoteLoading?: boolean;
downvoteLoading?: boolean;
handleUpvote: (i: PostListing) => void;
Copy link
Member

@dessalines dessalines Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What we've typically done, is pass the lemmy-js-client form (in this case CreateCommentLike) up to the parent. Check out post-form.tsx for an example.

But here, since that could be either a post or a comment, I'd recommend passing up an id, the new vote, and an auth. Type the interface well, something like:

interface VoteItem {
  id: number,
  newVote: number,
  auth: ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks -- are my latest edits more what you were picturing? I'm not sure where this VoteItem type could go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments use comment_id for their ID, and posts use post_id, so I had to add a switch and an extra property so comments/posts can specify which type to use when submitting the click.

src/shared/components/common/vote-buttons.tsx Outdated Show resolved Hide resolved
@jsit jsit requested a review from dessalines June 23, 2023 03:49
@jsit jsit marked this pull request as draft June 23, 2023 04:29
@jsit jsit marked this pull request as ready for review June 23, 2023 16:16
jsit and others added 3 commits June 23, 2023 12:16
* origin/main:
  Fix homepage `scrollTo(0, 0)` failing when document size changes.
  v0.18.0
  v0.18.0-rc.8
  Moved `!isBrowser()` check to `FirstLoadServer.isFirstLoad`
  Fix server-side rendering after first load.
@jsit jsit changed the title feat: Vote components feat(dev): Vote components Jun 24, 2023
jsit and others added 6 commits June 25, 2023 01:11
* lemmy/main:
  fix(a11y): Restore aria-activedescendant
  chore: Empty commit to re-trigger Woodpecker
  fix(a11y): Make foreground of 'remove image button' white
  fix(a11y): Add alt text to emojis form
  fix(a11y): Fix some a11y markup in Searchable Select component
  fix(a11y): Change image remove button to true button element
  fix: Ignore rule for clickaway div; 'Esc' works for this
  fix: Fix another class
  fix: Fix some Bootstrap 5 font classes
@SleeplessOne1917 SleeplessOne1917 merged commit dc48d74 into LemmyNet:main Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants