Skip to content

Commit 386fe01

Browse files
committed
feat: add row direction
1 parent e7a710c commit 386fe01

File tree

4 files changed

+62
-32
lines changed

4 files changed

+62
-32
lines changed

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

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
@import '../../../styles/variables.scss';
22

33
.#{$ns}row {
4-
display: flex;
5-
width: 500px;
6-
max-width: 500px;
74
margin-bottom: 15px;
85

6+
&_direction-horizontal {
7+
display: flex;
8+
width: 500px;
9+
max-width: 500px;
10+
}
11+
12+
&_direction-vertical {
13+
display: flex;
14+
width: 500px;
15+
max-width: 500px;
16+
}
17+
918
&:last-child {
1019
margin-bottom: 0;
1120
}
1221

13-
&__left {
14-
width: 180px;
22+
&__label {
23+
&_direction-horizontal {
24+
width: 180px;
25+
}
26+
1527
min-height: 28px;
1628
display: flex;
1729
margin-bottom: auto;
@@ -44,9 +56,12 @@
4456
}
4557

4658
&__note {
47-
padding-right: 16px;
4859
position: relative;
4960

61+
&_direction-horizontal {
62+
padding-right: 16px;
63+
}
64+
5065
&-inner {
5166
position: absolute;
5267
margin-top: 1px;
@@ -61,11 +76,13 @@
6176
}
6277
}
6378

64-
&__right {
65-
display: flex;
66-
flex-direction: column;
67-
flex-grow: 1;
68-
margin-left: 15px;
79+
&__value {
80+
&_direction-horizontal {
81+
display: flex;
82+
flex-direction: column;
83+
flex-grow: 1;
84+
margin-left: 15px;
85+
}
6986

7087
&-inner {
7188
display: flex;

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import './Row.scss';
2222
const b = block('row');
2323

2424
interface RowProps {
25+
direction?: 'vertical' | 'horizontal';
2526
verboseDescription?: boolean;
2627
}
2728

@@ -31,20 +32,21 @@ const RowBase = <T extends FieldValue, S extends Spec>({
3132
input,
3233
meta,
3334
verboseDescription,
35+
direction = 'vertical',
3436
children,
3537
}: LayoutProps<T, undefined, undefined, S> & RowProps) => {
3638
const arrayItem = React.useMemo(() => isArrayItem(name), [name]);
3739
const generateButton = React.useMemo(() => withGenerateButton(spec), [spec]);
3840

3941
return (
40-
<div className={b()}>
41-
<div className={b('left')}>
42-
<div className={b('left-inner')}>
42+
<div className={b('', {direction})}>
43+
<div className={b('label', {direction})}>
44+
<div className={b('label-inner')}>
4345
<Text className={b('title', {required: spec.required})}>
4446
{spec.viewSpec.layoutTitle}
4547
</Text>
4648
{!verboseDescription && spec.viewSpec.layoutDescription ? (
47-
<span className={b('note')}>
49+
<span className={b('note', {direction})}>
4850
<Text className={b('note-inner')}>
4951
<HelpPopover
5052
htmlContent={spec.viewSpec.layoutDescription}
@@ -55,8 +57,8 @@ const RowBase = <T extends FieldValue, S extends Spec>({
5557
) : null}
5658
</div>
5759
</div>
58-
<div className={b('right')}>
59-
<div className={b('right-inner')}>
60+
<div className={b('value', {direction})}>
61+
<div className={b('value-inner')}>
6062
<ErrorWrapper
6163
name={name}
6264
meta={meta}

src/lib/kit/components/ViewLayouts/ViewRow/ViewRow.scss

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,23 @@
33

44
.#{$ns}view-row {
55
width: 100%;
6-
display: flex;
76
margin-bottom: 20px;
87

98
&:last-child {
109
margin-bottom: 0;
1110
}
1211

13-
&__left {
14-
width: 300px;
15-
max-width: 300px;
16-
min-width: 300px;
12+
&_direction-horizontal {
13+
display: flex;
14+
}
15+
16+
&__label {
17+
&_direction-horizontal {
18+
width: 300px;
19+
max-width: 300px;
20+
min-width: 300px;
21+
}
22+
1723
display: flex;
1824
align-items: baseline;
1925
overflow: hidden;
@@ -30,11 +36,13 @@
3036
border-bottom: 1px dotted var(--g-color-text-secondary);
3137
}
3238

33-
&__right {
34-
max-width: 480px;
35-
white-space: nowrap;
36-
overflow: hidden;
37-
text-overflow: ellipsis;
39+
&__value {
40+
&_direction-horizontal {
41+
max-width: 480px;
42+
white-space: nowrap;
43+
overflow: hidden;
44+
text-overflow: ellipsis;
45+
}
3846

3947
& > .#{$ns}view-transparent {
4048
margin-bottom: 6px;

src/lib/kit/components/ViewLayouts/ViewRow/ViewRow.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,19 @@ export const ViewRow = <T extends FormValue, S extends Spec>({
1515
value,
1616
spec,
1717
children,
18-
}: ViewLayoutProps<T, S>) => {
18+
direction = 'vertical',
19+
}: ViewLayoutProps<T, S> & {
20+
direction?: 'vertical' | 'horizontal';
21+
}) => {
1922
const {showLayoutDescription} = useDynamicFormsCtx();
2023

2124
if (!isNotEmptyValue(value, spec)) {
2225
return null;
2326
}
2427

2528
return (
26-
<div className={b()}>
27-
<div className={b('left')}>
29+
<div className={b('', {direction})}>
30+
<div className={b('label', {direction})}>
2831
<Text whiteSpace="nowrap" color="secondary" ellipsis={true}>
2932
{spec.viewSpec.layoutTitle}
3033
</Text>
@@ -35,9 +38,9 @@ export const ViewRow = <T extends FormValue, S extends Spec>({
3538
placement={['bottom', 'top']}
3639
/>
3740
) : null}
38-
<div className={b('dots')} />
41+
{direction === 'horizontal' && <div className={b('dots')} />}
3942
</div>
40-
<div className={b('right')}>{children}</div>
43+
<div className={b('value', {direction})}>{children}</div>
4144
<CopyButton spec={spec} value={value} />
4245
</div>
4346
);

0 commit comments

Comments
 (0)