@itcase/ui 1.8.38 → 1.8.40
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/dist/{Avatar_cjs_nMPCDjk8.js → Avatar_cjs_BbeDJ-No.js} +2 -2
- package/dist/{Avatar_es_B73a6TzA.js → Avatar_es_B1Ao9Im_.js} +2 -2
- package/dist/{Button_cjs_plv5-qcj.js → Button_cjs_Ctkyt2ES.js} +1 -1
- package/dist/{Button_es_BigB2Wz6.js → Button_es_BiIuX0ER.js} +1 -1
- package/dist/{ChipsGroup_cjs_DrOhD-Fc.js → ChipsGroup_cjs_p99H-9a8.js} +48 -64
- package/dist/{ChipsGroup_es_B9m4l0wN.js → ChipsGroup_es_CWq3TR_1.js} +48 -64
- package/dist/{DatePicker_cjs_DKoF73mp.js → DatePicker_cjs_D_1v2mS0.js} +3 -3
- package/dist/{DatePicker_es_CdEYxtwj.js → DatePicker_es_CQwbdG0g.js} +3 -3
- package/dist/{DropdownItem_cjs_DQvByLbN.js → DropdownItem_cjs_B1gGciTB.js} +26 -9
- package/dist/{DropdownItem_es_KppIfto7.js → DropdownItem_es_JVT4f6Nb.js} +26 -9
- package/dist/{Image_cjs_CCWqbNn4.js → Image_cjs_2zEjohYE.js} +5 -4
- package/dist/{Image_es_DZUVp0FS.js → Image_es_ChF-63wh.js} +5 -4
- package/dist/{Label_cjs_BGJfyrOL.js → Label_cjs_Mb8j2bLu.js} +1 -5
- package/dist/{Label_es_C4Px7b-N.js → Label_es_CIDBUVgO.js} +1 -5
- package/dist/{Tooltip_cjs_DHduWa-v.js → Tooltip_cjs_BBwH8sjA.js} +16 -6
- package/dist/{Tooltip_es_ltCY-w4M.js → Tooltip_es_Y2aoFQW7.js} +16 -6
- package/dist/cjs/components/Accordion.js +3 -1
- package/dist/cjs/components/Avatar.js +5 -3
- package/dist/cjs/components/AvatarStack.js +5 -3
- package/dist/cjs/components/Badge.js +3 -1
- package/dist/cjs/components/Breadcrumbs.js +3 -1
- package/dist/cjs/components/Button.js +4 -2
- package/dist/cjs/components/Cell.js +4 -2
- package/dist/cjs/components/Chips.js +5 -2
- package/dist/cjs/components/Choice.js +3 -1
- package/dist/cjs/components/CookiesWarning.js +4 -2
- package/dist/cjs/components/DatePeriod.js +8 -5
- package/dist/cjs/components/DatePicker.js +6 -4
- package/dist/cjs/components/Drawer.js +3 -1
- package/dist/cjs/components/Dropdown/stories/__mock__.js +27 -4
- package/dist/cjs/components/Dropdown.js +5 -3
- package/dist/cjs/components/HeroTitle.js +3 -1
- package/dist/cjs/components/Icon.js +3 -1
- package/dist/cjs/components/Image.js +5 -3
- package/dist/cjs/components/InputPassword.js +3 -1
- package/dist/cjs/components/Label.js +4 -2
- package/dist/cjs/components/Logo.js +7 -5
- package/dist/cjs/components/MenuItem.js +3 -1
- package/dist/cjs/components/Modal.js +3 -1
- package/dist/cjs/components/Notification.js +3 -1
- package/dist/cjs/components/Pagination.js +68 -21
- package/dist/cjs/components/Radio.js +45 -65
- package/dist/cjs/components/Response.js +8 -5
- package/dist/cjs/components/SVGContent.js +5 -3
- package/dist/cjs/components/Search.js +3 -1
- package/dist/cjs/components/Segmented.js +3 -1
- package/dist/cjs/components/Select.js +5 -3
- package/dist/cjs/components/Swiper.js +3 -1
- package/dist/cjs/components/Tab.js +3 -1
- package/dist/cjs/components/Textarea.js +1 -1
- package/dist/cjs/components/Tile.js +3 -1
- package/dist/cjs/components/Title.js +3 -1
- package/dist/cjs/components/Tooltip.js +3 -1
- package/dist/cjs/context/UrlAssetPrefix.js +17 -0
- package/dist/cjs/hoc/urlWithAssetPrefix.js +64 -0
- package/dist/cjs/hooks/useAppearanceConfig/useAppearanceConfig.js +29 -0
- package/dist/cjs/hooks/useAppearanceConfig.js +9 -0
- package/dist/components/Accordion.js +3 -1
- package/dist/components/Avatar.js +5 -3
- package/dist/components/AvatarStack.js +5 -3
- package/dist/components/Badge.js +3 -1
- package/dist/components/Breadcrumbs.js +3 -1
- package/dist/components/Button.js +4 -2
- package/dist/components/Cell.js +4 -2
- package/dist/components/Chips.js +5 -2
- package/dist/components/Choice.js +3 -1
- package/dist/components/CookiesWarning.js +4 -2
- package/dist/components/DatePeriod.js +8 -5
- package/dist/components/DatePicker.js +6 -4
- package/dist/components/Drawer.js +3 -1
- package/dist/components/Dropdown/stories/__mock__.js +26 -5
- package/dist/components/Dropdown.js +5 -3
- package/dist/components/HeroTitle.js +3 -1
- package/dist/components/Icon.js +3 -1
- package/dist/components/Image.js +5 -3
- package/dist/components/InputPassword.js +3 -1
- package/dist/components/Label.js +4 -2
- package/dist/components/Logo.js +7 -5
- package/dist/components/MenuItem.js +3 -1
- package/dist/components/Modal.js +3 -1
- package/dist/components/Notification.js +3 -1
- package/dist/components/Pagination.js +69 -22
- package/dist/components/Radio.js +45 -65
- package/dist/components/Response.js +8 -5
- package/dist/components/SVGContent.js +5 -3
- package/dist/components/Search.js +3 -1
- package/dist/components/Segmented.js +3 -1
- package/dist/components/Select.js +5 -3
- package/dist/components/Swiper.js +3 -1
- package/dist/components/Tab.js +3 -1
- package/dist/components/Textarea.js +1 -1
- package/dist/components/Tile.js +3 -1
- package/dist/components/Title.js +3 -1
- package/dist/components/Tooltip.js +3 -1
- package/dist/context/UrlAssetPrefix.js +14 -0
- package/dist/css/components/Dropdown/Dropdown.css +24 -0
- package/dist/css/components/Pagination/Pagination.css +82 -30
- package/dist/css/components/Pagination/css/__item/pagination__item.css +8 -8
- package/dist/css/components/Pagination/css/__item/pagination__item_size.css +8 -0
- package/dist/css/components/Pagination/css/__item/pagination__item_state_active.css +16 -16
- package/dist/css/components/Radio/Radio.css +44 -5
- package/dist/css/components/Select/Select.css +1 -0
- package/dist/css/components/Select/css/__indicators/select__indicators.css +1 -0
- package/dist/css/components/Swiper/Swiper.css +2 -2
- package/dist/css/styles/fill/fill.css +2 -1
- package/dist/css/styles/fill/fill_active.css +3 -0
- package/dist/css/styles/fill/fill_active_hover.css +7 -0
- package/dist/css/styles/fill/fill_hover.css +5 -9
- package/dist/hoc/urlWithAssetPrefix.js +62 -0
- package/dist/hooks/useAppearanceConfig/useAppearanceConfig.js +27 -0
- package/dist/hooks/useAppearanceConfig.js +3 -0
- package/dist/stories/ChipsOverview.mdx +10 -10
- package/dist/stories/ChipsPlayground.mdx +2 -2
- package/dist/stories/Components.mdx +378 -87
- package/dist/stories/useAppearanceConfig.mdx +83 -0
- package/dist/stories/useDevicePropsGenerator.mdx +6 -8
- package/dist/types/components/Chips/appearance/chipsDisabled.d.ts +2 -3
- package/dist/types/components/Dropdown/appearance/dropdownAccent.d.ts +5 -0
- package/dist/types/components/Dropdown/appearance/dropdownSize.d.ts +9 -0
- package/dist/types/components/Dropdown/appearance/dropdownSurface.d.ts +3 -0
- package/dist/types/components/Dropdown/stories/__mock__/index.d.ts +9 -12
- package/dist/types/components/Icon/Icon.d.ts +6 -2
- package/dist/types/components/Icon/appearance/iconDanger.d.ts +1 -0
- package/dist/types/components/Icon/appearance/iconDisabled.d.ts +1 -0
- package/dist/types/components/Icon/appearance/iconError.d.ts +1 -0
- package/dist/types/components/Icon/appearance/iconInfo.d.ts +0 -1
- package/dist/types/components/Icon/appearance/iconPrimary.d.ts +1 -0
- package/dist/types/components/Icon/appearance/iconSecondary.d.ts +1 -0
- package/dist/types/components/Icon/appearance/iconSuccess.d.ts +1 -0
- package/dist/types/components/Icon/appearance/iconSurface.d.ts +1 -0
- package/dist/types/components/Icon/appearance/iconWarning.d.ts +1 -0
- package/dist/types/components/Image/Image.d.ts +5 -2
- package/dist/types/components/Label/appearance/labelError.d.ts +0 -1
- package/dist/types/components/Label/appearance/labelGradient.d.ts +8 -0
- package/dist/types/components/Label/appearance/labelPrimary.d.ts +0 -1
- package/dist/types/components/Label/appearance/labelSuccess.d.ts +0 -1
- package/dist/types/components/Label/appearance/labelSurface.d.ts +0 -1
- package/dist/types/components/Logo/Logo.d.ts +6 -2
- package/dist/types/components/Pagination/appearance/paginationAccent.d.ts +22 -1
- package/dist/types/components/Pagination/appearance/paginationSize.d.ts +20 -1
- package/dist/types/components/Pagination/appearance/paginationSurface.d.ts +4 -1
- package/dist/types/components/Radio/Radio.appearance.d.ts +28 -48
- package/dist/types/components/Radio/appearance/radioDefault.d.ts +2 -14
- package/dist/types/components/Radio/appearance/radioDisabled.d.ts +5 -5
- package/dist/types/components/Radio/appearance/radioError.d.ts +6 -5
- package/dist/types/components/Radio/appearance/radioRequire.d.ts +5 -13
- package/dist/types/components/Radio/appearance/radioStyle.d.ts +4 -6
- package/dist/types/components/Radio/appearance/radioSuccess.d.ts +6 -5
- package/dist/types/components/Response/Response.d.ts +6 -2
- package/dist/types/components/Response/Response.interface.d.ts +3 -1
- package/dist/types/components/SVGContent/SVGContent.d.ts +5 -2
- package/dist/types/components/Select/SelectLoadingIndicator.d.ts +2 -1
- package/dist/types/config/forms/datepicker.d.ts +18 -0
- package/dist/types/config/forms/index.d.ts +3 -0
- package/dist/types/config/forms/input.d.ts +14 -0
- package/dist/types/context/UrlAssetPrefix.d.ts +12 -0
- package/dist/types/hoc/urlWithAssetPrefix.d.ts +8 -0
- package/dist/types/hooks/useAppearanceConfig/index.d.ts +1 -0
- package/dist/types/hooks/useAppearanceConfig/useAppearanceConfig.d.ts +7 -0
- package/dist/types/hooks/useDevicePropsGenerator/index.d.ts +1 -0
- package/package.json +22 -17
- package/dist/types/hooks/useDeviceTargetClass.d.ts +0 -5
|
@@ -11,15 +11,40 @@ import { Meta } from '@storybook/blocks'
|
|
|
11
11
|
|
|
12
12
|
```js
|
|
13
13
|
/ComponentName/
|
|
14
|
-
├─
|
|
15
|
-
│
|
|
16
|
-
|
|
14
|
+
├─ docs // 👈 mdx файл с документаций компонента
|
|
15
|
+
│ ├─ Overview.mdx // 👈 базовая информация о компоненте
|
|
16
|
+
│ └─ Platground.mdx // 👈 песочница компонента
|
|
17
|
+
├─ css
|
|
17
18
|
│ └─ componentName.css
|
|
18
|
-
├─
|
|
19
|
-
│ ├─
|
|
20
|
-
│
|
|
21
|
-
├─
|
|
22
|
-
│ └─
|
|
19
|
+
├─ appearance // 👈 настройки appearance
|
|
20
|
+
│ ├─ componentDefault.ts // 👈 содержит `appearance` для цветов компонента, вместо `Default` может быть любой цвет
|
|
21
|
+
│ ├─ componentSize.ts // 👈 содержит appearance для size компонента
|
|
22
|
+
│ ├─ componentStyle.ts // 👈 содержит appearance для style компонента
|
|
23
|
+
│ └─ index.ts // 👈 файловый сборщик
|
|
24
|
+
├─ stories
|
|
25
|
+
│ ├─ __mock__ // 👈 мок данные
|
|
26
|
+
│ │ └─ index.ts
|
|
27
|
+
│ ├─ ComponentDemo.stories.tsx
|
|
28
|
+
│ │ ├─ Demo // 👈 это демонстрация компонента
|
|
29
|
+
│ │ └─ Skeleton // 👈 показывает временные контуры компонента, когда загружается страница
|
|
30
|
+
│ ├─ ComponentDefault.stories.tsx
|
|
31
|
+
│ │ ├─ Accent // 👈 цвет из figma
|
|
32
|
+
│ │ ├─ Error // 👈 цвет из figma
|
|
33
|
+
│ │ ├─ Warning // 👈 цвет из figma
|
|
34
|
+
│ │ └─ Surface // и т.д.
|
|
35
|
+
│ ├─ ComponentStyle.stories.tsx
|
|
36
|
+
│ │ ├─ Solid // 👈 состояние, когда есть задний фон, но нет рамки
|
|
37
|
+
│ │ ├─ Outlined // 👈 состояние, когда нет заднего фона, но есть рамка
|
|
38
|
+
│ │ ├─ Full // 👈 состояние, когда есть и задний фон и рамка
|
|
39
|
+
│ │ └─ Ghost // 👈 состояние, когда нет ни заднего фона, ни рамки
|
|
40
|
+
│ └─ ComponentSize.stories.tsx
|
|
41
|
+
│ ├─ SizeXXL // 👈 размер из figma
|
|
42
|
+
│ ├─ SizeXL // 👈 размер из figma
|
|
43
|
+
│ ├─ SizeL // 👈 размер из figma
|
|
44
|
+
│ ├─ SizeM // 👈 размер из figma
|
|
45
|
+
│ ├─ SizeS // 👈 размер из figma
|
|
46
|
+
│ ├─ SizeXS // 👈 размер из figma
|
|
47
|
+
│ └─ SizeXXS // 👈 размер из figma
|
|
23
48
|
├─ ComponentName.appearance.ts // 👈 импорт appearance
|
|
24
49
|
├─ ComponentName.css // 👈 импорт css файлов
|
|
25
50
|
├─ ComponentName.interface.ts // 👈 типы
|
|
@@ -28,73 +53,66 @@ import { Meta } from '@storybook/blocks'
|
|
|
28
53
|
└─ index.ts
|
|
29
54
|
```
|
|
30
55
|
|
|
31
|
-
|
|
56
|
+
### `/docs`
|
|
32
57
|
|
|
33
|
-
|
|
58
|
+
Содержит истории в формате Storybook
|
|
34
59
|
|
|
35
60
|
```js
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
//
|
|
39
|
-
export { ComponentName, componentNameConfig } from './ComponentName'
|
|
61
|
+
/docs/
|
|
62
|
+
├─ Overview.mdx // 👈 базовая информация о компоненте
|
|
63
|
+
└─ Playground.mdx // 👈 песочница компонента
|
|
40
64
|
```
|
|
41
65
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Файл содержит переменные в формат [CSS переменные](https://developer.mozilla.org/docs/Web/CSS/CSS_cascading_variables/Using_CSS_custom_properties)
|
|
66
|
+
Базовая информация о компоненте
|
|
45
67
|
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
--componentName-size-xxl-min-height: 40px;
|
|
53
|
-
--componentName-size-xxl-gap: 5px;
|
|
54
|
-
--componentName-type-icon-size-xxl-max-width: 40px;
|
|
55
|
-
--componentName-type-icon-size-xxl-max-height: 40px;
|
|
56
|
-
...
|
|
57
|
-
}
|
|
58
|
-
```
|
|
68
|
+
```jsx
|
|
69
|
+
import { Canvas, Meta } from '@storybook/blocks'
|
|
70
|
+
// 👇 импорт истории для использованя на странице
|
|
71
|
+
import * as ComponentNameStories from '../stories/Demo.stories.tsx'
|
|
72
|
+
// 👇 расположение компонента
|
|
73
|
+
<Meta title="Atoms / ComponentName / Overview" />
|
|
59
74
|
|
|
60
|
-
|
|
75
|
+
# ComponentName
|
|
76
|
+
`ComponentName` — используется для отображения компонента
|
|
61
77
|
|
|
62
|
-
|
|
78
|
+
## Demo
|
|
79
|
+
// 👇 демонстрация Demo
|
|
80
|
+
<Canvas sourceState="shown" of={ComponentNameStories.Demo} />
|
|
63
81
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
@import './css/componentName_shape.css';
|
|
68
|
-
@import './css/componentName_size.css';
|
|
69
|
-
@import './css/componentName_type.css';
|
|
82
|
+
## Skeleton
|
|
83
|
+
// 👇 демонстрация Skeleton
|
|
84
|
+
<Canvas sourceState="shown" of={ComponentNameStories.Skeleton} />
|
|
70
85
|
```
|
|
71
86
|
|
|
87
|
+
Песочница
|
|
72
88
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
import { componentNameAppearanceAccent } from './appearance/componentNameAccent'
|
|
80
|
-
import { componentNameAppearanceType } from './ComponentName.interface'
|
|
89
|
+
```jsx
|
|
90
|
+
import { Canvas, Controls, Meta } from '@storybook/blocks'
|
|
91
|
+
// 👇 импорт истории для использованя на странице
|
|
92
|
+
import * as ComponentNameStories from '../stories/Demo.stories.tsx'
|
|
93
|
+
// 👇 расположение компонента
|
|
94
|
+
<Meta title="Atoms / ComponentName / Playground" />
|
|
81
95
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
96
|
+
# Playground
|
|
97
|
+
<Canvas sourceState="shown" of={ComponentNameStories.Demo} />
|
|
98
|
+
<Controls of={ComponentNameStories.Demo} />
|
|
86
99
|
```
|
|
87
100
|
|
|
88
|
-
###
|
|
101
|
+
### `appearance`
|
|
89
102
|
|
|
90
|
-
|
|
103
|
+
#### Чтобы закрасить компонент
|
|
104
|
+
Используется цвет согласно фигме, для иконок добавляется суффикс `Item`, дял текста `Text`.
|
|
91
105
|
|
|
92
|
-
|
|
106
|
+
#### Чтобы указать состояния
|
|
107
|
+
Если есть состояния у компонента, `active`, `hover`, то цвета для них указать в `appearanre` c цветами.
|
|
93
108
|
|
|
109
|
+
```js
|
|
94
110
|
const componentNameAppearanceAccent = {
|
|
95
111
|
...
|
|
96
112
|
accent: {
|
|
97
113
|
// 👇 настройки props согласно компоненту
|
|
114
|
+
fill: 'accentPrimary'
|
|
115
|
+
textColor: 'labelTextColor',
|
|
98
116
|
dotFill: 'accentItemPrimary',
|
|
99
117
|
iconFill: 'accentItemPrimary',
|
|
100
118
|
},
|
|
@@ -102,19 +120,81 @@ const componentNameAppearanceAccent = {
|
|
|
102
120
|
}
|
|
103
121
|
|
|
104
122
|
export { componentNameAppearanceAccent }
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### Чтобы указать размеры компонента
|
|
126
|
+
Необходимо создать файл `componentSize.ts`, в котором должны находиться `размеры компонента`, `размеры иконок`, `размеры шрифтов`.
|
|
127
|
+
|
|
128
|
+
```js
|
|
129
|
+
const componentNameAppearanceSize = {
|
|
130
|
+
...
|
|
131
|
+
sizeL: {
|
|
132
|
+
// 👇 настройки props согласно компоненту
|
|
133
|
+
size: 'l',
|
|
134
|
+
textColorSize: 'l'
|
|
135
|
+
},
|
|
136
|
+
...
|
|
137
|
+
}
|
|
105
138
|
|
|
139
|
+
export { componentNameAppearanceSize }
|
|
106
140
|
```
|
|
107
141
|
|
|
142
|
+
#### Чтобы указать стиль
|
|
143
|
+
Необходимо создать файл `componentStyle.ts`, в котором должны находиться:
|
|
144
|
+
- `Solid` - есть задний фон, но нет рамки,
|
|
145
|
+
- `Outlined` - нет заднего фона, но есть рамка,
|
|
146
|
+
- `Full` - есть и задний фон и рамка,
|
|
147
|
+
- `Ghost` - нет ни заднего фона, ни рамки
|
|
148
|
+
|
|
149
|
+
```js
|
|
150
|
+
const componentNameAppearanceStyle = {
|
|
151
|
+
full: {},
|
|
152
|
+
ghost: {
|
|
153
|
+
fill: 'none',
|
|
154
|
+
borderColor: 'none',
|
|
155
|
+
},
|
|
156
|
+
outlined: {
|
|
157
|
+
fill: 'none',
|
|
158
|
+
},
|
|
159
|
+
solid: {
|
|
160
|
+
borderColor: 'none',
|
|
161
|
+
},
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { componentNameAppearanceStyle }
|
|
165
|
+
```
|
|
108
166
|
|
|
109
167
|
### `/stories`
|
|
110
168
|
|
|
111
|
-
Содержит минимум
|
|
169
|
+
Содержит минимум такую структуру 👇, почти для каждого компонента
|
|
112
170
|
|
|
113
171
|
```js
|
|
114
|
-
|
|
115
|
-
|
|
172
|
+
stories
|
|
173
|
+
├─ ComponentDemo.stories.tsx
|
|
174
|
+
│ ├─ Demo // 👈 это демонстрация компонента
|
|
175
|
+
│ └─ Skeleton // 👈 показывает временные контуры компонента, когда загружается страница
|
|
176
|
+
├─ ComponentDefault.stories.tsx
|
|
177
|
+
│ ├─ Accent // 👈 цвет из figma
|
|
178
|
+
│ ├─ Error // 👈 цвет из figma
|
|
179
|
+
│ ├─ Warning // 👈 цвет из figma
|
|
180
|
+
│ └─ Surface // и т.д.
|
|
181
|
+
├─ ComponentStyle.stories.tsx
|
|
182
|
+
│ ├─ Solid // 👈 состояние, когда есть задний фон, но нет рамки
|
|
183
|
+
│ ├─ Outlined // 👈 состояние, когда нет заднего фона, но есть рамка
|
|
184
|
+
│ ├─ Full // 👈 состояние, когда есть и задний фон и рамка
|
|
185
|
+
│ └─ Ghost // 👈 состояние, когда нет ни заднего фона, ни рамки
|
|
186
|
+
└─ ComponentSize.stories.tsx
|
|
187
|
+
├─ SizeXXL // 👈 размер из figma
|
|
188
|
+
├─ SizeXL // 👈 размер из figma
|
|
189
|
+
├─ SizeL // 👈 размер из figma
|
|
190
|
+
├─ SizeM // 👈 размер из figma
|
|
191
|
+
├─ SizeS // 👈 размер из figma
|
|
192
|
+
├─ SizeXS // 👈 размер из figma
|
|
193
|
+
└─ SizeXXS // 👈 размер из figma
|
|
116
194
|
```
|
|
117
195
|
|
|
196
|
+
Это типовая структуру `stories` для компонента, стоит помнить что каждый компонент индивидуален и структура `stories` подстраивается под него и под `figma`
|
|
197
|
+
|
|
118
198
|
```tsx
|
|
119
199
|
import { ComponentName } from '../ComponentName'
|
|
120
200
|
|
|
@@ -151,47 +231,258 @@ export const Skeleton = {
|
|
|
151
231
|
|
|
152
232
|
```
|
|
153
233
|
|
|
154
|
-
|
|
234
|
+
1. Каждый цвет это отдельная история,
|
|
235
|
+
```tsx
|
|
236
|
+
import { ComponentName } from '../ComponentName'
|
|
155
237
|
|
|
156
|
-
|
|
238
|
+
export default {
|
|
239
|
+
title: 'Atoms / ComponentName / Accent', // 👈 расположение компонента
|
|
240
|
+
component: ComponentName,
|
|
241
|
+
args: {
|
|
242
|
+
label: 'Label', // 👈 передаваемый свойства согласно компоненту
|
|
243
|
+
},
|
|
244
|
+
parameters: {
|
|
245
|
+
layout: 'centered', // 👈 настройка расположения компонента
|
|
246
|
+
},
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export const Default = {
|
|
250
|
+
render: (args) => {
|
|
251
|
+
return <ComponentName {...args} appearance="surfacePrimary sizeXXL" />
|
|
252
|
+
},
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export const IsChecked = {
|
|
256
|
+
args: {
|
|
257
|
+
isChecked: true,
|
|
258
|
+
},
|
|
259
|
+
render: (args) => {
|
|
260
|
+
return <ComponentName {...args} />
|
|
261
|
+
},
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
но когда компонент `простой`, то можно создать одну историю `ComponentDefault.stories.tsx`, в которой будут все цвета
|
|
266
|
+
|
|
267
|
+
```tsx
|
|
268
|
+
import { ComponentName } from '../ComponentName'
|
|
269
|
+
|
|
270
|
+
export default {
|
|
271
|
+
title: 'Atoms / ComponentName / Default', // 👈 расположение компонента
|
|
272
|
+
component: ComponentName,
|
|
273
|
+
args: {
|
|
274
|
+
label: 'Label', // 👈 передаваемый свойства согласно компоненту
|
|
275
|
+
},
|
|
276
|
+
parameters: {
|
|
277
|
+
layout: 'centered', // 👈 настройка расположения компонента
|
|
278
|
+
},
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export const Accent = {
|
|
282
|
+
args: {
|
|
283
|
+
appearance: 'accentPrimary sizeXL'
|
|
284
|
+
},
|
|
285
|
+
render: (args) => {
|
|
286
|
+
return <ComponentName {...args} appearance="surfacePrimary sizeXXL" />
|
|
287
|
+
},
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export const Surface = {
|
|
291
|
+
args: {
|
|
292
|
+
appearance: 'surfacePrimary sizeXL'
|
|
293
|
+
},
|
|
294
|
+
render: (args) => {
|
|
295
|
+
return <ComponentName {...args} appearance="surfacePrimary sizeXXL" />
|
|
296
|
+
},
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
```
|
|
300
|
+
2. Если есть `appearance` размеры, то для этого нужно сделать отдельно историю
|
|
301
|
+
|
|
302
|
+
```tsx
|
|
303
|
+
import { ComponentName } from '../ComponentName'
|
|
304
|
+
|
|
305
|
+
export default {
|
|
306
|
+
title: 'Atoms / ComponentName / Size', // 👈 расположение компонента
|
|
307
|
+
component: ComponentName,
|
|
308
|
+
args: {
|
|
309
|
+
label: 'Label', // 👈 передаваемый свойства согласно компоненту
|
|
310
|
+
},
|
|
311
|
+
parameters: {
|
|
312
|
+
layout: 'centered', // 👈 настройка расположения компонента
|
|
313
|
+
},
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export const SizeXXL = {
|
|
317
|
+
appearance: 'surfacePrimary sizeXXL',
|
|
318
|
+
render: (args) => {
|
|
319
|
+
return <ComponentName {...args} appearance="surfacePrimary sizeXXL" />
|
|
320
|
+
},
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export const SizeXL = {
|
|
324
|
+
args: {
|
|
325
|
+
appearance: 'surfacePrimary sizeXL',
|
|
326
|
+
},
|
|
327
|
+
render: (args) => {
|
|
328
|
+
return <ComponentName {...args} appearance="surfacePrimary sizeXXL" />
|
|
329
|
+
},
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
```
|
|
333
|
+
3. Если есть `style appearance`, сделать отдельно историю
|
|
334
|
+
|
|
335
|
+
```tsx
|
|
336
|
+
const meta = {
|
|
337
|
+
title: 'Atoms / Component / Style',
|
|
338
|
+
component: Component,
|
|
339
|
+
args: {
|
|
340
|
+
label: 'Label',
|
|
341
|
+
},
|
|
342
|
+
parameters: {
|
|
343
|
+
layout: 'centered',
|
|
344
|
+
},
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export default meta
|
|
348
|
+
|
|
349
|
+
export const Solid = {
|
|
350
|
+
args: {
|
|
351
|
+
appearance: 'surfacePrimary sizeXL solid',
|
|
352
|
+
},
|
|
353
|
+
render: (args: ComponentProps) => {
|
|
354
|
+
return <Chips {...args} />
|
|
355
|
+
},
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
export const Outlined = {
|
|
359
|
+
args: {
|
|
360
|
+
appearance: 'surfacePrimary sizeXL outlined',
|
|
361
|
+
},
|
|
362
|
+
render: (args: ComponentProps) => {
|
|
363
|
+
return <Chips {...args} />
|
|
364
|
+
},
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
export const Full = {
|
|
368
|
+
args: {
|
|
369
|
+
appearance: 'surfacePrimary sizeXL full',
|
|
370
|
+
},
|
|
371
|
+
render: (args: ComponentProps) => {
|
|
372
|
+
return <Chips {...args} />
|
|
373
|
+
},
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export const Ghost = {
|
|
377
|
+
args: {
|
|
378
|
+
appearance: 'surfacePrimary sizeL ghost',
|
|
379
|
+
},
|
|
380
|
+
render: (args: ComponentProps) => {
|
|
381
|
+
return <Chips {...args} />
|
|
382
|
+
},
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
### index.ts
|
|
157
389
|
|
|
158
390
|
```js
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
391
|
+
// 👇 экспорт настроек componentNameAppearance
|
|
392
|
+
export { componentNameAppearance } from './ComponentName.appearance'
|
|
393
|
+
// 👇 экспорт компонента и его конфигурации
|
|
394
|
+
export { ComponentName, componentNameConfig } from './ComponentName'
|
|
162
395
|
```
|
|
163
396
|
|
|
164
|
-
|
|
397
|
+
### ComponentName.tokens.css
|
|
165
398
|
|
|
166
|
-
|
|
167
|
-
import { Canvas, Meta } from '@storybook/blocks'
|
|
168
|
-
// 👇 импорт истории для использованя на странице
|
|
169
|
-
import * as ComponentNameStories from '../stories/Demo.stories.tsx'
|
|
170
|
-
// 👇 расположение компонента
|
|
171
|
-
<Meta title="Atoms / ComponentName / Overview" />
|
|
399
|
+
Файл содержит переменные в формат [CSS переменные](https://developer.mozilla.org/docs/Web/CSS/CSS_cascading_variables/Using_CSS_custom_properties)
|
|
172
400
|
|
|
173
|
-
|
|
174
|
-
|
|
401
|
+
```css
|
|
402
|
+
// 👇 экспорт настроек componentNameAppearance
|
|
403
|
+
:root {
|
|
404
|
+
...
|
|
405
|
+
--componentName-size-xxl-padding: 1m 1.5m;
|
|
406
|
+
--componentName-size-xxl-min-width: 40px;
|
|
407
|
+
--componentName-size-xxl-min-height: 40px;
|
|
408
|
+
--componentName-size-xxl-gap: 5px;
|
|
409
|
+
--componentName-type-icon-size-xxl-max-width: 40px;
|
|
410
|
+
--componentName-type-icon-size-xxl-max-height: 40px;
|
|
411
|
+
...
|
|
412
|
+
}
|
|
413
|
+
```
|
|
175
414
|
|
|
176
|
-
|
|
177
|
-
// 👇 демонстрация Demo
|
|
178
|
-
<Canvas sourceState="shown" of={ComponentNameStories.Demo} />
|
|
415
|
+
### ComponentName.css
|
|
179
416
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
417
|
+
Файл импорта css файлов
|
|
418
|
+
|
|
419
|
+
```css
|
|
420
|
+
@import './css/componentName.css';
|
|
421
|
+
@import './css/componentName_skeleton.css';
|
|
422
|
+
@import './css/componentName_shape.css';
|
|
423
|
+
@import './css/componentName_size.css';
|
|
424
|
+
@import './css/componentName_type.css';
|
|
183
425
|
```
|
|
184
426
|
|
|
185
|
-
Песочница
|
|
186
427
|
|
|
187
|
-
|
|
188
|
-
import { Canvas, Controls, Meta } from '@storybook/blocks'
|
|
189
|
-
// 👇 импорт истории для использованя на странице
|
|
190
|
-
import * as ComponentNameStories from '../stories/Demo.stories.tsx'
|
|
191
|
-
// 👇 расположение компонента
|
|
192
|
-
<Meta title="Atoms / ComponentName / Playground" />
|
|
428
|
+
### ComponentName.appearance.ts
|
|
193
429
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
430
|
+
Основной файл импорта оформлений
|
|
431
|
+
|
|
432
|
+
```js
|
|
433
|
+
// 👇 импорт Accent темы
|
|
434
|
+
import { componentNameAppearanceAccent } from './appearance/componentNameAccent'
|
|
435
|
+
import { componentNameAppearanceType } from './ComponentName.interface'
|
|
436
|
+
|
|
437
|
+
export const componentNameAppearance: componentNameAppearanceType = {
|
|
438
|
+
// 👇 экспорт Accent темы
|
|
439
|
+
...componentNameAppearanceAccent,
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
### Создание цветовых, стилевых, и размеры `appearance`,
|
|
445
|
+
|
|
446
|
+
### Реализация
|
|
447
|
+
На примере `button` рассмотрим реализацию
|
|
448
|
+

|
|
449
|
+
|
|
450
|
+
В фигме можно получить цвета, размеры, рамку у самой кнопки, у текста который используется в в ней, у иконок, которые в используются в кнопке, возьмем цвет `accent`, который равен `#74B43D`. Важно обратить внимание на `Default` - это название коллекции токенов
|
|
451
|
+
|
|
452
|
+

|
|
453
|
+
Нажав на компонент из кнопки, нам доступны эти цвета, которые ссылаются на [дизайн-токены](https://www.figma.com/design/S33s34qogjRq2u3Y9Imsml/AM---Tokens?t=5hacZwzMeBv9bJMA-0)
|
|
454
|
+
Далее переходим в `variables`
|
|
455
|
+

|
|
456
|
+
|
|
457
|
+
И как было написано ранее, здесь у нас коллекции токенов, в нашем случае это была `Default` коллекция.
|
|
458
|
+
Затем нам доступна таблица в которой:
|
|
459
|
+
- `fill` - используется чтобы закрасить фон
|
|
460
|
+
- `text` - цвет текста кнопки
|
|
461
|
+
- `item` - цвет иконки
|
|
462
|
+
- `boder` - цвет рамки
|
|
463
|
+
|
|
464
|
+
ориентироваться стоит на названия
|
|
465
|
+
|
|
466
|
+

|
|
467
|
+
|
|
468
|
+
Помним что цвет заднего фона кнопки равен `#74B43D` и именно он пойдет в код.
|
|
469
|
+
И именно в `buttonAccent.ts` будут находиться только цвета.
|
|
470
|
+
|
|
471
|
+
```js
|
|
472
|
+
accentPrimary: {
|
|
473
|
+
fill: 'accentPrimary', // задний фон
|
|
474
|
+
labelTextColor: 'accentTextPrimary', // цвет текста
|
|
475
|
+
borderColor: 'accentBorderPrimary', // цвет рамки
|
|
476
|
+
iconAfterFillIcon: 'accentItemPrimary', // цвет иконки
|
|
477
|
+
},
|
|
478
|
+
```
|
|
479
|
+
В коде это будет выглядеть так, ключи объекты, это `props` компонента, а значения это цвета, которые были взять из `figma`.
|
|
480
|
+
|
|
481
|
+
Все что связано с размерами, текста, компонента, иконок необходимо выносить в отдельный файл `buttonSize.ts`. Определяем по фигме необходимые размеры и переносим их в код
|
|
482
|
+
```js
|
|
483
|
+
sizeXXL: {
|
|
484
|
+
size: 'xxl', // размер кнопки
|
|
485
|
+
labelTextSize: 'xl', // размер текста
|
|
486
|
+
iconAfterSize: 24, // размер иконки
|
|
487
|
+
}
|
|
488
|
+
```
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Meta } from '@storybook/blocks'
|
|
2
|
+
|
|
3
|
+
<Meta title="Hooks / useAppearanceConfig" />
|
|
4
|
+
|
|
5
|
+
# `useAppearanceConfig`
|
|
6
|
+
Хук позволяет возвращает объект из всех `appearance` переданных компоненту
|
|
7
|
+
|
|
8
|
+
## Использование
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
import { useAppearanceConfig } from 'src/hooks/useAppearanceConfig'
|
|
12
|
+
|
|
13
|
+
const { appearanceConfig } = useAppearanceConfig(
|
|
14
|
+
appearance,
|
|
15
|
+
componentConfig,
|
|
16
|
+
isDisabled,
|
|
17
|
+
)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Параметры
|
|
21
|
+
|
|
22
|
+
<table>
|
|
23
|
+
<thead>
|
|
24
|
+
<tr>
|
|
25
|
+
<th>Название</th>
|
|
26
|
+
<th>Обязательный</th>
|
|
27
|
+
<th>Тип</th>
|
|
28
|
+
<th>Значение</th>
|
|
29
|
+
<th>Описание</th>
|
|
30
|
+
</tr>
|
|
31
|
+
</thead>
|
|
32
|
+
<tbody>
|
|
33
|
+
<tr>
|
|
34
|
+
<td>appearance</td>
|
|
35
|
+
<td>Да</td>
|
|
36
|
+
<td>`string`</td>
|
|
37
|
+
<td>`'surfacePrimary sizeXL'`</td>
|
|
38
|
+
<td>Переданные appearance компоненту</td>
|
|
39
|
+
</tr>
|
|
40
|
+
<tr>
|
|
41
|
+
<td>componentConfig</td>
|
|
42
|
+
<td>Да</td>
|
|
43
|
+
<td></td>
|
|
44
|
+
<td>
|
|
45
|
+
`{
|
|
46
|
+
appearance,
|
|
47
|
+
setAppearance
|
|
48
|
+
}`
|
|
49
|
+
</td>
|
|
50
|
+
<td>Конфигурация всех appearance компонента</td>
|
|
51
|
+
</tr>
|
|
52
|
+
<tr>
|
|
53
|
+
<td>isDisabled</td>
|
|
54
|
+
<td>Нет</td>
|
|
55
|
+
<td>`boolean`</td>
|
|
56
|
+
<td>
|
|
57
|
+
`true`
|
|
58
|
+
</td>
|
|
59
|
+
<td>Указывает, отключен ли компонент</td>
|
|
60
|
+
</tr>
|
|
61
|
+
</tbody>
|
|
62
|
+
</table>
|
|
63
|
+
|
|
64
|
+
## Возвращает
|
|
65
|
+
|
|
66
|
+
<table>
|
|
67
|
+
<thead>
|
|
68
|
+
<tr>
|
|
69
|
+
<th>Название</th>
|
|
70
|
+
<th>Тип</th>
|
|
71
|
+
<th>Значение</th>
|
|
72
|
+
</tr>
|
|
73
|
+
</thead>
|
|
74
|
+
<tbody>
|
|
75
|
+
<tr>
|
|
76
|
+
<td>appearanceConfig</td>
|
|
77
|
+
<td>`[key: string]: number | string`</td>
|
|
78
|
+
<td>`{size: 's', fill: 'surfacePrimary'}`</td>
|
|
79
|
+
</tr>
|
|
80
|
+
</tbody>
|
|
81
|
+
</table>
|
|
82
|
+
|
|
83
|
+
|
|
@@ -92,17 +92,15 @@ const componentConfig: ComponentConfig = {
|
|
|
92
92
|
}
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
Используем `useAppearanceConfig`
|
|
96
96
|
```js
|
|
97
|
-
const appearanceConfig =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}),
|
|
102
|
-
{},
|
|
97
|
+
const { appearanceConfig } = useAppearanceConfig(
|
|
98
|
+
appearance,
|
|
99
|
+
componentConfig,
|
|
100
|
+
isDisabled,
|
|
103
101
|
)
|
|
104
102
|
```
|
|
105
|
-
Которому передается созданный ранее componentConfig и его результатом будет единый объект со свойствами из разных appearance
|
|
103
|
+
Которому передается созданный ранее `componentConfig` и `appearance`, его результатом будет единый объект со свойствами из разных appearance
|
|
106
104
|
|
|
107
105
|
```js
|
|
108
106
|
{
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
declare const chipsAppearanceDisabled: {
|
|
2
2
|
disabled: {
|
|
3
3
|
fill: string;
|
|
4
|
-
fillActive: string;
|
|
5
|
-
fillHover: string;
|
|
6
4
|
labelTextColor: string;
|
|
7
|
-
labelTextHoverColor: string;
|
|
8
5
|
borderColor: string;
|
|
6
|
+
iconAfterFillIcon: string;
|
|
7
|
+
iconBeforeFillIcon: string;
|
|
9
8
|
};
|
|
10
9
|
};
|
|
11
10
|
export { chipsAppearanceDisabled };
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
declare const dropdownAppearanceAccent: {
|
|
2
2
|
accentPrimary: {
|
|
3
3
|
fill: string;
|
|
4
|
+
fillActive: string;
|
|
5
|
+
fillActiveHover: string;
|
|
4
6
|
fillHover: string;
|
|
5
7
|
labelTextColor: string;
|
|
6
8
|
labelTextColorActive: string;
|
|
7
9
|
labelTextColorActiveHover: string;
|
|
8
10
|
labelTextColorHover: string;
|
|
11
|
+
badgeAppearance: string;
|
|
12
|
+
dividerFill: string;
|
|
13
|
+
emptyMessageTextColor: string;
|
|
9
14
|
iconAfterFillIcon: string;
|
|
10
15
|
iconBeforeFillIcon: string;
|
|
11
16
|
};
|