Conversation
Added more props to card component Fixed spacing in button group component
openmetadata-ui-core-components/src/main/resources/ui/src/components/base/divider/divider.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR updates openmetadata-ui-core-components to improve component ergonomics and consistency by introducing a new Box layout primitive, expanding the Card API with sub-components, refining existing Tabs/Divider/ButtonGroup implementations, and enhancing Storybook stories/argTypes to better document these components.
Changes:
- Added a new
Boxflex layout component, supporting direction/alignment/justification/wrap and gap utilities, plus a supporting Tailwind class mapping constant. - Refactored
Cardto a composed sub-component API (Card.Header,Card.Content,Card.Footer) with variant/color/size/interactive styling. - Updated
Tabs,Divider, andButtonGroupimplementations and expanded Storybook stories/argTypes for better documentation.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| openmetadata-ui-core-components/src/main/resources/ui/src/stories/Tabs.stories.tsx | Reworked Tabs stories to use the core-components Tabs API and added more usage examples. |
| openmetadata-ui-core-components/src/main/resources/ui/src/stories/Divider.stories.tsx | Added argTypes to document Divider prop unions in Storybook. |
| openmetadata-ui-core-components/src/main/resources/ui/src/stories/Card.stories.tsx | Added argTypes and expanded stories to cover variants/colors/sizes and sub-components. |
| openmetadata-ui-core-components/src/main/resources/ui/src/stories/ButtonGroup.stories.tsx | Added argTypes and a trailing-icon story example. |
| openmetadata-ui-core-components/src/main/resources/ui/src/stories/Box.stories.tsx | Added Storybook coverage for the new Box component behaviors. |
| openmetadata-ui-core-components/src/main/resources/ui/src/constants/tailwindClasses.constants.ts | Introduced static Tailwind class maps for gap utilities. |
| openmetadata-ui-core-components/src/main/resources/ui/src/components/index.ts | Exported the new Box component from the package entrypoint. |
| openmetadata-ui-core-components/src/main/resources/ui/src/components/base/divider/divider.tsx | Updated Divider rendering to use <hr> for unlabeled dividers. |
| openmetadata-ui-core-components/src/main/resources/ui/src/components/base/card/card.tsx | Implemented composed Card API with sizing context and variant/color styling. |
| openmetadata-ui-core-components/src/main/resources/ui/src/components/base/button-group/button-group.tsx | Refactored ButtonGroup styles and imports; kept react-aria ToggleButtonGroup usage. |
| openmetadata-ui-core-components/src/main/resources/ui/src/components/base/box/box.tsx | Added the new Box component implementation. |
| openmetadata-ui-core-components/src/main/resources/ui/src/components/application/tabs/tabs.tsx | Reformatted/refined Tabs component and related styling helpers. |
Comments suppressed due to low confidence (1)
openmetadata-ui-core-components/src/main/resources/ui/src/components/base/divider/divider.tsx:23
DividerPropsextendsHTMLAttributes<HTMLDivElement>, but the component returns an<hr>for the common (unlabeled) horizontal and vertical cases. This makes the prop typing inaccurate (and allows passingchildren, which React warns about on void elements like<hr>). Consider splitting props by render path (e.g.,<hr>props vs labeled<div>props) or using a safer common type that omitschildrenfor the<hr>branches.
export type DividerOrientation = "horizontal" | "vertical";
export type DividerLabelAlignment = "start" | "center" | "end";
export interface DividerProps extends HTMLAttributes<HTMLDivElement> {
orientation?: DividerOrientation;
label?: ReactNode;
labelAlign?: DividerLabelAlignment;
}
openmetadata-ui-core-components/src/main/resources/ui/src/components/base/box/box.tsx
Outdated
Show resolved
Hide resolved
openmetadata-ui-core-components/src/main/resources/ui/src/components/base/box/box.tsx
Outdated
Show resolved
Hide resolved
openmetadata-ui-core-components/src/main/resources/ui/src/components/application/tabs/tabs.tsx
Outdated
Show resolved
Hide resolved
...a-ui-core-components/src/main/resources/ui/src/components/base/button-group/button-group.tsx
Outdated
Show resolved
Hide resolved
| const gapValue = gap ? gapClassMapping[gap] : undefined; | ||
| const rowGapValue = rowGap ? rowGapClassMapping[rowGap] : undefined; | ||
| const colGapValue = colGap ? colGapClassMapping[colGap] : undefined; |
There was a problem hiding this comment.
⚠️ Edge Case: Box: gap=0 is silently ignored due to falsy check
In box.tsx, the gap values are guarded with a truthiness check (gap ? gapClassMapping[gap] : undefined). Since 0 is falsy in JavaScript, passing gap={0} (or rowGap={0} / colGap={0}) will not apply the tw:gap-0 class, even though gapClassMapping[0] is defined as 'tw:gap-0'.
A consumer might explicitly pass gap={0} to reset gap (e.g., overriding a parent style), and it would silently do nothing. The same issue applies to rowGap and colGap.
Suggested fix:
const gapValue = gap != null ? gapClassMapping[gap] : undefined;
const rowGapValue = rowGap != null ? rowGapClassMapping[rowGap] : undefined;
const colGapValue = colGap != null ? colGapClassMapping[colGap] : undefined;
Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion
| ref | ||
| ) => { | ||
| return ( | ||
| <CardContext.Provider value={{ size }}> |
There was a problem hiding this comment.
💡 Performance: Card context value not memoized unlike TabList and ButtonGroup
In CardBase, the context value { size } is created inline on every render (<CardContext.Provider value={{ size }}>), which creates a new object reference each time and may cause unnecessary re-renders of CardHeader, CardContent, and CardFooter consumers.
This PR already added useMemo for the same pattern in TabList (line 184-187) and ButtonGroup (line 120), but the Card component was missed.
Suggested fix:
// Add useMemo import, then in CardBase:
const contextValue = useMemo(() => ({ size }), [size]);
return (
<CardContext.Provider value={contextValue}>
...
</CardContext.Provider>
);
Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion
Code Review
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar
🟡 Playwright Results — all passed (18 flaky)✅ 3415 passed · ❌ 0 failed · 🟡 18 flaky · ⏭️ 183 skipped
🟡 18 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
| return ( | ||
| <div | ||
| {...props} | ||
| className={cx( | ||
| "tw:outline-focus-ring tw:focus-visible:outline-2 tw:focus-visible:outline-offset-2 tw:relative tw:overflow-hidden tw:rounded-xl tw:ring-1 tw:ring-inset tw:ring-secondary tw:bg-primary", | ||
| className, | ||
| 'tw:flex tw:items-start tw:justify-between tw:gap-4 tw:border-b tw:border-secondary', |
There was a problem hiding this comment.
This change may cause issue where it is used.
Previously Card just had a border to it, now we have changed the default layout here.
Confirm the usages
There was a problem hiding this comment.
Also why are restricting usage of flex in default
This pull request primarily focuses on code style consistency and maintainability improvements across several UI component files. The most significant change is the consistent use of single quotes for string literals, replacing double quotes throughout the codebase. Additionally, a new flexible
Boxlayout component is introduced, and some minor refactors and style improvements are made to existing components.Code Style Consistency:
tabs.tsxandbutton-group.tsx, improving code consistency and reducing potential linting issues. [1] [2] [3] [4] [5] [6] [7] [8]Component Enhancements:
Boxcomponent (box.tsx) that provides a flexible, configurable flexbox container with support for direction, alignment, justification, wrapping, and gap utilities, streamlining layout creation.Refactor and Minor Improvements:
TabList,TabPanel,Tab, andTabscomponents. [1] [2] [3] [4]button-group.tsxcomponent by updating spacing calculations and maintaining consistency in style definitions.Utility Improvements:
cxandsortCx) use the new single quote convention and are consistently ordered.These changes collectively improve the codebase's readability, maintainability, and consistency for future development.