Skip to content

Commit a3030e1

Browse files
authored
feat: add row_verbose layout (#7)
1 parent 936500e commit a3030e1

File tree

3 files changed

+52
-14
lines changed

3 files changed

+52
-14
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,19 @@
5454

5555
&__right {
5656
display: flex;
57+
flex-direction: column;
5758
flex-grow: 1;
5859
margin-left: 15px;
60+
61+
&-inner {
62+
display: flex;
63+
}
64+
}
65+
66+
&__description {
67+
margin-top: 10px;
68+
color: var(--yc-color-text-secondary);
69+
word-break: break-word;
5970
}
6071

6172
&__remove-button {

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

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@ import './Row.scss';
1818

1919
const b = block('row');
2020

21-
export const Row = <T extends FieldValue, S extends Spec>({
21+
interface RowProps {
22+
verboseDescription?: boolean;
23+
}
24+
25+
const RowBase = <T extends FieldValue, S extends Spec>({
2226
name,
2327
spec,
2428
input,
2529
meta,
30+
verboseDescription,
2631
children,
27-
}: LayoutProps<T, S>) => {
32+
}: LayoutProps<T, S> & RowProps) => {
2833
const arrayItem = React.useMemo(() => isArrayItem(name), [name]);
2934

3035
return (
@@ -35,7 +40,7 @@ export const Row = <T extends FieldValue, S extends Spec>({
3540
{spec.viewSpec.layoutTitle}
3641
{spec.required && <span className={b('required-mark')}>*</span>}
3742
</div>
38-
{spec.viewSpec.layoutDescription ? (
43+
{!verboseDescription && spec.viewSpec.layoutDescription ? (
3944
<div className={b('note')}>
4045
<HelpPopover
4146
htmlContent={spec.viewSpec.layoutDescription}
@@ -46,19 +51,35 @@ export const Row = <T extends FieldValue, S extends Spec>({
4651
</div>
4752
</div>
4853
<div className={b('right')}>
49-
<ErrorWrapper
50-
name={name}
51-
meta={meta}
52-
withoutChildErrorStyles={isArraySpec(spec) || isObjectSpec(spec)}
53-
>
54-
{children}
55-
</ErrorWrapper>
56-
{arrayItem ? (
57-
<Button view="flat" className={b('remove-button')} onClick={input.onDrop}>
58-
<Icon data={Xmark} size={16} />
59-
</Button>
54+
<div className={b('right-inner')}>
55+
<ErrorWrapper
56+
name={name}
57+
meta={meta}
58+
withoutChildErrorStyles={isArraySpec(spec) || isObjectSpec(spec)}
59+
>
60+
{children}
61+
</ErrorWrapper>
62+
{arrayItem ? (
63+
<Button view="flat" className={b('remove-button')} onClick={input.onDrop}>
64+
<Icon data={Xmark} size={16} />
65+
</Button>
66+
) : null}
67+
</div>
68+
{verboseDescription && spec.viewSpec.layoutDescription ? (
69+
<div
70+
className={b('description')}
71+
dangerouslySetInnerHTML={{__html: spec.viewSpec.layoutDescription}}
72+
/>
6073
) : null}
6174
</div>
6275
</div>
6376
);
6477
};
78+
79+
export const Row = <T extends FieldValue, S extends Spec>(props: LayoutProps<T, S>) => (
80+
<RowBase {...props} />
81+
);
82+
83+
export const RowVerbose = <T extends FieldValue, S extends Spec>(props: LayoutProps<T, S>) => (
84+
<RowBase verboseDescription {...props} />
85+
);

src/lib/kit/constants/config.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
OneOfView,
2929
Row,
3030
Row2,
31+
RowVerbose,
3132
Secret,
3233
Section,
3334
Section2,
@@ -76,6 +77,7 @@ export const dynamicConfig: DynamicFormConfig = {
7677
},
7778
layouts: {
7879
row: Row,
80+
row_verbose: RowVerbose,
7981
accordeon: Accordeon,
8082
section: Section,
8183
section2: Section2,
@@ -96,6 +98,7 @@ export const dynamicConfig: DynamicFormConfig = {
9698
},
9799
layouts: {
98100
row: Row,
101+
row_verbose: RowVerbose,
99102
table_item: TableCell,
100103
},
101104
validators: {
@@ -108,6 +111,7 @@ export const dynamicConfig: DynamicFormConfig = {
108111
},
109112
layouts: {
110113
row: Row,
114+
row_verbose: RowVerbose,
111115
table_item: TableCell,
112116
transparent: Transparent,
113117
},
@@ -124,6 +128,7 @@ export const dynamicConfig: DynamicFormConfig = {
124128
},
125129
layouts: {
126130
row: Row,
131+
row_verbose: RowVerbose,
127132
accordeon: Accordeon,
128133
section: Section,
129134
section2: Section2,
@@ -149,6 +154,7 @@ export const dynamicConfig: DynamicFormConfig = {
149154
},
150155
layouts: {
151156
row: Row,
157+
row_verbose: RowVerbose,
152158
table_item: TableCell,
153159
transparent: Transparent,
154160
section: Section,

0 commit comments

Comments
 (0)