@true-engineering/true-react-common-ui-kit 3.32.0 → 3.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +15 -0
- package/dist/components/FlexibleTable/FlexibleTable.stories.d.ts +2 -0
- package/dist/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.d.ts +1 -1
- package/dist/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.d.ts +2 -1
- package/dist/components/SearchInput/SearchInput.stories.d.ts +1 -1
- package/dist/components/WithPopup/WithPopup.styles.d.ts +1 -1
- package/dist/components/WithPopup/types.d.ts +9 -3
- package/dist/true-react-common-ui-kit.js +144 -171
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +143 -170
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/dist/types.d.ts +7 -2
- package/package.json +98 -98
- package/src/components/AccountInfo/AccountInfo.stories.tsx +32 -32
- package/src/components/AccountInfo/AccountInfo.tsx +80 -80
- package/src/components/AddButton/AddButton.stories.tsx +21 -21
- package/src/components/AddButton/AddButton.tsx +52 -52
- package/src/components/Colors/Colors.stories.tsx +7 -7
- package/src/components/DateInput/DateInput.tsx +90 -90
- package/src/components/DateInput/constants.ts +2 -2
- package/src/components/Description/Description.stories.tsx +27 -27
- package/src/components/Description/Description.tsx +61 -61
- package/src/components/FiltersPane/components/FilterValueView/FilterValueView.tsx +166 -166
- package/src/components/FiltersPane/components/FilterWithDates/FilterWithDates.tsx +210 -210
- package/src/components/FiltersPane/components/FilterWithPeriod/FilterWithPeriod.tsx +177 -177
- package/src/components/FiltersPane/components/FilterWrapper/FilterWrapper.tsx +2 -2
- package/src/components/Flag/Flag.stories.tsx +29 -29
- package/src/components/Flag/Flag.tsx +26 -26
- package/src/components/Flag/augment.d.ts +1 -1
- package/src/components/FlexibleTable/FlexibleTable.stories.tsx +14 -1
- package/src/components/FlexibleTable/FlexibleTable.tsx +22 -10
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.styles.ts +39 -38
- package/src/components/FlexibleTable/components/FlexibleTableCell/FlexibleTableCell.tsx +4 -2
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.styles.ts +25 -25
- package/src/components/FlexibleTable/components/FlexibleTableRow/FlexibleTableRow.tsx +2 -1
- package/src/components/FlexibleTable/types.ts +70 -70
- package/src/components/Icon/Icon.stories.tsx +86 -86
- package/src/components/Icon/complexIcons/augment.d.ts +1 -1
- package/src/components/Icon/complexIcons/avatarGreen.svg +57 -57
- package/src/components/Icon/complexIcons/index.ts +1 -1
- package/src/components/Icon/icons-list.ts +855 -856
- package/src/components/IncrementInput/IncrementInput.tsx +105 -105
- package/src/components/Input/types.ts +32 -32
- package/src/components/List/List.tsx +3 -1
- package/src/components/Modal/Modal.stories.tsx +105 -105
- package/src/components/MultiSelect/MultiSelect.stories.tsx +46 -46
- package/src/components/MultiSelect/MultiSelect.tsx +106 -106
- package/src/components/MultiSelect/components/MultiSelectInput/MultiSelectInput.tsx +53 -53
- package/src/components/NewMoreMenu/NewMoreMenu.tsx +5 -5
- package/src/components/Notification/Notification.stories.tsx +55 -55
- package/src/components/Notification/Notification.styles.ts +57 -57
- package/src/components/Notification/Notification.tsx +77 -77
- package/src/components/Notification/types.ts +1 -1
- package/src/components/NumberInput/NumberInput.tsx +137 -137
- package/src/components/NumberInput/index.ts +1 -1
- package/src/components/PhoneInput/PhoneInput.tsx +214 -214
- package/src/components/PhoneInput/components/PhoneInputCountryList/PhoneInputCountryList.tsx +155 -155
- package/src/components/PhoneInput/types.ts +16 -16
- package/src/components/RadioButton/RadioButton.stories.tsx +46 -46
- package/src/components/RadioButton/RadioButton.tsx +57 -57
- package/src/components/ScrollIntoViewIfNeeded/index.ts +1 -1
- package/src/components/Select/Select.stories.tsx +235 -235
- package/src/components/Select/constants.ts +2 -2
- package/src/components/Select/types.ts +1 -1
- package/src/components/Selector/Selector.stories.tsx +62 -62
- package/src/components/Selector/Selector.tsx +115 -115
- package/src/components/Selector/index.ts +2 -2
- package/src/components/Selector/types.ts +12 -12
- package/src/components/Skeleton/Skeleton.stories.tsx +19 -19
- package/src/components/SmartInput/SmartInput.tsx +134 -134
- package/src/components/Status/Status.stories.tsx +73 -73
- package/src/components/Status/Status.styles.ts +143 -143
- package/src/components/Status/Status.tsx +49 -49
- package/src/components/Status/constants.ts +11 -11
- package/src/components/Status/index.ts +3 -3
- package/src/components/Status/types.ts +5 -5
- package/src/components/Switch/Switch.stories.tsx +40 -40
- package/src/components/Switch/Switch.tsx +75 -75
- package/src/components/TextWithInfo/TextWithInfo.stories.tsx +53 -53
- package/src/components/TextWithInfo/TextWithInfo.tsx +62 -62
- package/src/components/TextWithTooltip/TextWithTooltip.stories.tsx +58 -58
- package/src/components/ThemedPreloader/ThemedPreloader.stories.tsx +41 -41
- package/src/components/ThemedPreloader/ThemedPreloader.tsx +54 -54
- package/src/components/ThemedPreloader/components/DefaultPreloader/index.ts +1 -1
- package/src/components/Toaster/Toaster.stories.tsx +30 -30
- package/src/components/Tooltip/Tooltip.stories.tsx +19 -19
- package/src/components/Tooltip/Tooltip.tsx +35 -35
- package/src/components/Tooltip/types.ts +1 -1
- package/src/components/WithPopup/WithPopup.stories.tsx +3 -3
- package/src/components/WithPopup/WithPopup.styles.ts +2 -0
- package/src/components/WithPopup/WithPopup.tsx +18 -8
- package/src/components/WithPopup/types.ts +11 -3
- package/src/helpers/popper-helpers.ts +17 -17
- package/src/hooks/use-dropdown.ts +84 -84
- package/src/hooks/use-is-mounted.ts +15 -15
- package/src/theme/helpers.ts +76 -76
- package/src/types.ts +10 -2
- package/src/vite-env.d.ts +1 -1
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import { Status } from '.';
|
|
2
|
-
import { ComponentStory } from '@storybook/react';
|
|
3
|
-
import { IIconType, iconsList } from '../Icon';
|
|
4
|
-
import { complexIcons } from '../Icon/complexIcons';
|
|
5
|
-
import { STATUS_COLORS, STATUS_SIZES } from './constants';
|
|
6
|
-
import { IStatusStyles } from './Status.styles';
|
|
7
|
-
|
|
8
|
-
export default {
|
|
9
|
-
title: 'Data Display/Status',
|
|
10
|
-
component: Status,
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const iconTypes = [
|
|
14
|
-
undefined,
|
|
15
|
-
...Object.keys(iconsList),
|
|
16
|
-
...Object.keys(complexIcons),
|
|
17
|
-
] as IIconType[];
|
|
18
|
-
|
|
19
|
-
const customTweakStyles: IStatusStyles = {
|
|
20
|
-
custom: {
|
|
21
|
-
'--status-color': '#793472',
|
|
22
|
-
'--status-background': '#F2B9ED',
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const Template: ComponentStory<typeof Status> = (args) => (
|
|
27
|
-
<div
|
|
28
|
-
style={{
|
|
29
|
-
display: 'grid',
|
|
30
|
-
gridTemplateRows: `repeat(${STATUS_SIZES.length + 1}, 1fr)`,
|
|
31
|
-
gridTemplateColumns: `repeat(${STATUS_COLORS.length + 1}, 1fr)`,
|
|
32
|
-
gap: 20,
|
|
33
|
-
}}
|
|
34
|
-
>
|
|
35
|
-
<div key={0} style={{ display: 'contents' }}>
|
|
36
|
-
<div />
|
|
37
|
-
{STATUS_COLORS.map((color, j) => (
|
|
38
|
-
<div key={j + 1}>{color}</div>
|
|
39
|
-
))}
|
|
40
|
-
</div>
|
|
41
|
-
|
|
42
|
-
{STATUS_SIZES.map((size, i) => (
|
|
43
|
-
<div key={i + 1} style={{ display: 'contents' }}>
|
|
44
|
-
<div>{size}</div>
|
|
45
|
-
{STATUS_COLORS.map((color, j) => (
|
|
46
|
-
<div key={j + 1}>
|
|
47
|
-
<Status {...args} size={size} color={color} tweakStyles={customTweakStyles} />
|
|
48
|
-
</div>
|
|
49
|
-
))}
|
|
50
|
-
</div>
|
|
51
|
-
))}
|
|
52
|
-
</div>
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
export const Default = Template.bind({});
|
|
56
|
-
|
|
57
|
-
Default.args = {
|
|
58
|
-
children: 'Status',
|
|
59
|
-
badge: '+ Badge',
|
|
60
|
-
icon: 'balloon',
|
|
61
|
-
iconPosition: 'left',
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
Default.argTypes = {
|
|
65
|
-
icon: { options: iconTypes, control: 'select' },
|
|
66
|
-
iconPosition: { options: ['left', 'right'], control: 'inline-radio' },
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
Default.parameters = {
|
|
70
|
-
controls: {
|
|
71
|
-
exclude: ['size', 'color', 'tweakStyles', 'testId', 'data'],
|
|
72
|
-
},
|
|
73
|
-
};
|
|
1
|
+
import { Status } from '.';
|
|
2
|
+
import { ComponentStory } from '@storybook/react';
|
|
3
|
+
import { IIconType, iconsList } from '../Icon';
|
|
4
|
+
import { complexIcons } from '../Icon/complexIcons';
|
|
5
|
+
import { STATUS_COLORS, STATUS_SIZES } from './constants';
|
|
6
|
+
import { IStatusStyles } from './Status.styles';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Data Display/Status',
|
|
10
|
+
component: Status,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const iconTypes = [
|
|
14
|
+
undefined,
|
|
15
|
+
...Object.keys(iconsList),
|
|
16
|
+
...Object.keys(complexIcons),
|
|
17
|
+
] as IIconType[];
|
|
18
|
+
|
|
19
|
+
const customTweakStyles: IStatusStyles = {
|
|
20
|
+
custom: {
|
|
21
|
+
'--status-color': '#793472',
|
|
22
|
+
'--status-background': '#F2B9ED',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const Template: ComponentStory<typeof Status> = (args) => (
|
|
27
|
+
<div
|
|
28
|
+
style={{
|
|
29
|
+
display: 'grid',
|
|
30
|
+
gridTemplateRows: `repeat(${STATUS_SIZES.length + 1}, 1fr)`,
|
|
31
|
+
gridTemplateColumns: `repeat(${STATUS_COLORS.length + 1}, 1fr)`,
|
|
32
|
+
gap: 20,
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
<div key={0} style={{ display: 'contents' }}>
|
|
36
|
+
<div />
|
|
37
|
+
{STATUS_COLORS.map((color, j) => (
|
|
38
|
+
<div key={j + 1}>{color}</div>
|
|
39
|
+
))}
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
{STATUS_SIZES.map((size, i) => (
|
|
43
|
+
<div key={i + 1} style={{ display: 'contents' }}>
|
|
44
|
+
<div>{size}</div>
|
|
45
|
+
{STATUS_COLORS.map((color, j) => (
|
|
46
|
+
<div key={j + 1}>
|
|
47
|
+
<Status {...args} size={size} color={color} tweakStyles={customTweakStyles} />
|
|
48
|
+
</div>
|
|
49
|
+
))}
|
|
50
|
+
</div>
|
|
51
|
+
))}
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
export const Default = Template.bind({});
|
|
56
|
+
|
|
57
|
+
Default.args = {
|
|
58
|
+
children: 'Status',
|
|
59
|
+
badge: '+ Badge',
|
|
60
|
+
icon: 'balloon',
|
|
61
|
+
iconPosition: 'left',
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
Default.argTypes = {
|
|
65
|
+
icon: { options: iconTypes, control: 'select' },
|
|
66
|
+
iconPosition: { options: ['left', 'right'], control: 'inline-radio' },
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
Default.parameters = {
|
|
70
|
+
controls: {
|
|
71
|
+
exclude: ['size', 'color', 'tweakStyles', 'testId', 'data'],
|
|
72
|
+
},
|
|
73
|
+
};
|
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
import { rgba } from '../../helpers';
|
|
2
|
-
import { colors, createThemedStyles, ITweakStyles } from '../../theme';
|
|
3
|
-
|
|
4
|
-
export const useStyles = createThemedStyles('Status', {
|
|
5
|
-
root: {
|
|
6
|
-
display: 'inline-flex',
|
|
7
|
-
verticalAlign: 'middle',
|
|
8
|
-
color: 'var(--status-color)',
|
|
9
|
-
backgroundColor: 'var(--status-background)',
|
|
10
|
-
width: 'max-content',
|
|
11
|
-
alignItems: 'center',
|
|
12
|
-
|
|
13
|
-
'& > *': {
|
|
14
|
-
flexShrink: 0,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
icon: {
|
|
19
|
-
'& > div': {
|
|
20
|
-
display: 'inline-block',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
iconLeft: {
|
|
25
|
-
order: -1,
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
text: {},
|
|
29
|
-
|
|
30
|
-
badge: {
|
|
31
|
-
color: colors.CLASSIC_WHITE,
|
|
32
|
-
backgroundColor: 'var(--status-color)',
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
xs: {
|
|
36
|
-
padding: [2, 4],
|
|
37
|
-
gap: 4,
|
|
38
|
-
borderRadius: 2,
|
|
39
|
-
|
|
40
|
-
fontSize: 12,
|
|
41
|
-
lineHeight: '16px',
|
|
42
|
-
letterSpacing: 0.24,
|
|
43
|
-
fontWeight: 'bold',
|
|
44
|
-
|
|
45
|
-
'& $icon': {
|
|
46
|
-
width: 16,
|
|
47
|
-
height: 16,
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
'& $badge': {
|
|
51
|
-
padding: [0, 2],
|
|
52
|
-
marginRight: -1,
|
|
53
|
-
borderRadius: 4,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
s: {
|
|
58
|
-
padding: [3, 8, 5, 8],
|
|
59
|
-
gap: 4,
|
|
60
|
-
borderRadius: 6,
|
|
61
|
-
|
|
62
|
-
fontSize: 13,
|
|
63
|
-
lineHeight: '16px',
|
|
64
|
-
letterSpacing: 0.2,
|
|
65
|
-
fontWeight: 'bold',
|
|
66
|
-
|
|
67
|
-
'& $text': {},
|
|
68
|
-
|
|
69
|
-
'& $icon': {
|
|
70
|
-
width: 16,
|
|
71
|
-
height: 16,
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
'& $badge': {
|
|
75
|
-
padding: [0, 4, 2, 4],
|
|
76
|
-
margin: [0, -4, -2, 0],
|
|
77
|
-
borderRadius: 4,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
m: {
|
|
82
|
-
padding: [7, 12],
|
|
83
|
-
gap: 4,
|
|
84
|
-
borderRadius: 6,
|
|
85
|
-
|
|
86
|
-
fontSize: 15,
|
|
87
|
-
lineHeight: '18px',
|
|
88
|
-
letterSpacing: 0.15,
|
|
89
|
-
fontWeight: 'bold',
|
|
90
|
-
|
|
91
|
-
'& $text': {},
|
|
92
|
-
|
|
93
|
-
'& $icon': {
|
|
94
|
-
width: 18,
|
|
95
|
-
height: 18,
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
'& $badge': {
|
|
99
|
-
padding: [2, 4],
|
|
100
|
-
margin: [-2, -7, -2, 0],
|
|
101
|
-
borderRadius: 4,
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
green: {
|
|
106
|
-
'--status-background': rgba('#D4E3AC', 0.5),
|
|
107
|
-
'--status-color': '#6F990F',
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
blue: {
|
|
111
|
-
'--status-background': rgba('#AABFFC', 0.4),
|
|
112
|
-
'--status-color': '#4C6EBF',
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
grey: {
|
|
116
|
-
'--status-background': rgba('#95A0B3', 0.25),
|
|
117
|
-
'--status-color': '#7A869A',
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
orange: {
|
|
121
|
-
'--status-background': rgba('#FCD3A9', 0.5),
|
|
122
|
-
'--status-color': '#E5741C',
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
red: {
|
|
126
|
-
'--status-background': rgba('#F7949A', 0.25),
|
|
127
|
-
'--status-color': '#F14D56',
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
teal: {
|
|
131
|
-
'--status-background': rgba('#8CE3EA', 0.4),
|
|
132
|
-
'--status-color': '#0092A6',
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
violet: {
|
|
136
|
-
'--status-background': rgba('#BEABE0', 0.4),
|
|
137
|
-
'--status-color': '#7450B2',
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
custom: {},
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
export type IStatusStyles = ITweakStyles<typeof useStyles>;
|
|
1
|
+
import { rgba } from '../../helpers';
|
|
2
|
+
import { colors, createThemedStyles, ITweakStyles } from '../../theme';
|
|
3
|
+
|
|
4
|
+
export const useStyles = createThemedStyles('Status', {
|
|
5
|
+
root: {
|
|
6
|
+
display: 'inline-flex',
|
|
7
|
+
verticalAlign: 'middle',
|
|
8
|
+
color: 'var(--status-color)',
|
|
9
|
+
backgroundColor: 'var(--status-background)',
|
|
10
|
+
width: 'max-content',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
|
|
13
|
+
'& > *': {
|
|
14
|
+
flexShrink: 0,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
icon: {
|
|
19
|
+
'& > div': {
|
|
20
|
+
display: 'inline-block',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
iconLeft: {
|
|
25
|
+
order: -1,
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
text: {},
|
|
29
|
+
|
|
30
|
+
badge: {
|
|
31
|
+
color: colors.CLASSIC_WHITE,
|
|
32
|
+
backgroundColor: 'var(--status-color)',
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
xs: {
|
|
36
|
+
padding: [2, 4],
|
|
37
|
+
gap: 4,
|
|
38
|
+
borderRadius: 2,
|
|
39
|
+
|
|
40
|
+
fontSize: 12,
|
|
41
|
+
lineHeight: '16px',
|
|
42
|
+
letterSpacing: 0.24,
|
|
43
|
+
fontWeight: 'bold',
|
|
44
|
+
|
|
45
|
+
'& $icon': {
|
|
46
|
+
width: 16,
|
|
47
|
+
height: 16,
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
'& $badge': {
|
|
51
|
+
padding: [0, 2],
|
|
52
|
+
marginRight: -1,
|
|
53
|
+
borderRadius: 4,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
s: {
|
|
58
|
+
padding: [3, 8, 5, 8],
|
|
59
|
+
gap: 4,
|
|
60
|
+
borderRadius: 6,
|
|
61
|
+
|
|
62
|
+
fontSize: 13,
|
|
63
|
+
lineHeight: '16px',
|
|
64
|
+
letterSpacing: 0.2,
|
|
65
|
+
fontWeight: 'bold',
|
|
66
|
+
|
|
67
|
+
'& $text': {},
|
|
68
|
+
|
|
69
|
+
'& $icon': {
|
|
70
|
+
width: 16,
|
|
71
|
+
height: 16,
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
'& $badge': {
|
|
75
|
+
padding: [0, 4, 2, 4],
|
|
76
|
+
margin: [0, -4, -2, 0],
|
|
77
|
+
borderRadius: 4,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
m: {
|
|
82
|
+
padding: [7, 12],
|
|
83
|
+
gap: 4,
|
|
84
|
+
borderRadius: 6,
|
|
85
|
+
|
|
86
|
+
fontSize: 15,
|
|
87
|
+
lineHeight: '18px',
|
|
88
|
+
letterSpacing: 0.15,
|
|
89
|
+
fontWeight: 'bold',
|
|
90
|
+
|
|
91
|
+
'& $text': {},
|
|
92
|
+
|
|
93
|
+
'& $icon': {
|
|
94
|
+
width: 18,
|
|
95
|
+
height: 18,
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
'& $badge': {
|
|
99
|
+
padding: [2, 4],
|
|
100
|
+
margin: [-2, -7, -2, 0],
|
|
101
|
+
borderRadius: 4,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
green: {
|
|
106
|
+
'--status-background': rgba('#D4E3AC', 0.5),
|
|
107
|
+
'--status-color': '#6F990F',
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
blue: {
|
|
111
|
+
'--status-background': rgba('#AABFFC', 0.4),
|
|
112
|
+
'--status-color': '#4C6EBF',
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
grey: {
|
|
116
|
+
'--status-background': rgba('#95A0B3', 0.25),
|
|
117
|
+
'--status-color': '#7A869A',
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
orange: {
|
|
121
|
+
'--status-background': rgba('#FCD3A9', 0.5),
|
|
122
|
+
'--status-color': '#E5741C',
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
red: {
|
|
126
|
+
'--status-background': rgba('#F7949A', 0.25),
|
|
127
|
+
'--status-color': '#F14D56',
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
teal: {
|
|
131
|
+
'--status-background': rgba('#8CE3EA', 0.4),
|
|
132
|
+
'--status-color': '#0092A6',
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
violet: {
|
|
136
|
+
'--status-background': rgba('#BEABE0', 0.4),
|
|
137
|
+
'--status-color': '#7450B2',
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
custom: {},
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
export type IStatusStyles = ITweakStyles<typeof useStyles>;
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { FC, ReactNode } from 'react';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import { addDataTestId, isReactNodeNotEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
4
|
-
import { addDataAttributes } from '../../helpers';
|
|
5
|
-
import { ICommonProps } from '../../types';
|
|
6
|
-
import { IIcon, renderIcon } from '../Icon';
|
|
7
|
-
import { IStatusColor, IStatusSize } from './types';
|
|
8
|
-
import { useStyles, IStatusStyles } from './Status.styles';
|
|
9
|
-
|
|
10
|
-
export interface IStatusProps extends ICommonProps<IStatusStyles> {
|
|
11
|
-
children: ReactNode;
|
|
12
|
-
color: IStatusColor;
|
|
13
|
-
icon?: IIcon;
|
|
14
|
-
/** @default 's' */
|
|
15
|
-
size?: IStatusSize;
|
|
16
|
-
/** @default 'right' */
|
|
17
|
-
iconPosition?: 'left' | 'right';
|
|
18
|
-
badge?: ReactNode;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const Status: FC<IStatusProps> = ({
|
|
22
|
-
children,
|
|
23
|
-
color,
|
|
24
|
-
size = 's',
|
|
25
|
-
icon,
|
|
26
|
-
iconPosition = 'right',
|
|
27
|
-
badge,
|
|
28
|
-
tweakStyles,
|
|
29
|
-
testId,
|
|
30
|
-
data,
|
|
31
|
-
}) => {
|
|
32
|
-
const classes = useStyles({ theme: tweakStyles });
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<span
|
|
36
|
-
className={clsx(classes.root, classes[size], classes[color])}
|
|
37
|
-
{...addDataTestId(testId)}
|
|
38
|
-
{...addDataAttributes(data)}
|
|
39
|
-
>
|
|
40
|
-
{isReactNodeNotEmpty(children) && <span className={classes.text}>{children}</span>}
|
|
41
|
-
{isReactNodeNotEmpty(icon) && (
|
|
42
|
-
<span className={clsx(classes.icon, iconPosition === 'left' && classes.iconLeft)}>
|
|
43
|
-
{renderIcon(icon)}
|
|
44
|
-
</span>
|
|
45
|
-
)}
|
|
46
|
-
{isReactNodeNotEmpty(badge) && <span className={classes.badge}>{badge}</span>}
|
|
47
|
-
</span>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { addDataTestId, isReactNodeNotEmpty } from '@true-engineering/true-react-platform-helpers';
|
|
4
|
+
import { addDataAttributes } from '../../helpers';
|
|
5
|
+
import { ICommonProps } from '../../types';
|
|
6
|
+
import { IIcon, renderIcon } from '../Icon';
|
|
7
|
+
import { IStatusColor, IStatusSize } from './types';
|
|
8
|
+
import { useStyles, IStatusStyles } from './Status.styles';
|
|
9
|
+
|
|
10
|
+
export interface IStatusProps extends ICommonProps<IStatusStyles> {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
color: IStatusColor;
|
|
13
|
+
icon?: IIcon;
|
|
14
|
+
/** @default 's' */
|
|
15
|
+
size?: IStatusSize;
|
|
16
|
+
/** @default 'right' */
|
|
17
|
+
iconPosition?: 'left' | 'right';
|
|
18
|
+
badge?: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const Status: FC<IStatusProps> = ({
|
|
22
|
+
children,
|
|
23
|
+
color,
|
|
24
|
+
size = 's',
|
|
25
|
+
icon,
|
|
26
|
+
iconPosition = 'right',
|
|
27
|
+
badge,
|
|
28
|
+
tweakStyles,
|
|
29
|
+
testId,
|
|
30
|
+
data,
|
|
31
|
+
}) => {
|
|
32
|
+
const classes = useStyles({ theme: tweakStyles });
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<span
|
|
36
|
+
className={clsx(classes.root, classes[size], classes[color])}
|
|
37
|
+
{...addDataTestId(testId)}
|
|
38
|
+
{...addDataAttributes(data)}
|
|
39
|
+
>
|
|
40
|
+
{isReactNodeNotEmpty(children) && <span className={classes.text}>{children}</span>}
|
|
41
|
+
{isReactNodeNotEmpty(icon) && (
|
|
42
|
+
<span className={clsx(classes.icon, iconPosition === 'left' && classes.iconLeft)}>
|
|
43
|
+
{renderIcon(icon)}
|
|
44
|
+
</span>
|
|
45
|
+
)}
|
|
46
|
+
{isReactNodeNotEmpty(badge) && <span className={classes.badge}>{badge}</span>}
|
|
47
|
+
</span>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export const STATUS_COLORS = [
|
|
2
|
-
'green',
|
|
3
|
-
'teal',
|
|
4
|
-
'blue',
|
|
5
|
-
'grey',
|
|
6
|
-
'orange',
|
|
7
|
-
'red',
|
|
8
|
-
'violet',
|
|
9
|
-
'custom',
|
|
10
|
-
] as const;
|
|
11
|
-
export const STATUS_SIZES = ['xs', 's', 'm'] as const;
|
|
1
|
+
export const STATUS_COLORS = [
|
|
2
|
+
'green',
|
|
3
|
+
'teal',
|
|
4
|
+
'blue',
|
|
5
|
+
'grey',
|
|
6
|
+
'orange',
|
|
7
|
+
'red',
|
|
8
|
+
'violet',
|
|
9
|
+
'custom',
|
|
10
|
+
] as const;
|
|
11
|
+
export const STATUS_SIZES = ['xs', 's', 'm'] as const;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './Status';
|
|
2
|
-
|
|
3
|
-
export type { IStatusStyles } from './Status.styles';
|
|
1
|
+
export * from './Status';
|
|
2
|
+
|
|
3
|
+
export type { IStatusStyles } from './Status.styles';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { STATUS_COLORS, STATUS_SIZES } from './constants';
|
|
2
|
-
|
|
3
|
-
export type IStatusColor = (typeof STATUS_COLORS)[number];
|
|
4
|
-
|
|
5
|
-
export type IStatusSize = (typeof STATUS_SIZES)[number];
|
|
1
|
+
import { STATUS_COLORS, STATUS_SIZES } from './constants';
|
|
2
|
+
|
|
3
|
+
export type IStatusColor = (typeof STATUS_COLORS)[number];
|
|
4
|
+
|
|
5
|
+
export type IStatusSize = (typeof STATUS_SIZES)[number];
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { ComponentStory } from '@storybook/react';
|
|
3
|
-
import { Switch } from './Switch';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Controls/Switch',
|
|
7
|
-
component: Switch,
|
|
8
|
-
argTypes: {
|
|
9
|
-
labelPosition: { control: 'inline-radio', options: ['left', 'right'] },
|
|
10
|
-
color: { control: 'inline-radio', options: ['primary', 'secondary'] },
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const Template: ComponentStory<typeof Switch> = (args) => {
|
|
15
|
-
const [isChecked, setIsChecked] = useState(true);
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<Switch
|
|
19
|
-
{...args}
|
|
20
|
-
isChecked={isChecked}
|
|
21
|
-
onChange={(value) => setIsChecked(value.isEnabled)}
|
|
22
|
-
value="check"
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const Default = Template.bind({});
|
|
28
|
-
|
|
29
|
-
Default.args = {
|
|
30
|
-
children: 'Label',
|
|
31
|
-
labelPosition: 'right',
|
|
32
|
-
isDisabled: false,
|
|
33
|
-
color: 'primary',
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
Default.parameters = {
|
|
37
|
-
controls: {
|
|
38
|
-
exclude: ['data', 'testId', 'onChange'],
|
|
39
|
-
},
|
|
40
|
-
};
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { ComponentStory } from '@storybook/react';
|
|
3
|
+
import { Switch } from './Switch';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Controls/Switch',
|
|
7
|
+
component: Switch,
|
|
8
|
+
argTypes: {
|
|
9
|
+
labelPosition: { control: 'inline-radio', options: ['left', 'right'] },
|
|
10
|
+
color: { control: 'inline-radio', options: ['primary', 'secondary'] },
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const Template: ComponentStory<typeof Switch> = (args) => {
|
|
15
|
+
const [isChecked, setIsChecked] = useState(true);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Switch
|
|
19
|
+
{...args}
|
|
20
|
+
isChecked={isChecked}
|
|
21
|
+
onChange={(value) => setIsChecked(value.isEnabled)}
|
|
22
|
+
value="check"
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const Default = Template.bind({});
|
|
28
|
+
|
|
29
|
+
Default.args = {
|
|
30
|
+
children: 'Label',
|
|
31
|
+
labelPosition: 'right',
|
|
32
|
+
isDisabled: false,
|
|
33
|
+
color: 'primary',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
Default.parameters = {
|
|
37
|
+
controls: {
|
|
38
|
+
exclude: ['data', 'testId', 'onChange'],
|
|
39
|
+
},
|
|
40
|
+
};
|