Conversation
|
Visit https://backpack.github.io/storybook-prs/4287 to see this build running in a browser. |
There was a problem hiding this comment.
Pull request overview
Adds additional visual and interaction capabilities to BpkBox in bpk-component-layout, primarily by introducing token-backed background/text color props (via SCSS modules) and expanding the common layout prop surface (ARIA/HTML attributes and a few structural layout controls).
Changes:
- Introduces
BACKGROUND_COLORS+BpkBoxBackgroundColorand wiresBpkBoxbackgroundColorto SCSS module classes. - Adds
colorsupport onBpkBoxusingTEXT_COLORS-compatible class names (compound selectors to beat Chakra specificity). - Expands shared layout props (
BpkCommonLayoutProps) to includeid,role,aria-*,position,zIndex, and overflow props; updates examples/stories accordingly.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/bpk-component-layout/src/backgroundColors.ts | Adds BACKGROUND_COLORS constant and BpkBoxBackgroundColor type to define allowed background tokens. |
| packages/bpk-component-layout/src/BpkBox.module.scss | Implements the SCSS-module classes for background and text color modifiers used by BpkBox. |
| packages/bpk-component-layout/src/BpkBox.tsx | Adds backgroundColor/color class handling and forwards refs to the underlying Chakra Box. |
| packages/bpk-component-layout/src/commonProps.ts | Expands shared layout props with ARIA/HTML attributes and structural layout props. |
| packages/bpk-component-layout/src/types.ts | Extends BpkBoxProps with background/text color types and additional interaction/visual props. |
| packages/bpk-component-layout/src/BpkBox-test.tsx | Adds initial tests for backgroundColor rendering (currently not asserting class behavior). |
| packages/bpk-component-layout/index.ts | Exposes BACKGROUND_COLORS + BpkBoxBackgroundColor from the package entrypoint. |
| examples/bpk-component-layout/examples.module.scss | Tweaks example styling (tokenised background-size, ordering, outline block styling). |
| examples/bpk-component-layout/box-examples.tsx | Adds new swatch examples for surface/status/canvas background tokens and text colors. |
| examples/bpk-component-layout/box.stories.tsx | Adds new Storybook stories to surface the new examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| describe('backgroundColor', () => { | ||
| it('renders with a surface color token', () => { | ||
| const { container } = render( |
| expect(container.querySelector('div')).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
| type BoxEventProps = Pick<BoxProps, | ||
| 'onClick' | 'onFocus' | 'onBlur' | ||
| 'onClick' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onKeyUp' | ||
| >; |
| * - BpkBox reintroduces a minimal set of events (onClick, onFocus, onBlur) | ||
| * on its own props type. |
| // backgroundColor keys must stay in sync with backgroundColors.ts | ||
| // color keys must stay in sync with TEXT_COLORS in bpk-component-text |
|
Visit https://backpack.github.io/storybook-prs/4287 to see this build running in a browser. |
New files
packages/bpk-component-layout/src/BpkBox.module.scssSCSS module for
BpkBoxcolor props. Background colors use thebpk-surface-bg-colorsmixin (shared with BpkPanel) plus explicit status fill and canvas classes. Text colors use compound selectors (.bpk-box.bpk-box--text-*) to beat Chakra emotion specificity, matching BpkText's pattern.packages/bpk-component-layout/src/backgroundColors.tsDefines
BACKGROUND_COLORS(all-caps, matchingTEXT_COLORSconvention). ExtendsSURFACE_COLORSfrombpk-react-utilsand addsstatusSuccessFill,statusDangerFill,statusWarningFill,canvas, andcanvasContrast. ExportsBpkBoxBackgroundColortype.Modified files
packages/bpk-component-layout/src/BpkBox.tsxbackgroundColorandcolorprops handled via SCSS class approach witheslint-disable-next-line(same pattern as BpkText)React.forwardRef<HTMLElement>to expose the underlying DOM nodepackages/bpk-component-layout/src/commonProps.tsAdded to
BpkCommonLayoutProps(shared across all layout components):id,rolearia-*viaextends AriaAttributesposition,zIndexoverflow,overflowX,overflowYpackages/bpk-component-layout/src/types.tsAdded to
BpkBoxPropsonly (interaction / visual, not shared):backgroundColorBpkBoxBackgroundColorcolorTextColor(fromTEXT_COLORS)cursor'auto' | 'default' | 'pointer' | 'not-allowed'opacitynumbertabIndexnumberonKeyDown/onKeyUpBoxPropsevent typespackages/bpk-component-layout/index.tsExported
BACKGROUND_COLORSandBpkBoxBackgroundColor.examples/bpk-component-layout/box-examples.tsxAdded
SurfaceBackgroundColorExample,StatusFillBackgroundColorExample,CanvasBackgroundColorExample, andColorExample.examples/bpk-component-layout/box.stories.tsxAdded
SurfaceBackgroundColor,StatusFillBackgroundColor,CanvasBackgroundColor, andColorstories.Design decisions
backgroundColorandcoloruse SCSS classes, not Chakra semantic tokens, to keep token usage within the Backpack boundarydisplay: nonewas already supported viaBoxProps['display']— no change neededclassName,style,transform,boxShadow,transition, border shorthands, and raw CSS custom properties