-
Notifications
You must be signed in to change notification settings - Fork 65
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(component): localize components #1200
Conversation
b6ada22
to
4865b06
Compare
40c026e
to
d6ddb8d
Compare
@jorgemoya For the dev docs team to suggest copyedits, we need some screenshots of the front end changes. Thanks! |
This is how it looks for all components (plus/minus the correct type for the corresponding component). Is this enough to 👀 ? |
This is how it looks for all components (plus/minus the correct type for the corresponding component). Is this enough to 👀 ? Got it, thanks @jorgemoya ! |
d6ddb8d
to
aaf3a9f
Compare
Hey @funivan 👋 . Eugene suggested I tag you in this PR to look for your opinion on this implementation of adding translation in BD components. Wanted to hear your input on how I did this, if there is a better way that you've seen, and if this works with the translation tools in the CP. I'm open to suggestions! |
@jorgemoya LGTM. I'll ping folks that are working more closely with big-design components. |
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.
Nice job 👏.
I left a few comments. Please look at them
packages/big-design/src/components/InlineMessage/InlineMessage.tsx
Outdated
Show resolved
Hide resolved
packages/big-design/src/components/Table/HeaderCell/HeaderCell.tsx
Outdated
Show resolved
Hide resolved
packages/big-design/src/components/Table/TablePagination/TablePagination.tsx
Show resolved
Hide resolved
packages/big-design/src/components/TableNext/HeaderCell/HeaderCell.tsx
Outdated
Show resolved
Hide resolved
packages/big-design/src/components/TableNext/TablePagination/TablePagination.tsx
Show resolved
Hide resolved
renderOptional && | ||
css` | ||
&::after { | ||
color: ${theme.colors.secondary60}; | ||
content: ' (optional)'; | ||
content: ' (${optionalLabel?.toLowerCase() ?? 'optional'})'; |
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.
we shouldn't be enforcing this, it is up to the consumer to decide if they want lowercase or uppercase.
@@ -68,7 +72,7 @@ export const InlineMessage: React.FC<InlineMessageProps> = memo( | |||
{props.onClose && ( | |||
<GridItem> | |||
<MessagingButton | |||
iconOnly={<CloseIcon size="medium" title="Close." />} |
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.
we lost the .
?
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.
I think it's okay to remove it. I think the initial intention was to create a pause when a screen reader lands on the button but it should occur naturally since a SR will naturally stop on the element.
); | ||
}, [actions]); | ||
export const ButtonGroup: React.FC<ButtonGroupProps> = memo( | ||
({ actions, localization, ...wrapperProps }) => { |
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.
Can we define a default localization object instead of adding the translations adhoc?
Something like:
const defaultLocalization: Localization {
more: 'more',
};
// ...
export const ButtonGroup: React.FC<ButtonGroupProps> = memo(
({ actions, localization = defaultLocalization, ...wrapperProps }) => {
// ...
iconOnly={<MoreHorizIcon title={localization.more} />}
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.
I had it this way at some point and reverted to what I have now 😅 . In other words, I agree we this!
optional: string; | ||
} | ||
|
||
const defaultLocalization = { |
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.
const defaultLocalization = { | |
const defaultLocalization: Localization = { |
totalItems: number, | ||
of = 'of', | ||
): string => { | ||
const defaultGetRangeLabel = (start: number, end: number, totalItems: number): string => { |
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.
Can we add this as part of the localization
object?
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.
Like having the function be part of the object? My concern is that this getRangeLabel
can be used for non localization purposes.
2d92b3d
to
210faac
Compare
renderOptional && | ||
css` | ||
&::after { | ||
color: ${theme.colors.secondary60}; | ||
content: ' (optional)'; | ||
content: ' (${localization?.optional})'; |
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.
🤔 if localization
is nullable, that means localization?.optional
can be undefined
. Are types correct?
@@ -62,6 +85,8 @@ const InternalStatefulTable = <T extends TableItem>({ | |||
itemName, | |||
items = [], | |||
keyField, | |||
localization: localizationProp, |
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.
might want to keep the style across the change:
localization: localizationProp, | |
localization = defaultLocalization, |
35f15c5
to
393e7bc
Compare
Added the fixes, please review if you have time. 🙏 |
@@ -68,7 +72,7 @@ export const InlineMessage: React.FC<InlineMessageProps> = memo( | |||
{props.onClose && ( | |||
<GridItem> | |||
<MessagingButton | |||
iconOnly={<CloseIcon size="medium" title="Close." />} |
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.
I think it's okay to remove it. I think the initial intention was to create a pause when a screen reader lands on the button but it should occur naturally since a SR will naturally stop on the element.
{ | ||
name: 'getRangeLabel', | ||
types: '(start: number, end: number, totalItems: number) => string', | ||
required: false, | ||
description: 'A callback to format the label of the per-page range dropdown.', | ||
}, | ||
{ | ||
name: 'localization', | ||
types: '{of: string, previousPage: string, nextPage: string}', |
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.
🍹 💅
types: '{of: string, previousPage: string, nextPage: string}', | |
types: '{ of: string, previousPage: string, nextPage: string }', |
a06789d
to
4683dae
Compare
Breaking changes
What?
Localize components per feedback from #1194
How
Created a
localization
object prop that has all values that can be localized within the component. This is a breaking change because I changed the pagination props.Screen with example of new
localization
propTesting/Proof
Locally + unit tests.