Skip to content

Commit 974b8af

Browse files
authored
feat(Layout): auto-border (#921)
1 parent 8c97de9 commit 974b8af

File tree

9 files changed

+37
-4
lines changed

9 files changed

+37
-4
lines changed

.changeset/layout-auto-border.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': patch
3+
---
4+
5+
Layout sub-components now automatically add bottom borders between elements when the layout has vertical flow. This eliminates the need to manually set borders on individual components to create visual separation.

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107

108108
- name: Publish to Chromatic
109109
id: publish_chromatic
110-
uses: chromaui/action@v1
110+
uses: chromaui/action@v11
111111
with:
112112
exitZeroOnChanges: true
113113
exitOnceUploaded: true

.github/workflows/pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ jobs:
175175

176176
- name: Publish to Chromatic
177177
id: publish_chromatic
178-
uses: chromaui/action@v1
178+
uses: chromaui/action@v11
179179
with:
180180
exitZeroOnChanges: true
181181
exitOnceUploaded: true

src/components/content/Layout/Layout.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ const LayoutElement = tasty({
4949
},
5050

5151
'$content-padding': '1x',
52+
// Auto-border size for sub-components (set when layout is vertical)
53+
'$layout-border-size': {
54+
'': '0',
55+
vertical: '1bw',
56+
},
5257

5358
Inner: {
5459
// Direct child selector required for nested layouts
@@ -149,6 +154,16 @@ function LayoutInner(
149154
const outerStyles = extractStyles(otherProps, OUTER_STYLES);
150155
const innerStyles = extractStyles(otherProps, INNER_STYLES);
151156

157+
// Calculate if the layout flow is vertical (for auto-border feature)
158+
// Default flow is 'column' (vertical), check if user overrides it
159+
const isVertical = useMemo(() => {
160+
const providedFlow = (styles?.Inner as Record<string, unknown>)?.flow;
161+
const flowValue =
162+
typeof providedFlow === 'string' ? providedFlow : 'column';
163+
164+
return flowValue.startsWith('column');
165+
}, [styles?.Inner]);
166+
152167
// Merge styles using the same pattern as LayoutPane
153168
const finalStyles = useMemo(() => {
154169
// Handle grid mode and grid properties
@@ -259,8 +274,9 @@ function LayoutInner(
259274
'has-transition': hasTransition,
260275
'auto-height': isAutoHeight && !isCollapsed,
261276
collapsed: isCollapsed,
277+
vertical: isVertical,
262278
}),
263-
[isDragging, isReady, hasTransition, isAutoHeight, isCollapsed],
279+
[isDragging, isReady, hasTransition, isAutoHeight, isCollapsed, isVertical],
264280
);
265281

266282
// Combine local ref with forwarded ref

src/components/content/Layout/LayoutContainer.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const ContainerElement = tasty({
2828
padding: '$content-padding',
2929
placeSelf: 'stretch',
3030
width: '100%',
31+
border: {
32+
'': 0,
33+
'!:last-child': '$layout-border-size solid #border bottom',
34+
},
3135

3236
Inner: {
3337
$: '>',

src/components/content/Layout/LayoutContent.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const ContentElement = tasty({
3333
height: 'min 0',
3434
overflow: 'hidden',
3535
boxSizing: 'content-box',
36+
border: {
37+
'': 0,
38+
'!:last-child': '$layout-border-size solid #border bottom',
39+
},
3640

3741
Inner: {
3842
$: '>',

src/components/content/Layout/LayoutFooter.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const FooterElement = tasty(LayoutContent, {
99
qa: 'LayoutFooter',
1010
role: 'contentinfo',
1111
styles: {
12-
border: 'top',
12+
// Footer inherits auto-border from LayoutContent
13+
// (no border when last-child, which is typical for footers)
1314
height: 'min 5x',
1415
flexShrink: 0,
1516
flexGrow: 0,

src/components/content/Layout/LayoutHeader.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const HeaderElement = tasty(LayoutContent, {
2020
as: 'header',
2121
qa: 'LayoutHeader',
2222
styles: {
23+
// Header always has bottom border (inherent style)
2324
border: 'bottom',
2425
flexShrink: 0,
2526
flexGrow: 0,

src/components/content/Layout/LayoutPanel.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ const PanelElement = tasty({
6262
boxSizing: 'border-box',
6363

6464
'$content-padding': '1x',
65+
// Auto-border size for sub-components (panels are always vertical)
66+
'$layout-border-size': '1bw',
6567

6668
// Position based on side prop
6769
top: {

0 commit comments

Comments
 (0)