Repository navigation
[FEATURE] UI customization. Add Box primitive component - #299
Conversation
a78beda to
b0648b6
Compare
|
|
aa34d0c to
b0648b6
Compare
3c1faa8 to
c0b8da9
Compare
b301a27 to
1c52c92
Compare
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>
ccde284 to
a04da7d
Compare
1c52c92 to
cb533f0
Compare
Signed-off-by: Jenny Zhu <jenny.a.zhu@gmail.com>
|
|
||
| export interface BoxProps extends HTMLAttributes<HTMLDivElement> { | ||
| display?: CSSProperties['display']; | ||
| p?: SpacingToken; |
There was a problem hiding this comment.
| 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>;There was a problem hiding this comment.
Addressed. Responsive<T>, ResponsiveObject<T>, and Breakpoint are defined in the shared primitive system utility. Box spacing props now use Responsive<SpacingToken>.
There was a problem hiding this comment.
we might need to adjust previously created components to include this, can you create a follow UP PR with this.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
be7f323 to
164a708
Compare
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>
164a708 to
bb7f31b
Compare
- 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>
Signed-off-by: Gabriel Bernal <gbernal@redhat.com>
…factor box stories Signed-off-by: Gabriel Bernal <gbernal@redhat.com>
56c5a50 to
3eaff7f
Compare
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>
Description
Create
Boxprimitive component as part of this initiative perses/perses#3570Previous PRs towards this initiative:
Ladel Story showcasing Box component

Checklist
[<catalog_entry>] <commit message>naming convention using one of thefollowing
catalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.UI Changes
See e2e docs for more details. Common issues include: