Skip to content

[NO-JIRA] Add textAlign prop to layout components#4720

Open
GC Zhu (gc-skyscanner) wants to merge 5 commits into
mainfrom
gc-skyscanner/bpkbox-add-text-align
Open

[NO-JIRA] Add textAlign prop to layout components#4720
GC Zhu (gc-skyscanner) wants to merge 5 commits into
mainfrom
gc-skyscanner/bpkbox-add-text-align

Conversation

@gc-skyscanner

Copy link
Copy Markdown
Contributor

What

Adds a textAlign prop to all Backpack layout components (BpkBox, BpkFlex, BpkGrid, BpkGridItem, BpkStack).

How

  • textAlign?: BpkResponsiveValue<TextAlign> added to BpkCommonLayoutProps in commonProps.ts
  • Reuses the TextAlign type ('start' | 'end' | 'center' | 'justify') already exported from bpk-component-text — consistent with textStyle (uses TextStyle) and color (uses TextColor)
  • Added 'textAlign' to the responsive-processing allowlist for all 5 components in tokenUtils.ts, so it goes through the same breakpoint-normalisation pipeline as position, overflow, and textStyle
  • No new SCSS classes needed — Chakra handles it as a plain text-align inline style

Usage

// Static
<BpkBox textAlign="center">...</BpkBox>

// Responsive
<BpkFlex textAlign={{ base: 'start', tablet: 'center' }}>...</BpkFlex>

Test plan

  • Added a renders when textAlign is provided test to each of the 5 component test files, mirroring the existing textStyle test pattern
  • TypeScript will catch any misuse at compile time (only 'start' | 'end' | 'center' | 'justify' are valid)

…omponents

Adds `textAlign` to `BpkCommonLayoutProps`, making it available on
BpkBox, BpkFlex, BpkGrid, BpkGridItem and BpkStack. The type is
`BpkResponsiveValue<TextAlign>`, reusing the same `TextAlign` type
already exported from `bpk-component-text` — consistent with how
`textStyle` and `color` are typed.

The prop is wired into the responsive-processing allowlist for each
component in `tokenUtils.ts`, so it is breakpoint-normalised and
passed through to Chakra as a plain `text-align` inline style (no new
SCSS classes needed).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 22, 2026 08:41
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Visit https://backpack.github.io/storybook-prs/4720 to see this build running in a browser.

Adds TextAlign (and ResponsiveTextAlign for BpkBox) stories to
BpkBox, BpkFlex, BpkGrid and BpkStack, demonstrating all four values
(start/center/end/justify) using TEXT_ALIGN constants from
bpk-component-text — consistent with the existing TextStyle story pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@skyscanner-backpack-bot

skyscanner-backpack-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor
Warnings
⚠️

Package source files (e.g. packages/package-name/src/Component.js) were updated, but snapshots weren't. Have you checked that the tests still pass?

Browser support

If this is a visual change, make sure you've tested it in multiple browsers.

Generated by 🚫 dangerJS against 70e5645

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 a responsive textAlign prop to Backpack layout components, wiring it through the shared props/types and the existing responsive-prop processing pipeline.

Changes:

  • Adds textAlign?: BpkResponsiveValue<TextAlign> to BpkCommonLayoutProps.
  • Allows textAlign to be breakpoint-normalised by adding it to the responsive prop groups for BpkBox, BpkFlex, BpkGrid, BpkGridItem, and BpkStack.
  • Adds Storybook examples and basic render tests covering the new prop.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/backpack-web/src/bpk-component-layout/src/tokenUtils.ts Adds textAlign to the responsive prop allowlist for all layout components.
packages/backpack-web/src/bpk-component-layout/src/commonProps.ts Extends common layout props/types to include responsive textAlign.
packages/backpack-web/src/bpk-component-layout/src/BpkStack.stories.tsx Adds a textAlign usage example for BpkStack.
packages/backpack-web/src/bpk-component-layout/src/BpkStack-test.tsx Adds a render test case for textAlign on BpkStack.
packages/backpack-web/src/bpk-component-layout/src/BpkGridItem-test.tsx Adds a render test case for textAlign on BpkGridItem.
packages/backpack-web/src/bpk-component-layout/src/BpkGrid.stories.tsx Adds a textAlign usage example for BpkGrid.
packages/backpack-web/src/bpk-component-layout/src/BpkGrid-test.tsx Adds a render test case for textAlign on BpkGrid.
packages/backpack-web/src/bpk-component-layout/src/BpkFlex.stories.tsx Adds a textAlign usage example for BpkFlex.
packages/backpack-web/src/bpk-component-layout/src/BpkFlex-test.tsx Adds a render test case for textAlign on BpkFlex.
packages/backpack-web/src/bpk-component-layout/src/BpkBox.stories.tsx Adds static + responsive textAlign examples for BpkBox.
packages/backpack-web/src/bpk-component-layout/src/BpkBox-test.tsx Adds a render test case for textAlign on BpkBox.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/backpack-web/src/bpk-component-layout/src/BpkBox-test.tsx Outdated
Replace smoke-test assertions with className-diff assertions that
verify textAlign actually changes the rendered output — consistent
with the opacity test pattern used elsewhere in the same files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Visit https://backpack.github.io/storybook-prs/4720 to see this build running in a browser.

Assert that textAlign prop applies the correct text-align inline style
to the rendered DOM element, consistent with existing flex-direction,
gap, and other Chakra prop tests in the same files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gc-skyscanner GC Zhu (gc-skyscanner) added the minor Non breaking change label Jun 22, 2026
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Visit https://backpack.github.io/storybook-prs/4720 to see this build running in a browser.

Add missing @returns JSDoc tag to all new textAlign story functions,
matching the pattern used by existing story functions in the same files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Visit https://backpack.github.io/storybook-prs/4720 to see this build running in a browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Non breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants