Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 28 additions & 11 deletions src/lib/kit/components/Layouts/Row/Row.scss
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
@import '../../../styles/variables.scss';

.#{$ns}row {
display: flex;
width: 500px;
max-width: 500px;
margin-bottom: 15px;

&_direction-horizontal {
display: flex;
width: 500px;
max-width: 500px;
}

&_direction-vertical {
display: flex;
width: 500px;
max-width: 500px;
}

&:last-child {
margin-bottom: 0;
}

&__left {
width: 180px;
&__label {
&_direction-horizontal {
width: 180px;
}

min-height: 28px;
display: flex;
margin-bottom: auto;
Expand Down Expand Up @@ -44,9 +56,12 @@
}

&__note {
padding-right: 16px;
position: relative;

&_direction-horizontal {
padding-right: 16px;
}

&-inner {
position: absolute;
margin-top: 1px;
Expand All @@ -61,11 +76,13 @@
}
}

&__right {
display: flex;
flex-direction: column;
flex-grow: 1;
margin-left: 15px;
&__value {
&_direction-horizontal {
display: flex;
flex-direction: column;
flex-grow: 1;
margin-left: 15px;
}

&-inner {
display: flex;
Expand Down
14 changes: 8 additions & 6 deletions src/lib/kit/components/Layouts/Row/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import './Row.scss';
const b = block('row');

interface RowProps {
direction?: 'vertical' | 'horizontal';
verboseDescription?: boolean;
}

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

return (
<div className={b()}>
<div className={b('left')}>
<div className={b('left-inner')}>
<div className={b('', {direction})}>
<div className={b('label', {direction})}>
<div className={b('label-inner')}>
<Text className={b('title', {required: spec.required})}>
{spec.viewSpec.layoutTitle}
</Text>
{!verboseDescription && spec.viewSpec.layoutDescription ? (
<span className={b('note')}>
<span className={b('note', {direction})}>
<Text className={b('note-inner')}>
<HelpPopover
htmlContent={spec.viewSpec.layoutDescription}
Expand All @@ -55,8 +57,8 @@ const RowBase = <T extends FieldValue, S extends Spec>({
) : null}
</div>
</div>
<div className={b('right')}>
<div className={b('right-inner')}>
<div className={b('value', {direction})}>
<div className={b('value-inner')}>
<ErrorWrapper
name={name}
meta={meta}
Expand Down
28 changes: 18 additions & 10 deletions src/lib/kit/components/ViewLayouts/ViewRow/ViewRow.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@

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

&:last-child {
margin-bottom: 0;
}

&__left {
width: 300px;
max-width: 300px;
min-width: 300px;
&_direction-horizontal {
display: flex;
}

&__label {
&_direction-horizontal {
width: 300px;
max-width: 300px;
min-width: 300px;
}

display: flex;
align-items: baseline;
overflow: hidden;
Expand All @@ -30,11 +36,13 @@
border-bottom: 1px dotted var(--g-color-text-secondary);
}

&__right {
max-width: 480px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
&__value {
&_direction-horizontal {
max-width: 480px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

& > .#{$ns}view-transparent {
margin-bottom: 6px;
Expand Down
13 changes: 8 additions & 5 deletions src/lib/kit/components/ViewLayouts/ViewRow/ViewRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ export const ViewRow = <T extends FormValue, S extends Spec>({
value,
spec,
children,
}: ViewLayoutProps<T, S>) => {
direction = 'vertical',
}: ViewLayoutProps<T, S> & {
direction?: 'vertical' | 'horizontal';
}) => {
const {showLayoutDescription} = useDynamicFormsCtx();

if (!isNotEmptyValue(value, spec)) {
return null;
}

return (
<div className={b()}>
<div className={b('left')}>
<div className={b('', {direction})}>
<div className={b('label', {direction})}>
<Text whiteSpace="nowrap" color="secondary" ellipsis={true}>
{spec.viewSpec.layoutTitle}
</Text>
Expand All @@ -35,9 +38,9 @@ export const ViewRow = <T extends FormValue, S extends Spec>({
placement={['bottom', 'top']}
/>
) : null}
<div className={b('dots')} />
{direction === 'horizontal' && <div className={b('dots')} />}
</div>
<div className={b('right')}>{children}</div>
<div className={b('value', {direction})}>{children}</div>
<CopyButton spec={spec} value={value} />
</div>
);
Expand Down
Loading