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: add ShareDropdownMenu component #38

Merged
merged 7 commits into from
Oct 11, 2024
Merged

feat: add ShareDropdownMenu component #38

merged 7 commits into from
Oct 11, 2024

Conversation

MH4GF
Copy link
Member

@MH4GF MH4GF commented Oct 10, 2024

@MH4GF MH4GF temporarily deployed to preview - service-site October 10, 2024 10:56 — with GitHub Actions Inactive
@MH4GF MH4GF temporarily deployed to preview - service-site-storybook October 10, 2024 10:56 — with GitHub Actions Inactive
@MH4GF MH4GF temporarily deployed to preview - service-site October 10, 2024 11:09 — with GitHub Actions Inactive
@MH4GF MH4GF temporarily deployed to preview - service-site-storybook October 10, 2024 11:09 — with GitHub Actions Inactive
@MH4GF MH4GF changed the title add dropdown menu feat: add ShareDropdownMenu component Oct 10, 2024
| 'posts.share.facebook'
| 'posts.share.linkedin',
string
>
Copy link
Member Author

Choose a reason for hiding this comment

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

The situation where a key is only available in one of the languages is not complementary, so it is defined as a type.

string
>

export type TranslationFn = <K extends keyof Dictionary>(key: K) => string
Copy link
Member Author

Choose a reason for hiding this comment

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

Defined as a type for ease of definition in component props.

export const ShareDropdownMenu: FC<Props> = ({ children, t }) => {
return (
<DropdownMenuRoot>
<DropdownMenuTrigger asChild>{children}</DropdownMenuTrigger>
Copy link
Member Author

Choose a reason for hiding this comment

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

Trigger will be this component:

<DropdownMenuContent sideOffset={5} align="start">
<DropdownMenuItem
leftIcon={<CopyIcon className={styles.icon} />}
onSelect={() => alert('Item 1 clicked')}
Copy link
Member Author

Choose a reason for hiding this comment

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

Actual copying process will be implemented in another PR.

@MH4GF MH4GF marked this pull request as ready for review October 10, 2024 11:16
@MH4GF MH4GF requested a review from a team as a code owner October 10, 2024 11:16
@MH4GF MH4GF requested review from hoshinotsuyoshi, FunamaYukina, junkisai and sasamuku and removed request for a team October 10, 2024 11:16
Copy link
Member

@junkisai junkisai left a comment

Choose a reason for hiding this comment

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

LGTM!

import styles from './ShareDropdownMenu.module.css'

type Props = PropsWithChildren<{
t: TranslationFn
Copy link
Member

Choose a reason for hiding this comment

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

[Q]
I was thinking it might be okay to use 'lang' as a props, but is there a specific reason why you chose to pass the 't' function as a props?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is because it is easier for child components to be maintained if they are initialized in the page component and t is passed around. I refer to the implementation in i18next.
ref: https://locize.com/blog/next-app-dir-i18n/

  • No need to worry about SC / CC distinction.
    • No need to worry about getTranslation becoming an async function.
    • Components do not have to worry about implementing getTranslation for clients, for example, to retrieve lang from localStorage.

Copy link
Member

@junkisai junkisai Oct 11, 2024

Choose a reason for hiding this comment

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

I see! 😄
I understand now that considering the async case of SC, passing 't' as a prop makes it unnecessary to maintain the child component.

> Conflicts:
>	frontend/apps/service-site/package.json
>	frontend/pnpm-lock.yaml
@MH4GF MH4GF enabled auto-merge October 11, 2024 03:00
@MH4GF MH4GF temporarily deployed to preview - service-site October 11, 2024 03:00 — with GitHub Actions Inactive
@MH4GF MH4GF temporarily deployed to preview - service-site-storybook October 11, 2024 03:00 — with GitHub Actions Inactive
@MH4GF MH4GF added this pull request to the merge queue Oct 11, 2024
Merged via the queue into main with commit b64eab9 Oct 11, 2024
8 checks passed
@MH4GF MH4GF deleted the add-dropdown-menu branch October 11, 2024 03:03
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.

2 participants