Repository navigation
chore: replace left/right prop values with start/end - #85
LinKCoding wants to merge 14 commits into
Conversation
@skillsoft/eslint-plugin-gamut
@skillsoft/gamut
@skillsoft/gamut-agent-tools
@skillsoft/gamut-codemods
@skillsoft/gamut-icons
@skillsoft/gamut-illustrations
@skillsoft/gamut-patterns
@skillsoft/gamut-styles
@skillsoft/gamut-tests
@skillsoft/variance
commit: |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #85 +/- ##
=========================================
+ Coverage 0 77.20% +77.20%
=========================================
Files 0 464 +464
Lines 0 32093 +32093
Branches 0 1500 +1500
=========================================
+ Hits 0 24778 +24778
- Misses 0 7315 +7315
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Directional props now use logical `start` / `end` values instead of physical `left` / `right`. - Disclosure `buttonPlacement` - Drawer `alignContentContainer` - Flyout `openFrom` - SelectDropdown `menuAlignment` - DataList column, ListCol, and FilterControl `justify` - Toggle `labelSide` - `iconPosition` on FillButton, StrokeButton, TextButton, Anchor, Tag, and Badge - GridForm section `layout` and `submit.position` Stories, docs, and agent skills are updated to match. Code Connect files keep `left` / `right` with TODO comments until the Figma changes take effect. BREAKING CHANGE: `left` and `right` are no longer accepted for these props. Use `start` in place of `left` and `end` in place of `right`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… PopoverContainer, and Tips Popover, PopoverContainer, and Tips alignment values now use logical `start` / `end` instead of physical `left` / `right`. - Popover `align` and `beak` (also Coachmark `beak`): `start` | `end` | `center` - PopoverContainer `alignment`: `top-start`, `top-end`, `bottom-start`, `bottom-end`, `top`, `bottom`, `start`, `end` - ToolTip, InfoTip, and PreviewTip `alignment` (and Modal `tipAlignment`): `top-start`, `top-end`, `bottom-start`, `bottom-end`, `start-center`, `end-center`, `top-center`, `bottom-center` PopoverContainer resolves logical alignments to physical ones with `resolvePhysicalAlignment`, which replaces `mirrorAlignment`. Popover's `resolveHorizontalSideForRtl` now takes `start` / `end` and returns a physical side. Internal beak variant keys use `start` / `end`; pattern variants and beak rotations stay physical. Stories, tests, docs, and agent skills are updated to match. Code Connect files keep their current values with TODO comments until the Figma changes take effect. This also fixes two GridForm docs lines missed in the previous commit. BREAKING CHANGE: `left` and `right` are no longer accepted in these alignment values. Use `start` in place of `left` and `end` in place of `right`, e.g. `top-left` becomes `top-start` and `right-center` becomes `end-center`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Physical `left` / `right` CSS keyword values now use logical `start` / `end`, so they flip in RTL. - SelectDropdown option label `textAlign` - DataList SortControl `textAlign` - ProgressBar percent label `text-align` - BarChart and Menu story alignment - Storybook TableOfContents and ImageGallery `textAlign` LTR rendering is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The naming conventions rationale page now explains why prop values use `start` / `end` instead of `left` / `right`, and why `start` / `end` is preferred over `leading` / `trailing` for values. The writing guidance page links to the rationale page and updates the RTL rule to cover prop values. The rule no longer says `start` / `end` replace `top` / `bottom`, which contradicted the renamed values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The "Staying correct in both reading directions" section now explains the `start` / `end` values Gamut uses and why, then the `left` / `right` values they replaced and why those no longer suit RTL layouts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7f9cd93 to
9775597
Compare
Resolve conflicts: keep the styleguide package deleted as on main, and use the branch's story versions for List, Popover, and PreviewTip, with left/right values updated to start/end. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
aresnik11
left a comment
There was a problem hiding this comment.
Spot checked most of them and have a few follow up comments and some existing bugs but overall this is great!
There was a problem hiding this comment.
we should rename this to be MenuAlignmentEnd
| @@ -32,7 +32,7 @@ export const SubmitButtonRight: Story = { | |||
There was a problem hiding this comment.
same here can we rename these SubmitButtonStart and SubmitButtonEnd
| @@ -135,11 +135,11 @@ export const Below: Story = { | |||
| }; | |||
|
|
|||
| export const CenterLeft: Story = { | |||
There was a problem hiding this comment.
bunch here that we can rename the story from Left/Right to Start/End
| args: { align: 'start', beak: 'center', position: 'center' }, | ||
| }; | ||
|
|
||
| export const CenterRight: Story = { |
There was a problem hiding this comment.
can be ticketed for later but CenterRight and CenterLeft stories the spacing/alignment of the beak is a little off in RTL (existing issue)
| label={{ | ||
| info: 'More info here...', | ||
| alignment: 'right-center', | ||
| alignment: 'end-center', |
There was a problem hiding this comment.
can be ticketed for later but for end-center tooltips the spacing/alignment of the beak is a little off in RTL (existing issue)
There was a problem hiding this comment.
this applies to IconButton too
There was a problem hiding this comment.
Seems like it's rooted in popover then, curiously I haven't been able to repro
| font-weight: bold; | ||
| padding: 0.5rem; | ||
| text-align: right; | ||
| text-align: end; |
There was a problem hiding this comment.
confirmed the percentage sticks to end but the text doesn't flip... shouldn't 33% become %33 in rtl?
There was a problem hiding this comment.
good catch! This is what the robot says.
tl;dr: it works as intended rn, but we should prob do a locale-correct text update to our Text component
No, ProgressBar shouldn't swap the text. I read the code but didn't render it in RTL, so this is from the code and how bidi text works.
Why 33% is correct in RTL. The text is a plain string, {percent}% (ProgressBar/index.tsx:176). The Unicode bidi algorithm treats % as a number terminator, so it stays attached to the digits and the run renders as 33%, left-to-right, even inside an RTL layout. Browsers do the same. %33 is not a general RTL convention. Where the sign goes depends on the language:
- Hebrew: 33%, same as English.
- Turkish: %33, and Turkish is LTR.
- Arabic and Persian: these use their own digits and sign, such as ٣٣٪, which Arabic-script locales produce but the bidi algorithm doesn't.
So the placement follows the locale and not the text direction. Flipping the string whenever the page is RTL would be wrong for Hebrew.
What your end change already handles. text-align: end (DisplayedPercent) puts the label at the trailing edge, which is the left side in RTL. That matches what the reviewer confirmed. The label sitting in the right place with its text unchanged is the correct result.
If you want locale-correct text. That would be a separate feature. You'd format with new Intl.NumberFormat(locale, { style: 'percent' }), which produces the right digits and sign per locale. The component hardcodes % and the English Progress: ${percent}% screen-reader label, so it isn't localized today. I'd leave that out of this PR, because it's a behavior change and not a rename.
Overview
Directional prop values now use logical
start/endinstead of physicalleft/right, so they stay correct in right-to-left (RTL) layouts.There are no
left/rightaliases.Consuming apps will be migrated with a codemod in a separate branch.
Component props (
feat!)buttonPlacementalignContentContaineropenFrommenuAlignmentjustifylabelSideiconPositionon FillButton, StrokeButton, TextButton, Anchor, Tag, and Badgelayoutandsubmit.positionPopover, PopoverContainer, and Tips alignments (
feat!)alignandbeak(also Coachmarkbeak):start|end|centeralignment:top-start,top-end,bottom-start,bottom-end,top,bottom,start,endalignment(and ModaltipAlignment):top-start,top-end,bottom-start,bottom-end,start-center,end-center,top-center,bottom-centerPopoverContainer resolves logical alignments to physical ones with
resolvePhysicalAlignment, which replacesmirrorAlignment.Popover's
resolveHorizontalSideForRtlnow takesstart/endand returns a physical side.CSS keyword swaps (
fix)SelectDropdown option labels, DataList SortControl, the ProgressBar percent label, and a few stories and Storybook components now use
start/endfortext-alignandjustify-content.LTR rendering is unchanged.
Docs
The naming conventions rationale page explains why prop values use
start/end, and the writing guidance page links to it and covers prop values in its RTL rule.Stories, gamut-docs pages, and agent skills are updated to match.
Code Connect files keep
left/rightwith TODO comments until the Figma changes take effect.Not in this PR
ScaleChartHeadertextAlign, which needs itsleft: %/translateXmath made direction-aware first.backgroundPosition: 'right', which has no logical CSS keyword.shadowvaluespatternLeft/patternRight.BREAKING CHANGE:
leftandrightare no longer accepted in these prop values.Use
startin place ofleftandendin place ofright, e.g.top-leftbecomestop-startandright-centerbecomesend-center.PR Checklist
Testing Instructions
Check each of the following Storybook pages three ways:
main.start/endplacements mirror:startsits on the right andendsits on the left.Component props
Containers/Disclosure: the body button sits at the end by default and at the start when thebuttonPlacementcontrol is set tostart.Containers/Drawer: the content stays pinned to thealignContentContaineredge while the drawer animates.Overlays/Flyout: the flyout opens from the start edge by default.Inputs & forms/SelectDropdown: the menu lines up with the input's end edge in themenuAlignment: 'end'story, and option right labels align to the end.Data display/DataTableandData display/DataList:justify: 'end'columns align to the end, column filter menus open toward the inside of the table, and sort headers align to the start.Data display/List/List,Data display/List/ListCol, andData display/List/ListRow:justify="end"columns align to the end.Actions/Toggle: the label sits at the end by default and at the start withlabelSide: 'start'.Actions/Buttons/Button Examples,Actions/Buttons/FillButton,Actions/Buttons/StrokeButton, andActions/Buttons/TextButton: icons sit before the label by default and after it withiconPosition="end".Navigation/Anchor: sameiconPositioncheck as the buttons.Actions/TagandStatus/Badge: icons sit before the label.Inputs & forms/GridForm/Buttons,Inputs & forms/GridForm/Layout, andInputs & forms/GridForm/Usage: the submit button followssubmit.position, and section titles withlayout: 'start'take the start column.Popover, PopoverContainer, and Tips alignments
Overlays/Popover: check everyalign/beakstory, including Center Left, Center Right, the pattern stories, and the Rtl stories, and confirm the beak points at the target.Overlays/PopoverContainer: check each corner and single-side alignment, inline and portaled.Feedback/Coachmark: the beak sits on thebeakside.Feedback/Tips/ToolTip,Feedback/Tips/InfoTip, andFeedback/Tips/PreviewTip: check every alignment, both inline and floating, and confirm the beak points at the trigger.Actions/Menu/MenuandActions/Menu/MenuItem:end-centertooltips open beside the item.Actions/Buttons/IconButton: tooltips open on the selected side.Inputs & forms/DatePicker,Inputs & forms/Form/FormGroup,Feedback/Alert, andPatterns/FloatingMenu: popovers and tips open where they did before.CSS keyword swaps
Status/ProgressBar: the percent label aligns to the end.Data display/BarChart: the external title story aligns to the end.Docs
Concepts/Naming conventions rationaleandGuides/Writing guidance, and click the reading-direction rationale link to confirm it lands on the "Staying correct in both reading directions" section.PR Links and Envs