Skip to content

Commit eb63e6d

Browse files
committed
Add shape settings scope tabs
1 parent 531e1e9 commit eb63e6d

File tree

13 files changed

+507
-125
lines changed

13 files changed

+507
-125
lines changed

src/shared/constants/qa/wizard.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ export const enum ChartSettingsDialogQA {
197197
}
198198

199199
export const enum DialogShapeSettings {
200+
LineSettingsScopeTab = 'line-settings-scope-tab',
200201
LineWidthSelectControl = 'line-width-select-control',
201202
LineWidthSelectOption = 'line-width-select-option',
202203
}

src/shared/types/config/wizard/v15.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ export type V15ColorsConfig = {
312312
export type V15ShapesConfig = {
313313
mountedShapes?: Record<string, string>;
314314
mountedShapesLineWidths?: Record<string, number>;
315+
chartLineWidth?: number;
315316
fieldGuid?: string;
316317
};
317318

src/shared/types/wizard/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ export type Sort = Field & {
511511
export interface ShapesConfig {
512512
mountedShapes?: Record<string, string>;
513513
mountedShapesLineWidths?: Record<string, number>;
514+
chartLineWidth?: number;
514515
fieldGuid?: string;
515516
}
516517

src/ui/units/wizard/components/Dialogs/DialogShapes/DialogLineWidth/DialogLineWidth.tsx

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,65 @@ import React from 'react';
22

33
import {Flex, Text} from '@gravity-ui/uikit';
44
import NumberInput from 'ui/components/NumberFormatSettings/NumberInput/NumberInput';
5-
import {LINE_WIDTH_MAX_VALUE, LINE_WIDTH_MIN_VALUE} from 'ui/units/wizard/constants/shapes';
5+
import {
6+
LINE_WIDTH_AUTO_VALUE,
7+
LINE_WIDTH_MAX_VALUE,
8+
LINE_WIDTH_MIN_VALUE,
9+
} from 'ui/units/wizard/constants/shapes';
610

711
import {LineWidthSelect} from '../../../LineWidthSelect/LineWidthSelect';
812

913
interface DialogLineWidthProps {
10-
value: number;
11-
onChange: (lineWidth: number) => void;
14+
value: string;
15+
onChange: (lineWidth: string) => void;
16+
style?: React.CSSProperties;
1217
}
1318

1419
// TODO: Fix in a separate branch
1520
const I18N_STUB = {
1621
'dialog-line-width-title': 'Толщина линии',
1722
};
1823

19-
export const DialogLineWidth = React.memo(({value, onChange}: DialogLineWidthProps) => {
20-
return (
21-
<Flex direction="column" gap={2}>
22-
<Flex direction="row" alignItems="center" justifyContent="space-between">
23-
<Text variant="body-1">{I18N_STUB['dialog-line-width-title']}</Text>
24-
<LineWidthSelect value={value} onChange={onChange} />
25-
</Flex>
24+
export const DialogLineWidth = React.memo(({value, onChange, style}: DialogLineWidthProps) => {
25+
const handleNumberInputChange = React.useCallback(
26+
(nextValue: number) => {
27+
return onChange(nextValue.toString());
28+
},
29+
[onChange],
30+
);
31+
32+
const isAutoValue = value === LINE_WIDTH_AUTO_VALUE;
33+
34+
const numberInput = React.useMemo(() => {
35+
if (isAutoValue) {
36+
return null;
37+
}
38+
39+
const valueNumber = Number.parseInt(value, 10);
40+
41+
if (Number.isNaN(valueNumber)) {
42+
return null;
43+
}
44+
45+
return (
2646
<Flex direction="row" alignItems="center" justifyContent="flex-end">
2747
<NumberInput
28-
value={value}
48+
value={valueNumber}
2949
min={LINE_WIDTH_MIN_VALUE}
3050
max={LINE_WIDTH_MAX_VALUE}
31-
onChange={onChange}
51+
onChange={handleNumberInputChange}
3252
/>
3353
</Flex>
54+
);
55+
}, [handleNumberInputChange, value, isAutoValue]);
56+
57+
return (
58+
<Flex direction="column" gap={2} style={style}>
59+
<Flex direction="row" alignItems="center" justifyContent="space-between">
60+
<Text variant="body-1">{I18N_STUB['dialog-line-width-title']}</Text>
61+
<LineWidthSelect value={value} onChange={onChange} />
62+
</Flex>
63+
{numberInput}
3464
</Flex>
3565
);
3666
});

src/ui/units/wizard/components/Dialogs/DialogShapes/DialogShapes.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@
1515
justify-content: center;
1616
}
1717

18-
& .g-dialog-body {
18+
&_other-shapes .g-dialog-body {
1919
display: flex;
2020
padding: 0;
2121
overflow-y: auto;
2222
height: calc(80vh - 153px);
2323
border-top: 1px solid var(--g-color-line-generic);
2424
border-bottom: 1px solid var(--g-color-line-generic);
2525
}
26+
27+
&_lines-shapes .g-dialog-body {
28+
padding: 0;
29+
border-bottom: 1px solid var(--g-color-line-generic);
30+
}
2631
}

0 commit comments

Comments
 (0)