Skip to content

Commit dd9d1c7

Browse files
authored
Try add layout action (#320)
1 parent df08011 commit dd9d1c7

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

src/lib/kit/components/Layouts/Column/Column.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
min-height: var(--df-column-first-row-min-height, 28px);
1212
display: flex;
1313
margin-bottom: auto;
14-
flex-direction: column;
14+
flex-direction: row;
1515
flex-shrink: 0;
1616

1717
&-inner {
18-
display: inline;
18+
flex-grow: 1;
1919
margin-top: auto;
2020
margin-bottom: auto;
2121
}
2222

23-
&::after {
24-
content: '';
25-
width: 100%;
26-
flex-shrink: 1;
23+
&-action {
24+
padding-left: var(--g-spacing-2);
25+
margin-top: auto;
26+
margin-bottom: auto;
2727
}
2828
}
2929

src/lib/kit/components/Layouts/Column/Column.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ import './Column.scss';
1414

1515
const b = block('column');
1616

17-
interface ColumnProps {}
17+
interface ColumnProps {
18+
action?: React.ReactNode;
19+
}
1820

1921
const ColumnBase = <T extends FieldValue, S extends Spec>({
2022
name,
2123
spec,
2224
input,
2325
meta,
2426
children,
27+
action,
2528
}: LayoutProps<T, undefined, undefined, S> & ColumnProps) => {
2629
const arrayItem = React.useMemo(() => isArrayItem(name), [name]);
2730
const generateButton = React.useMemo(() => withGenerateButton(spec), [spec]);
@@ -47,6 +50,7 @@ const ColumnBase = <T extends FieldValue, S extends Spec>({
4750
</span>
4851
) : null}
4952
</div>
53+
{Boolean(action) && <div className={b('first-row-action')}>{action}</div>}
5054
</div>
5155
<div className={b('second-row')}>
5256
<div className={b('second-row-inner')}>

src/lib/kit/components/Layouts/Row/Row.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
margin-bottom: auto;
2525
}
2626

27+
&-action {
28+
padding-left: var(--g-spacing-2);
29+
}
30+
2731
&::after {
2832
content: '';
2933
width: 100%;

src/lib/kit/components/Layouts/Row/Row.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const b = block('row');
1616

1717
interface RowProps {
1818
verboseDescription?: boolean;
19+
action?: React.ReactNode;
1920
}
2021

2122
const RowBase = <T extends FieldValue, S extends Spec>({
@@ -24,6 +25,7 @@ const RowBase = <T extends FieldValue, S extends Spec>({
2425
input,
2526
meta,
2627
verboseDescription,
28+
action,
2729
children,
2830
}: LayoutProps<T, undefined, undefined, S> & RowProps) => {
2931
const arrayItem = React.useMemo(() => isArrayItem(name), [name]);
@@ -49,6 +51,7 @@ const RowBase = <T extends FieldValue, S extends Spec>({
4951
</Text>
5052
</span>
5153
) : null}
54+
{Boolean(action) && <span className={b('left-action')}>{action}</span>}
5255
</div>
5356
</div>
5457
<div className={b('right')}>

0 commit comments

Comments
 (0)