Skip to content

[FEATURE] UI customization. Add Box primitive component - #299

Merged
jgbernalp merged 22 commits into
perses:ui-customizationfrom
zhuje:worktree-box-stack-primitives
Oct 13, 2026
Merged

jgbernalp merged 22 commits into
perses:ui-customizationfrom
zhuje:worktree-box-stack-primitives

Conversation

@zhuje

@zhuje zhuje commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Description

Create Box primitive component as part of this initiative perses/perses#3570

Previous PRs towards this initiative:

Ladel Story showcasing Box component
Screenshot 2026-09-15 at 3 32 46 PM

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.
  • E2E tests are stable and unlikely to be flaky.
    See e2e docs for more details. Common issues include:
    • Is the data inconsistent? You need to mock API requests.
    • Does the time change? You need to use consistent time values or mock time utilities.
    • Does it have loading states? You need to wait for loading to complete.

@zhuje
zhuje requested a review from a team as a code owner September 16, 2026 18:57
@zhuje
zhuje force-pushed the worktree-box-stack-primitives branch from a78beda to b0648b6 Compare September 16, 2026 19:59
@zhuje
zhuje marked this pull request as draft September 16, 2026 20:32
@zhuje

zhuje commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor Author

HOLD

TDepends on this #300 merging first to fix CI issue due BREAKINGCHANGES with Node upgrade and removal of CommonJS

@zhuje
zhuje force-pushed the worktree-box-stack-primitives branch from aa34d0c to b0648b6 Compare September 16, 2026 20:58
@zhuje
zhuje force-pushed the worktree-box-stack-primitives branch 2 times, most recently from 3c1faa8 to c0b8da9 Compare September 17, 2026 18:06
@zhuje
zhuje marked this pull request as ready for review September 17, 2026 19:35
Comment thread components/src/next/primitives/Box/Box.tsx Outdated
Comment thread components/src/next/primitives/Box/Box.tsx Outdated
Comment thread components/src/next/primitives/Box/Box.tsx Outdated
Comment thread components/src/next/primitives/Box/Box.tsx Outdated
Comment thread components/src/next/primitives/Box/Box.tsx Outdated
@zhuje
zhuje force-pushed the worktree-box-stack-primitives branch from b301a27 to 1c52c92 Compare September 22, 2026 02:46
Comment thread components/src/next/primitives/Box/Box.tsx Outdated
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
…and Alert primitives (perses#213)

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
… and remove CommonJS (perses#300)

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
… Node updates

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
@zhuje
zhuje force-pushed the worktree-box-stack-primitives branch from 1c52c92 to cb533f0 Compare September 23, 2026 19:54
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
Comment thread components/src/next/primitives/Box/box.css Outdated
Comment thread components/src/next/primitives/Box/Box.stories.tsx Outdated

export interface BoxProps extends HTMLAttributes<HTMLDivElement> {
display?: CSSProperties['display'];
p?: SpacingToken;

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.

Suggested change
p?: SpacingToken;
p?: Responsive<SpacingToken>;

in which SpacingToken could be something similar to

// 1. Define your supported breakpoints
export type Breakpoint = 'default' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';

// 2. Create a mapped type where each breakpoint is an optional key for type T
export type ResponsiveObject<T> = {
  [Key in Breakpoint]?: T;
};

// 3. Create the final generic type: either a direct value OR the responsive object
export type Responsive<T> = T | ResponsiveObject<T>;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed. Responsive<T>, ResponsiveObject<T>, and Breakpoint are defined in the shared primitive system utility. Box spacing props now use Responsive<SpacingToken>.

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.

we might need to adjust previously created components to include this, can you create a follow UP PR with this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I reviewed the existing primitives and their usage. I do not think Button, Alert, or Divider need responsive props by default.

Their responsive behavior should be controlled by the surrounding layout. A parent container can change direction, wrap content, adjust available space, or hide controls at breakpoints, while these primitives retain consistent behavior and accessible sizing. Divider already adjusts to its parent: horizontal dividers use the full available width, and vertical dividers use the available height.

The shared responsive utility is most useful for layout primitives such as Box, where properties like display, flexDirection, gap, and width often need to change across breakpoints. We can add responsive behavior to another primitive later if a specific product requirement shows that it is needed.

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.

The problem of adding later is that it might be a breaking api change, more difficult to change for users that use the new components. I find valuable to include responsiveness on the button sizes for example: In mobile you might want to use an md button, aligning with a11y so the button fits in a human thumb, but on large screens you might want to use an xs button as the mouse might allow smaller buttons to be clicked. I agree the divider does not need responsiveness as it is already designed with that in mind.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@zhuje
zhuje force-pushed the worktree-box-stack-primitives branch from be7f323 to 164a708 Compare September 25, 2026 00:44
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
…Update Box.tsx, Box.test.tsx and Box.stories.tsx to improve how props are checked and applied

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
  Add a reusable Box primitive with token-based padding, margin, gap,
  and common layout props.

  Add reusable spacing utility styles and responsive spacing support
  through shared primitive system utilities.

  Add Box stories and focused tests.

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
@zhuje
zhuje force-pushed the worktree-box-stack-primitives branch from 164a708 to bb7f31b Compare September 25, 2026 00:48
Comment thread components/package.json
Comment thread components/src/next/contexts/ComponentsContext.ts Outdated
Comment thread components/src/next/primitives/system/spacing.css Outdated
Comment thread components/src/next/primitives/system/spacing.css Outdated
Comment thread components/src/next/primitives/system/responsive.ts Outdated
 - Exported the shared responsive stylesheet from @perses-dev/components.
 - Renamed responsive CSS variables from --ps-box-* to generic --ps-
    responsive-*, so the responsive utility can be reused by future layout
    primitives.
- Updated the responsive stylesheet and Box test to use the new variable
    names.
- Simplified spacing CSS by removing intermediate --ps-spacing-value-*
    variables and referencing Perses spacing tokens directly.

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
Addresses react-doctor no-object-keys-values-entries-on-maybe-undefined
(perses#352 (comment)).
The value is already narrowed by isResponsiveValue, but the linter does
not follow custom type guards, so add a `?? {}` fallback.

Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
Comment thread components/src/next/primitives/Box/Box.tsx
Signed-off-by: Gabriel Bernal <gbernal@redhat.com>
…factor box stories

Signed-off-by: Gabriel Bernal <gbernal@redhat.com>
Signed-off-by: Gabriel Bernal <gbernal@redhat.com>
Signed-off-by: Gabriel Bernal <gbernal@redhat.com>
Signed-off-by: Gabriel Bernal <gbernal@redhat.com>
Signed-off-by: Gabriel Bernal <gbernal@redhat.com>
@jgbernalp
jgbernalp merged commit c97ec5c into perses:ui-customization Oct 13, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants