Repository navigation
[NOJIRA]add locale-aware line-break rules for non-Latin scripts - #4732
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds global, locale-aware CSS line-breaking and wrapping behavior using :lang() selectors so non‑Latin scripts (CJK/Korean/Thai/RTL/Cyrillic) break more naturally without per-component changes.
Changes:
- Introduces
:lang()-scopedline-break,overflow-wrap,word-break, andhyphensrules for multiple scripts. - Adjusts CJK/Korean
line-breakbehavior at the small-tablet breakpoint.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Visit https://backpack.github.io/storybook-prs/4732 to see this build running in a browser. |
1 similar comment
|
Visit https://backpack.github.io/storybook-prs/4732 to see this build running in a browser. |
Dev Release PublishedVersion: Install with: You can also use the dev tag to install the latest dev release: |
|
Visit https://backpack.github.io/storybook-prs/4732 to see this build running in a browser. |
4 similar comments
|
Visit https://backpack.github.io/storybook-prs/4732 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4732 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4732 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4732 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4732 to see this build running in a browser. |
Add :lang() CSS rules to font.scss so kinsoku shori (JIS X 4051) and equivalent rules are enforced globally via the existing <html lang="..."> attribute — no per-component changes required. Key decisions: - line-break: strict for CJK/Korean fixes punctuation/particles appearing at line-start (を、に、の etc. must not begin a line) - overflow-wrap: anywhere for CJK as last-resort fallback; preserves Latin brand names and URLs on mixed-script pages unlike word-break: break-all - word-break: keep-all for Korean preserves syllable-block boundaries; overflow-wrap: break-word fallback handles 360–390px narrow viewports - bpk-breakpoint-query-small-tablet (48rem) loosens line-break to loose for CJK/Korean to avoid uneven rag on narrow screens - Thai uses break-all + overflow-wrap: anywhere — no word spaces, ICU dictionary failure leaves zero break points otherwise - Arabic/Hebrew: overflow-wrap only; direction left to existing html[dir] RTL system - Russian/Ukrainian: hyphens: auto degrades silently in Chrome Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
The base :lang(ja) rule used word-break: keep-all, which forbids all breaks between space-less Japanese characters. Browsers without word-break: auto-phrase (Firefox, Safari) fell back to keep-all and overflowed the container instead of wrapping. - Drop keep-all from the base rule so non-Chromium browsers wrap per-character under kinsoku (line-break: strict) — the conventional, overflow-safe Japanese fallback. - Keep auto-phrase for Chromium via @supports. - Add :lang(ja):has(wbr) → keep-all so author-inserted <wbr> phrase hints become the only break points, giving phrase-aware breaks in every browser (incl. Firefox) with no consumer className. - Document the behaviour and <wbr> usage in the bpk-stylesheets README. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…r support docs - Remove word-break: break-all and line-break: loose from :lang(th) — break-all overrides ICU dictionary word segmentation causing incorrect mid-character breaks; line-break only affects CJK kinsoku and has no effect on Thai - Remove duplicate @include bpk-locale-line-breaks from larken.scss — font.scss already includes it, consumers importing both got duplicate rules - Update README to qualify <wbr> phrase-break support as "all modern browsers (Chrome 105+, Safari 15.4+, Firefox 121+)" rather than "all browsers" Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
96ec660 to
a58245d
Compare
|
Visit https://backpack.github.io/storybook-prs/4732 to see this build running in a browser. |
GC Zhu (gc-skyscanner)
left a comment
There was a problem hiding this comment.
Confirmed with localisation team, LGTM
Add :lang() CSS rules to font.scss so kinsoku shori (JIS X 4051) and equivalent rules are enforced globally via the existing attribute — no per-component changes required.
Key decisions:
word-break: keep-all) so it never overflows in browsers withoutauto-phrase; Chromium is upgraded to phrase-level breaks via@supports (word-break: auto-phrase)Japanese line breaking across browsers
Japanese has no word spaces, so there is no single CSS declaration that gives phrase-aware (文節) breaks everywhere. We handle it in layers:
word-break: auto-phrasebreaks at natural phrase boundaries automatically. Best-in-class, but Chromium-only (caniuse).auto-phrase, so they fall back to standard per-character wrapping underline-break: strict(kinsoku). This is the conventional way Japanese wraps in print and, crucially, never overflows the container. (An earlier revision usedword-break: keep-allin the base rule; that forbids every break in space-less Japanese and caused horizontal overflow in Firefox/Safari — now fixed.)Optional
<wbr>phrase hints (works in every browser)For key marketing/UI copy where phrase-aware breaks are wanted in all browsers, the author inserts
<wbr>at phrase boundaries. Backpack detects it via:lang(ja):has(wbr)and switches that text toword-break: keep-all, making the<wbr>marks the only break points — so Firefox and Safari honour the same boundaries as Chromium. No consumer className is needed —<wbr>is content, and its presence is itself the opt-in signal.Note: under
keep-all, if the viewport is narrower than a single hinted phrase (e.g. narrower thanプライスアラートを), that phrase still wraps mid-word (プライスアラート/を) rather than overflow the element — breaking is preferred over horizontal overflow.Documented in the
bpk-stylesheetsREADME. See thebpk-stylesheets-fontsLarken story ("Japanese line-break validation") — compare the default vs<wbr>-hinted samples in Firefox.Remember to include the following changes:
[Clover-123][BpkButton] Updating the colourREADME.md(If you have created a new component)README.md