@salutejs/plasma-new-hope 0.67.0-canary.1148.8444175533.0 → 0.67.0-canary.1148.8449317874.0
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/components/Cell/Cell.js +3 -0
- package/cjs/components/Cell/Cell.js.map +1 -1
- package/cjs/components/Cell/Cell.tokens.js +2 -3
- package/cjs/components/Cell/Cell.tokens.js.map +1 -1
- package/es/components/Cell/Cell.js +3 -0
- package/es/components/Cell/Cell.js.map +1 -1
- package/es/components/Cell/Cell.tokens.js +2 -3
- package/es/components/Cell/Cell.tokens.js.map +1 -1
- package/package.json +2 -2
- package/styled-components/cjs/components/Avatar/Avatar.template-doc.mdx +97 -0
- package/styled-components/cjs/components/AvatarGroup/AvatarGroup.template-doc.mdx +29 -0
- package/styled-components/cjs/components/Badge/Badge.template-doc.mdx +131 -0
- package/styled-components/cjs/components/Button/Button.template-doc.mdx +162 -0
- package/styled-components/cjs/components/ButtonGroup/ButtonGroup.template-doc.mdx +123 -0
- package/styled-components/cjs/components/Calendar/Calendar.template-doc.mdx +208 -0
- package/styled-components/cjs/components/Cell/Cell.js +3 -0
- package/styled-components/cjs/components/Cell/Cell.tokens.js +2 -3
- package/styled-components/cjs/components/Checkbox/Checkbox.template-doc.mdx +44 -0
- package/styled-components/cjs/components/Chip/Chip.template-doc.mdx +90 -0
- package/styled-components/cjs/components/Combobox/Combobox.template-doc.mdx +237 -0
- package/styled-components/cjs/components/Counter/Counter.template-doc.mdx +76 -0
- package/styled-components/cjs/components/Drawer/Drawer.template-doc.mdx +170 -0
- package/styled-components/cjs/components/Dropdown/Dropdown.template-doc.mdx +80 -0
- package/styled-components/cjs/components/Grid/Grid.template-doc.mdx +142 -0
- package/styled-components/cjs/components/Image/Image.template-doc.mdx +26 -0
- package/styled-components/cjs/components/Indicator/Indicator.template-doc.mdx +76 -0
- package/styled-components/cjs/components/Link/Link.template-doc.mdx +23 -0
- package/styled-components/cjs/components/Modal/Modal.template-doc.mdx +56 -0
- package/styled-components/cjs/components/Notification/Notification.template-doc.mdx +59 -0
- package/styled-components/cjs/components/Overlay/Overlay.template-doc.mdx +10 -0
- package/styled-components/cjs/components/Popover/Popover.template-doc.mdx +72 -0
- package/styled-components/cjs/components/Popup/Popup.template-doc.mdx +209 -0
- package/styled-components/cjs/components/Radiobox/Radiobox.template-doc.mdx +38 -0
- package/styled-components/cjs/components/Segment/Segment.template-doc.mdx +61 -0
- package/styled-components/cjs/components/Select/Select.template-doc.mdx +115 -0
- package/styled-components/cjs/components/Skeleton/Skeleton.template-doc.mdx +103 -0
- package/styled-components/cjs/components/Spinner/Spinner.template-doc.mdx +21 -0
- package/styled-components/cjs/components/Switch/Switch.template-doc.mdx +24 -0
- package/styled-components/cjs/components/Tabs/Tabs.template-doc.mdx +94 -0
- package/styled-components/cjs/components/TextArea/TextArea.template-doc.mdx +88 -0
- package/styled-components/cjs/components/TextField/TextField.template-doc.mdx +112 -0
- package/styled-components/cjs/components/Toast/Toast.template-doc.mdx +153 -0
- package/styled-components/cjs/components/Tooltip/Tooltip.template-doc.mdx +30 -0
- package/styled-components/cjs/components/Typography/Typography.template-doc.mdx +127 -0
- package/styled-components/cjs/examples/plasma_b2c/components/Cell/Cell.config.js +5 -5
- package/styled-components/cjs/examples/plasma_b2c/components/Cell/Cell.stories.tsx +16 -19
- package/styled-components/cjs/examples/plasma_web/components/Cell/Cell.config.js +5 -5
- package/styled-components/cjs/examples/plasma_web/components/Cell/Cell.stories.tsx +16 -19
- package/styled-components/es/components/Avatar/Avatar.template-doc.mdx +97 -0
- package/styled-components/es/components/AvatarGroup/AvatarGroup.template-doc.mdx +29 -0
- package/styled-components/es/components/Badge/Badge.template-doc.mdx +131 -0
- package/styled-components/es/components/Button/Button.template-doc.mdx +162 -0
- package/styled-components/es/components/ButtonGroup/ButtonGroup.template-doc.mdx +123 -0
- package/styled-components/es/components/Calendar/Calendar.template-doc.mdx +208 -0
- package/styled-components/es/components/Cell/Cell.js +3 -0
- package/styled-components/es/components/Cell/Cell.tokens.js +2 -3
- package/styled-components/es/components/Checkbox/Checkbox.template-doc.mdx +44 -0
- package/styled-components/es/components/Chip/Chip.template-doc.mdx +90 -0
- package/styled-components/es/components/Combobox/Combobox.template-doc.mdx +237 -0
- package/styled-components/es/components/Counter/Counter.template-doc.mdx +76 -0
- package/styled-components/es/components/Drawer/Drawer.template-doc.mdx +170 -0
- package/styled-components/es/components/Dropdown/Dropdown.template-doc.mdx +80 -0
- package/styled-components/es/components/Grid/Grid.template-doc.mdx +142 -0
- package/styled-components/es/components/Image/Image.template-doc.mdx +26 -0
- package/styled-components/es/components/Indicator/Indicator.template-doc.mdx +76 -0
- package/styled-components/es/components/Link/Link.template-doc.mdx +23 -0
- package/styled-components/es/components/Modal/Modal.template-doc.mdx +56 -0
- package/styled-components/es/components/Notification/Notification.template-doc.mdx +59 -0
- package/styled-components/es/components/Overlay/Overlay.template-doc.mdx +10 -0
- package/styled-components/es/components/Popover/Popover.template-doc.mdx +72 -0
- package/styled-components/es/components/Popup/Popup.template-doc.mdx +209 -0
- package/styled-components/es/components/Radiobox/Radiobox.template-doc.mdx +38 -0
- package/styled-components/es/components/Segment/Segment.template-doc.mdx +61 -0
- package/styled-components/es/components/Select/Select.template-doc.mdx +115 -0
- package/styled-components/es/components/Skeleton/Skeleton.template-doc.mdx +103 -0
- package/styled-components/es/components/Spinner/Spinner.template-doc.mdx +21 -0
- package/styled-components/es/components/Switch/Switch.template-doc.mdx +24 -0
- package/styled-components/es/components/Tabs/Tabs.template-doc.mdx +94 -0
- package/styled-components/es/components/TextArea/TextArea.template-doc.mdx +88 -0
- package/styled-components/es/components/TextField/TextField.template-doc.mdx +112 -0
- package/styled-components/es/components/Toast/Toast.template-doc.mdx +153 -0
- package/styled-components/es/components/Tooltip/Tooltip.template-doc.mdx +30 -0
- package/styled-components/es/components/Typography/Typography.template-doc.mdx +127 -0
- package/styled-components/es/examples/plasma_b2c/components/Cell/Cell.config.js +5 -5
- package/styled-components/es/examples/plasma_b2c/components/Cell/Cell.stories.tsx +16 -19
- package/styled-components/es/examples/plasma_web/components/Cell/Cell.config.js +5 -5
- package/styled-components/es/examples/plasma_web/components/Cell/Cell.stories.tsx +16 -19
- package/types/components/Cell/Cell.d.ts +4 -2
- package/types/components/Cell/Cell.d.ts.map +1 -1
- package/types/components/Cell/Cell.tokens.d.ts +0 -1
- package/types/components/Cell/Cell.tokens.d.ts.map +1 -1
- package/types/components/Cell/Cell.types.d.ts +5 -2
- package/types/components/Cell/Cell.types.d.ts.map +1 -1
- package/types/examples/plasma_b2c/components/Cell/Cell.d.ts +2 -1
- package/types/examples/plasma_b2c/components/Cell/Cell.d.ts.map +1 -1
- package/types/examples/plasma_web/components/Cell/Cell.d.ts +2 -1
- package/types/examples/plasma_web/components/Cell/Cell.d.ts.map +1 -1
@@ -0,0 +1,72 @@
|
|
1
|
+
---
|
2
|
+
id: popover
|
3
|
+
title: Popover
|
4
|
+
---
|
5
|
+
|
6
|
+
import { PropsTable, Description } from '@site/src/components';
|
7
|
+
|
8
|
+
# Popover
|
9
|
+
<Description name="Popover" />
|
10
|
+
<PropsTable name="Popover" />
|
11
|
+
|
12
|
+
```tsx live
|
13
|
+
import React from 'react';
|
14
|
+
import styled from "styled-components";
|
15
|
+
import { surfaceSolid03 } from "@salutejs/plasma-tokens/brands/{{ theme }}";
|
16
|
+
import { Popover, Button } from '@salutejs/{{ package }}';
|
17
|
+
|
18
|
+
export function App() {
|
19
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
20
|
+
|
21
|
+
const StyledArrow = styled.div`
|
22
|
+
visibility: hidden;
|
23
|
+
|
24
|
+
&,
|
25
|
+
&::before {
|
26
|
+
position: absolute;
|
27
|
+
width: 0.5rem;
|
28
|
+
height: 0.5rem;
|
29
|
+
background: ${surfaceSolid03};
|
30
|
+
}
|
31
|
+
|
32
|
+
&::before {
|
33
|
+
visibility: visible;
|
34
|
+
content: '';
|
35
|
+
transform: rotate(45deg);
|
36
|
+
}
|
37
|
+
`;
|
38
|
+
|
39
|
+
const StyledContent = styled.div`
|
40
|
+
background: ${surfaceSolid03};
|
41
|
+
padding: 1rem;
|
42
|
+
|
43
|
+
display: flex;
|
44
|
+
flex-direction: column;
|
45
|
+
align-items: center;
|
46
|
+
`;
|
47
|
+
|
48
|
+
return (
|
49
|
+
<section style=\{{width: '20rem', height: '15rem'}}>
|
50
|
+
<Popover
|
51
|
+
isOpen={isOpen}
|
52
|
+
onToggle={(is) => setIsOpen(is)}
|
53
|
+
role="presentation"
|
54
|
+
id="popover"
|
55
|
+
target={<Button>Target</Button>}
|
56
|
+
offset={[0, 6]}
|
57
|
+
arrow={<StyledArrow/>}
|
58
|
+
placement='bottom'
|
59
|
+
trigger='click'
|
60
|
+
closeOnOverlayClick
|
61
|
+
closeOnEsc
|
62
|
+
isFocusTrapped
|
63
|
+
>
|
64
|
+
<StyledContent>
|
65
|
+
<>Content</>
|
66
|
+
<Button onClick={() => setIsOpen(false)}>close</Button>
|
67
|
+
</StyledContent>
|
68
|
+
</Popover>
|
69
|
+
</section>
|
70
|
+
);
|
71
|
+
}
|
72
|
+
```
|
@@ -0,0 +1,209 @@
|
|
1
|
+
---
|
2
|
+
id: popupBase
|
3
|
+
title: PopupBase
|
4
|
+
---
|
5
|
+
|
6
|
+
import { PropsTable, Description } from '@site/src/components';
|
7
|
+
|
8
|
+
# PopupBase
|
9
|
+
<Description name="PopupBase" />
|
10
|
+
<PropsTable name="PopupBase" />
|
11
|
+
|
12
|
+
### Провайдер контекста
|
13
|
+
|
14
|
+
Поместите `PopupBaseProvider` в [корень приложения](../../#корень-приложения) или там, где будете применять PopupBase:
|
15
|
+
|
16
|
+
```tsx title="index.ts"
|
17
|
+
import ReactDOM from 'react-dom';
|
18
|
+
import { PopupBaseProvider } from '@salutejs/{{ package }}';
|
19
|
+
|
20
|
+
import { App } from './App';
|
21
|
+
|
22
|
+
ReactDOM.render(
|
23
|
+
<PopupBaseProvider>
|
24
|
+
<App />
|
25
|
+
</PopupBaseProvider>,
|
26
|
+
document.getElementById('root')
|
27
|
+
);
|
28
|
+
```
|
29
|
+
|
30
|
+
### Использование
|
31
|
+
|
32
|
+
PopupBase можно использовать как и на всем окне, так и в отдельном фрейме - свойство `frame`.
|
33
|
+
Также это свойство поддерживает передачу id элемента, в котором будет использоваться компонент.
|
34
|
+
Само позиционирование можно указать с помощью свойства `placement`(center - по умолчанию; left, right, top, bottom и их комбинации),
|
35
|
+
а также определить отступы от точки с помощью `offset`.
|
36
|
+
|
37
|
+
```tsx live
|
38
|
+
import React, { useRef } from 'react';
|
39
|
+
import { surfaceSolid03, surfaceSolid02 } from '@salutejs/plasma-tokens/brands/{{ theme }}';
|
40
|
+
import { SSRProvider, Button, PopupBase, PopupBaseProvider } from '@salutejs/{{ package }}';
|
41
|
+
|
42
|
+
export function App() {
|
43
|
+
const [isOpenA, setIsOpenA] = React.useState(false);
|
44
|
+
const [isOpenB, setIsOpenB] = React.useState(false);
|
45
|
+
|
46
|
+
const ref = useRef();
|
47
|
+
|
48
|
+
return (
|
49
|
+
<SSRProvider>
|
50
|
+
<PopupBaseProvider>
|
51
|
+
<div style=\{{height: "500px"}}>
|
52
|
+
<div style=\{{ display: 'flex', flexDirection: 'column' }}>
|
53
|
+
<Button
|
54
|
+
style=\{{
|
55
|
+
marginTop: "1rem",
|
56
|
+
width: "15rem"
|
57
|
+
}}
|
58
|
+
text="Открыть в document"
|
59
|
+
onClick={() => setIsOpenB(true)}
|
60
|
+
/>
|
61
|
+
<Button
|
62
|
+
style=\{{
|
63
|
+
marginTop: "1rem",
|
64
|
+
width: "15rem"
|
65
|
+
}}
|
66
|
+
text="Открыть во Frame"
|
67
|
+
onClick={() => setIsOpenA(true)}
|
68
|
+
/>
|
69
|
+
</div>
|
70
|
+
<PopupBase
|
71
|
+
id="popupA"
|
72
|
+
frame={ref}
|
73
|
+
isOpen={isOpenA}
|
74
|
+
placement="center"
|
75
|
+
offset={[0, 0]}
|
76
|
+
>
|
77
|
+
<div style=\{{ background: surfaceSolid02, padding: "1rem" }}>
|
78
|
+
<Button onClick={() => setIsOpenA(false)}>Close</Button>
|
79
|
+
<>Content</>
|
80
|
+
</div>
|
81
|
+
</PopupBase>
|
82
|
+
<div
|
83
|
+
ref={ref}
|
84
|
+
style=\{{
|
85
|
+
marginTop: "1rem",
|
86
|
+
width: "400px",
|
87
|
+
height: "500px",
|
88
|
+
background: surfaceSolid03,
|
89
|
+
position: "absolute",
|
90
|
+
|
91
|
+
display: "flex",
|
92
|
+
alignItems: "flex-start",
|
93
|
+
justifyContent: "center",
|
94
|
+
padding: "1rem",
|
95
|
+
|
96
|
+
bottom: 0,
|
97
|
+
right: 0
|
98
|
+
}}
|
99
|
+
>
|
100
|
+
<>Frame</>
|
101
|
+
</div>
|
102
|
+
<PopupBase
|
103
|
+
id="popupB"
|
104
|
+
frame="document"
|
105
|
+
isOpen={isOpenB}
|
106
|
+
placement="center"
|
107
|
+
offset={[0, 0]}
|
108
|
+
>
|
109
|
+
<Content>
|
110
|
+
<Button onClick={() => setIsOpenB(false)}>Close</Button>
|
111
|
+
<>Content</>
|
112
|
+
</Content>
|
113
|
+
</PopupBase>
|
114
|
+
</div>
|
115
|
+
</PopupBaseProvider>
|
116
|
+
</SSRProvider>
|
117
|
+
);
|
118
|
+
}
|
119
|
+
```
|
120
|
+
|
121
|
+
## Подключение анимации
|
122
|
+
|
123
|
+
Для подключения анимации нужно добавить параметр `withAnimation`.
|
124
|
+
Само управление происходит с помощью классов через переменные `endAnimation`, `endTransition` из объекта `popupBaseClasses` для `PopupBase`.
|
125
|
+
Для добавления анимации необходимо использовать класс `.popup-base-root` через переменную `popupBaseClasses.root` из пакета.
|
126
|
+
|
127
|
+
Пример:
|
128
|
+
|
129
|
+
```tsx
|
130
|
+
const StyledPopupTransition = styled(PopupBase)`
|
131
|
+
&& > .${popupBaseClasses.root} {
|
132
|
+
opacity: 1;
|
133
|
+
transition: opacity 0.5s 0.1s;
|
134
|
+
}
|
135
|
+
|
136
|
+
&&.${popupBaseClasses.endTransition} > .${popupBaseClasses.root} {
|
137
|
+
opacity: 0;
|
138
|
+
transition: opacity 0.5s 0.1s;
|
139
|
+
}
|
140
|
+
`;
|
141
|
+
```
|
142
|
+
|
143
|
+
или
|
144
|
+
|
145
|
+
```tsx
|
146
|
+
const StyledPopupAnimation = styled(PopupBase)`
|
147
|
+
&& > .${popupBaseClasses.root} {
|
148
|
+
animation: fadeIn 1s forwards;
|
149
|
+
}
|
150
|
+
|
151
|
+
&&.${popupBaseClasses.endAnimation} > .${popupBaseClasses.root} {
|
152
|
+
animation: fadeOut 1s forwards;
|
153
|
+
}
|
154
|
+
|
155
|
+
@keyframes fadeIn {
|
156
|
+
from {
|
157
|
+
opacity: 0;
|
158
|
+
}
|
159
|
+
|
160
|
+
to {
|
161
|
+
opacity: 1;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
@keyframes fadeOut {
|
166
|
+
from {
|
167
|
+
opacity: 1;
|
168
|
+
}
|
169
|
+
|
170
|
+
to {
|
171
|
+
opacity: 0;
|
172
|
+
}
|
173
|
+
}
|
174
|
+
`;
|
175
|
+
```
|
176
|
+
|
177
|
+
И в самом компоненте:
|
178
|
+
|
179
|
+
```tsx
|
180
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
181
|
+
|
182
|
+
return (
|
183
|
+
<>
|
184
|
+
<div>
|
185
|
+
<Button
|
186
|
+
style=\{{
|
187
|
+
marginTop: "1rem",
|
188
|
+
width: "15rem"
|
189
|
+
}}
|
190
|
+
text="Открыть"
|
191
|
+
onClick={() => setIsOpen(true)}
|
192
|
+
/>
|
193
|
+
</div>
|
194
|
+
<StyledPopupAnimation
|
195
|
+
id="popup-id"
|
196
|
+
withAnimation
|
197
|
+
frame="document"
|
198
|
+
isOpen={isOpen}
|
199
|
+
placement="center"
|
200
|
+
offset={[0, 0]}
|
201
|
+
>
|
202
|
+
<div>
|
203
|
+
<Button onClick={() => setIsOpen(false)}>Close</Button>
|
204
|
+
</div>
|
205
|
+
</StyledPopupAnimation>
|
206
|
+
</>
|
207
|
+
);
|
208
|
+
}
|
209
|
+
```
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
id: radiobox
|
3
|
+
title: Radiobox
|
4
|
+
---
|
5
|
+
|
6
|
+
import { PropsTable, Description } from '@site/src/components';
|
7
|
+
|
8
|
+
# Radiobox
|
9
|
+
<Description name="Radiobox" />
|
10
|
+
<PropsTable name="Radiobox" exclude={['css', 'focused']} />
|
11
|
+
|
12
|
+
## Использование
|
13
|
+
Компонент `Radiobox` может содержать лейбл и описание.
|
14
|
+
|
15
|
+
По умолчанию, контент внутри лейбла и описания многострочный.
|
16
|
+
|
17
|
+
Для того чтобы стал однострочным, необходимо использовать свойство `singleLine`(по умолчанию `false`).
|
18
|
+
|
19
|
+
```tsx live
|
20
|
+
import React from 'react';
|
21
|
+
import { Radiobox } from '@salutejs/{{ package }}';
|
22
|
+
|
23
|
+
export function App() {
|
24
|
+
return (
|
25
|
+
<Radiobox label="Радиокнопка" description="Описание" defaultChecked />
|
26
|
+
);
|
27
|
+
}
|
28
|
+
```
|
29
|
+
|
30
|
+
## Группа радиокнопок
|
31
|
+
Компоненты `Radiobox` следует объединять в `RadioGroup`
|
32
|
+
```tsx live
|
33
|
+
<RadioGroup aria-labelledby="radiogroup-title-id">
|
34
|
+
<H3 id="radiogroup-title-id">Заголовок</H3>
|
35
|
+
<Radiobox name="radio-1" label="Радиокнопка 1" description="Описание 1" defaultChecked />
|
36
|
+
<Radiobox name="radio-1" label="Радиокнопка 2" description="Описание 2" />
|
37
|
+
</RadioGroup>
|
38
|
+
```
|
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
id: segment
|
3
|
+
title: Segment
|
4
|
+
---
|
5
|
+
|
6
|
+
import { PropsTable, Description } from '@site/src/components';
|
7
|
+
|
8
|
+
# Segment
|
9
|
+
Набор компонентов для создания группы сегментов.
|
10
|
+
Структура для сегментов похожа на структуру маркированных списков.
|
11
|
+
|
12
|
+
## SegmentGroup
|
13
|
+
|
14
|
+
<Description name="SegmentGroup" />
|
15
|
+
<PropsTable name="SegmentGroup" exclude={['css', 'selectedView']} />
|
16
|
+
|
17
|
+
## SegmentItem
|
18
|
+
|
19
|
+
<Description name="SegmentItem" />
|
20
|
+
<PropsTable name="SegmentItem" exclude={['css', 'filledBackground', 'disabled']} />
|
21
|
+
|
22
|
+
### Провайдер контекста
|
23
|
+
|
24
|
+
Оберните в `SegmentProvider` компонент, в котором будут использованы SegmentGroup с SegmentItem.
|
25
|
+
Внутри данного провайдера есть доступ к хуку `useSegment`.
|
26
|
+
|
27
|
+
```tsx live
|
28
|
+
import React, { useState } from 'react';
|
29
|
+
import { SegmentGroup, SegmentItem, SegmentProvider } from '@salutejs/{{ package }}';
|
30
|
+
|
31
|
+
export function App() {
|
32
|
+
const items = Array(8).fill(0);
|
33
|
+
|
34
|
+
const SegmentTemplate = () => {
|
35
|
+
const {selectedSegmentItems} = useSegment();
|
36
|
+
|
37
|
+
return (
|
38
|
+
<>
|
39
|
+
<div>Выбранные элементы: {selectedSegmentItems.join(', ')}</div>
|
40
|
+
<SegmentGroup view='filled' selectionMode='multiple' filledBackground pilled>
|
41
|
+
{items.map((_, i) => (
|
42
|
+
<SegmentItem
|
43
|
+
label={`Label ${i}`}
|
44
|
+
value={`label_${i}`}
|
45
|
+
key={`label_${i}`}
|
46
|
+
view='default'
|
47
|
+
pilled
|
48
|
+
/>
|
49
|
+
))}
|
50
|
+
</SegmentGroup>
|
51
|
+
</>
|
52
|
+
)
|
53
|
+
}
|
54
|
+
|
55
|
+
return (
|
56
|
+
<SegmentProvider>
|
57
|
+
<SegmentTemplate/>
|
58
|
+
</SegmentProvider>
|
59
|
+
);
|
60
|
+
}
|
61
|
+
```
|
@@ -0,0 +1,115 @@
|
|
1
|
+
---
|
2
|
+
id: select
|
3
|
+
title: Select
|
4
|
+
---
|
5
|
+
|
6
|
+
import { PropsTable, Description } from '@site/src/components';
|
7
|
+
|
8
|
+
# Select
|
9
|
+
<Description name="Select" />
|
10
|
+
<PropsTable name="Select" />
|
11
|
+
|
12
|
+
```tsx live
|
13
|
+
import React, { useState } from 'react';
|
14
|
+
import { Select } from '@salutejs/{{ package }}';
|
15
|
+
|
16
|
+
export function App() {
|
17
|
+
const items = [
|
18
|
+
{ value: 'each', label: 'Каждый' },
|
19
|
+
{ value: 'hunter', label: 'Охотник', isDisabled: true },
|
20
|
+
{ value: 'wants', label: 'Желает' },
|
21
|
+
{
|
22
|
+
value: 'toKnow',
|
23
|
+
label: 'Знать',
|
24
|
+
items: [
|
25
|
+
{ value: '_fullText', label: 'Каждый охотник желает знать, где сидит фазан' },
|
26
|
+
{ value: '_thePheasant', label: 'Фазан' },
|
27
|
+
{ value: '_is', label: 'Сидит' },
|
28
|
+
],
|
29
|
+
},
|
30
|
+
{ value: 'where', label: 'Где' },
|
31
|
+
{ value: 'is', label: 'Сидит' },
|
32
|
+
{ value: 'thePheasant', label: 'Фазан' },
|
33
|
+
{ value: 'fullText', label: 'Каждый охотник желает знать, где сидит фазан' },
|
34
|
+
];
|
35
|
+
|
36
|
+
const [value, setValue] = useState(null);
|
37
|
+
|
38
|
+
return (
|
39
|
+
<div style=\{{ maxWidth: '20rem' }}>
|
40
|
+
<div style=\{{ marginBottom: '1rem' }}>
|
41
|
+
<Select
|
42
|
+
value={value}
|
43
|
+
items={items}
|
44
|
+
onChange={(v) => {
|
45
|
+
setValue(v);
|
46
|
+
}}
|
47
|
+
placeholder="Выберите пример"
|
48
|
+
helperText="Заполните пример"
|
49
|
+
status="success"
|
50
|
+
/>
|
51
|
+
</div>
|
52
|
+
<div>
|
53
|
+
<Select value={null} items={[]} placeholder="Another select" />
|
54
|
+
</div>
|
55
|
+
</div>
|
56
|
+
);
|
57
|
+
}
|
58
|
+
```
|
59
|
+
|
60
|
+
### Управление высотой выпадающего меню
|
61
|
+
Что бы задать высоту и `scroll` для выпадающего меню можно использовать **props** для компонента `Select`:
|
62
|
+
- **listOverflow**
|
63
|
+
- **listHeight**
|
64
|
+
|
65
|
+
> Эти **props** необязательные, если их не указать будет использовано значение - [initial](https://developer.mozilla.org/en-US/docs/Web/CSS/initial)
|
66
|
+
|
67
|
+
```tsx live
|
68
|
+
import React, { useState, useCallback } from 'react';
|
69
|
+
import { Select, Modal, ModalsProvider, H3, Button } from '@salutejs/{{ package }}';
|
70
|
+
|
71
|
+
export function App() {
|
72
|
+
const [value, setValue] = useState(null);
|
73
|
+
const [isOpenA, setIsOpenA] = useState(false);
|
74
|
+
|
75
|
+
const onCloseA = useCallback(() => setIsOpenA(false), []);
|
76
|
+
|
77
|
+
const items = [
|
78
|
+
{ value: 'each', label: 'Каждый' },
|
79
|
+
{ value: 'hunter', label: 'Охотник', isDisabled: true },
|
80
|
+
{ value: 'wants', label: 'Желает' },
|
81
|
+
{
|
82
|
+
value: 'toKnow',
|
83
|
+
label: 'Знать',
|
84
|
+
items: [
|
85
|
+
{ value: '_fullText', label: 'Каждый охотник желает знать, где сидит фазан' },
|
86
|
+
{ value: '_thePheasant', label: 'Фазан' },
|
87
|
+
{ value: '_is', label: 'Сидит' },
|
88
|
+
],
|
89
|
+
},
|
90
|
+
{ value: 'where', label: 'Где' },
|
91
|
+
{ value: 'is', label: 'Сидит' },
|
92
|
+
{ value: 'thePheasant', label: 'Фазан' },
|
93
|
+
{ value: 'fullText', label: 'Каждый охотник желает знать, где сидит фазан' },
|
94
|
+
];
|
95
|
+
|
96
|
+
return (
|
97
|
+
<section>
|
98
|
+
<ModalsProvider>
|
99
|
+
<Button text="Open modal" onClick={() => setIsOpenA(true)} />
|
100
|
+
|
101
|
+
<Modal style=\{{ "height": "20rem" }} id="modalA" isOpen={isOpenA} onClose={onCloseA}>
|
102
|
+
<H3>Фильтр</H3>
|
103
|
+
<Select
|
104
|
+
value={value}
|
105
|
+
onChange={setValue}
|
106
|
+
items={items}
|
107
|
+
listHeight={11}
|
108
|
+
listOverflow="scroll"
|
109
|
+
/>
|
110
|
+
</Modal>
|
111
|
+
</ModalsProvider>
|
112
|
+
</section>
|
113
|
+
);
|
114
|
+
}
|
115
|
+
```
|
@@ -0,0 +1,103 @@
|
|
1
|
+
---
|
2
|
+
id: skeleton
|
3
|
+
title: Skeleton
|
4
|
+
---
|
5
|
+
|
6
|
+
import { PropsTable, Description } from '@site/src/components';
|
7
|
+
|
8
|
+
# Skeleton
|
9
|
+
Набор компонентов для создания скелетов загрузки (плейсхолдеров).
|
10
|
+
|
11
|
+
## LineSkeleton
|
12
|
+
<Description name="LineSkeleton" />
|
13
|
+
<PropsTable name="LineSkeleton" />
|
14
|
+
|
15
|
+
```tsx live
|
16
|
+
import React from 'react';
|
17
|
+
import { LineSkeleton } from '@salutejs/{{ package }}';
|
18
|
+
|
19
|
+
export function App() {
|
20
|
+
return (
|
21
|
+
<LineSkeleton size="headline3" />
|
22
|
+
);
|
23
|
+
}
|
24
|
+
```
|
25
|
+
|
26
|
+
## RectSkeleton
|
27
|
+
<Description name="RectSkeleton" />
|
28
|
+
<PropsTable name="RectSkeleton" />
|
29
|
+
|
30
|
+
```tsx live
|
31
|
+
import React from 'react';
|
32
|
+
import { RectSkeleton } from '@salutejs/{{ package }}';
|
33
|
+
|
34
|
+
export function App() {
|
35
|
+
return (
|
36
|
+
<RectSkeleton width="12rem" height="8rem" />
|
37
|
+
);
|
38
|
+
}
|
39
|
+
```
|
40
|
+
|
41
|
+
## TextSkeleton
|
42
|
+
<Description name="TextSkeleton" />
|
43
|
+
<PropsTable name="TextSkeleton" />
|
44
|
+
|
45
|
+
```tsx live
|
46
|
+
import React from 'react';
|
47
|
+
import { TextSkeleton } from '@salutejs/{{ package }}';
|
48
|
+
|
49
|
+
export function App() {
|
50
|
+
return (
|
51
|
+
<TextSkeleton size="paragraph1" lines={4} />
|
52
|
+
);
|
53
|
+
}
|
54
|
+
```
|
55
|
+
## На примере карточки
|
56
|
+
|
57
|
+
```tsx live
|
58
|
+
import React from 'react';
|
59
|
+
import { Button, withSkeleton } from '@salutejs/{{ package }}';
|
60
|
+
|
61
|
+
export function App() {
|
62
|
+
const ButtonSkeleton = withSkeleton(Button);
|
63
|
+
|
64
|
+
return (
|
65
|
+
<ButtonSkeleton
|
66
|
+
fullWidth
|
67
|
+
text="Загрузка..."
|
68
|
+
view="primary"
|
69
|
+
size="s"
|
70
|
+
scaleOnInteraction={false}
|
71
|
+
outlined={false}
|
72
|
+
skeleton={true}
|
73
|
+
tabIndex={-1}
|
74
|
+
/>
|
75
|
+
);
|
76
|
+
}
|
77
|
+
```
|
78
|
+
|
79
|
+
## Доступность
|
80
|
+
При использование хока `withSkeleton` необходимо воспользоваться атрибутами WAI ARIA. Пример с кнопкой:
|
81
|
+
|
82
|
+
```tsx
|
83
|
+
import React, { useState } from 'react';
|
84
|
+
import { Button } from '@salutejs/{{ package }}';
|
85
|
+
|
86
|
+
const ButtonSkeleton = withSkeleton<ButtonProps & WithSkeletonProps>(BasicButton);
|
87
|
+
|
88
|
+
export default function App () {
|
89
|
+
const [skeleton, setSkeleton] = useState(false);
|
90
|
+
|
91
|
+
return (
|
92
|
+
<ButtonSkeleton
|
93
|
+
type="button"
|
94
|
+
text={skeleton ? 'Загрузка' : 'Нажмите'}
|
95
|
+
skeleton={skeleton}
|
96
|
+
aria-busy={skeleton}
|
97
|
+
onClick={() => setSkeleton((prevValue) => !prevValue)}
|
98
|
+
/>
|
99
|
+
);
|
100
|
+
}
|
101
|
+
```
|
102
|
+
|
103
|
+
Таким образом, при `skeleton=true` и `aria-busy=true` скринридер будет оповещать о соответствующем статусе компонента.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
id: spinner
|
3
|
+
title: Spinner
|
4
|
+
---
|
5
|
+
|
6
|
+
import { PropsTable, Description } from '@site/src/components';
|
7
|
+
|
8
|
+
# Spinner
|
9
|
+
<Description name="Spinner" />
|
10
|
+
<PropsTable name="Spinner" exclude={['css', 'focused']}/>
|
11
|
+
|
12
|
+
```tsx live
|
13
|
+
import React from 'react';
|
14
|
+
import { Spinner } from '@salutejs/{{ package }}';
|
15
|
+
|
16
|
+
export function App() {
|
17
|
+
return (
|
18
|
+
<Spinner size={32} />
|
19
|
+
);
|
20
|
+
}
|
21
|
+
```
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
id: switch
|
3
|
+
title: Switch
|
4
|
+
---
|
5
|
+
|
6
|
+
import { PropsTable, Description } from '@site/src/components';
|
7
|
+
|
8
|
+
# Switch
|
9
|
+
<Description name="Switch" />
|
10
|
+
<PropsTable name="Switch" />
|
11
|
+
|
12
|
+
## Использование
|
13
|
+
Компонент `Switch` может содержать лейбл.
|
14
|
+
|
15
|
+
```tsx live
|
16
|
+
import React from 'react';
|
17
|
+
import { Switch } from '@salutejs/{{ package }}';
|
18
|
+
|
19
|
+
export function App() {
|
20
|
+
return (
|
21
|
+
<Switch label="Переключатель" defaultChecked />
|
22
|
+
);
|
23
|
+
}
|
24
|
+
```
|