-
Notifications
You must be signed in to change notification settings - Fork 409
feat(clerk-js,types): Add navbar button text descriptor and localization key #4635
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
Changes from all commits
ef60713
7a432a2
64d09fb
44e0d1d
7fa0dab
4c2a466
a484b40
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@clerk/clerk-js': patch | ||
| '@clerk/types': patch | ||
| --- | ||
|
|
||
| Introduce the `navbarButtonText` element descriptor. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import { createContextAndHook } from '@clerk/shared/react'; | |
| import React, { useCallback } from 'react'; | ||
|
|
||
| import type { LocalizationKey } from '../customizables'; | ||
| import { Button, Col, descriptors, Flex, Heading, Icon, Text, useLocalizations } from '../customizables'; | ||
| import { Button, Col, descriptors, Flex, Heading, Icon, Span, Text, useLocalizations } from '../customizables'; | ||
| import type { ElementDescriptor, ElementId } from '../customizables/elementDescriptors'; | ||
| import { useNavigateToFlowStart, usePopover } from '../hooks'; | ||
| import { Menu } from '../icons'; | ||
|
|
@@ -47,7 +47,6 @@ export const NavBar = (props: NavBarProps) => { | |
| const { close } = useNavbarContext(); | ||
| const { navigate } = useRouter(); | ||
| const { navigateToFlowStart } = useNavigateToFlowStart(); | ||
| const { t } = useLocalizations(); | ||
| const router = useRouter(); | ||
|
|
||
| const handleNavigate = (route: NavbarRoute) => { | ||
|
|
@@ -105,7 +104,11 @@ export const NavBar = (props: NavBarProps) => { | |
| minHeight: t.space.$8, | ||
| })} | ||
| > | ||
| {t(r.name)} | ||
| <Span | ||
| elementDescriptor={descriptors.navbarButtonText} | ||
| elementId={descriptors.navbarButtonText.setId(r.id as any)} | ||
| localizationKey={r.name} | ||
| /> | ||
|
Comment on lines
+107
to
+111
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ Could this be replaced with
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No because of the default styles the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it |
||
| </NavButton> | ||
| ))} | ||
| </Col> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import React from 'react'; | ||
|
|
||
| export const Span = React.forwardRef< | ||
| HTMLSpanElement, | ||
| React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement> | ||
| >((props, ref) => { | ||
| return ( | ||
| <span | ||
| {...props} | ||
| ref={ref} | ||
| /> | ||
| ); | ||
| }); |
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.
Update selectors using best practices https://kentcdodds.com/blog/common-mistakes-with-react-testing-library#not-using-byrole-most-of-the-time