@meduza/ui-kit-2 0.8.5 → 0.8.7
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/AnnouncementInText/AnnouncementInText.types.d.ts +4 -0
- package/dist/AnnouncementInText/index.d.ts +3 -0
- package/dist/BookmarkButton/BookmarkButton.types.d.ts +6 -0
- package/dist/BookmarkButton/index.d.ts +3 -0
- package/dist/Button/Button.types.d.ts +16 -0
- package/dist/Button/ButtonLoader.d.ts +2 -0
- package/dist/Button/index.d.ts +2 -0
- package/dist/CardTitle/CardTitle.types.d.ts +11 -0
- package/dist/CardTitle/index.d.ts +3 -0
- package/dist/ChapterBlock/ChapterBlock.types.d.ts +8 -0
- package/dist/ChapterBlock/index.d.ts +3 -0
- package/dist/Cover/Cover.types.d.ts +24 -0
- package/dist/Cover/index.d.ts +3 -0
- package/dist/DocumentItemsCount/DocumentItemsCount.types.d.ts +6 -0
- package/dist/DocumentItemsCount/index.d.ts +3 -0
- package/dist/DonatesTeaser/DonatesTeaser.types.d.ts +4 -0
- package/dist/DonatesTeaser/index.d.ts +3 -0
- package/dist/DotsOnImage/DotsOnImage.types.d.ts +46 -0
- package/dist/DotsOnImage/index.d.ts +3 -0
- package/dist/Dropdown/Dropdown.types.d.ts +5 -0
- package/dist/Dropdown/index.d.ts +4 -0
- package/dist/EmbedBlock/EmbedBlock.d.ts +3 -0
- package/dist/EmbedBlock/EmbedBlock.types.d.ts +12 -0
- package/dist/EmbedBlock/EmbedGif.d.ts +3 -0
- package/dist/EmbedBlock/IframeBlock.d.ts +3 -0
- package/dist/EmbedBlock/index.d.ts +3 -0
- package/dist/Footnote/Footnote.types.d.ts +5 -0
- package/dist/Footnote/index.d.ts +3 -0
- package/dist/GroupedBlock/GroupedBlock.types.d.ts +4 -0
- package/dist/GroupedBlock/index.d.ts +3 -0
- package/dist/HalfBlock/HalfBlock.types.d.ts +4 -0
- package/dist/HalfBlock/index.d.ts +3 -0
- package/dist/Image/Image.types.d.ts +35 -0
- package/dist/Image/RenderPicture.d.ts +4 -0
- package/dist/ImportantLead/ImportantLead.types.d.ts +4 -0
- package/dist/ImportantLead/index.d.ts +3 -0
- package/dist/Lazy/Lazy.types.d.ts +4 -0
- package/dist/ListBlock/ListBlock.types.d.ts +9 -0
- package/dist/ListBlock/index.d.ts +3 -0
- package/dist/ListViewSwitcher/ListViewSwitcher.types.d.ts +6 -0
- package/dist/ListViewSwitcher/index.d.ts +3 -0
- package/dist/MaterialNote/MaterialNote.types.d.ts +13 -0
- package/dist/MaterialNote/index.d.ts +3 -0
- package/dist/MaterialTitle/MaterialTitle.types.d.ts +4 -0
- package/dist/MaterialTitle/index.d.ts +5 -0
- package/dist/MediaCaption/MediaCaption.types.d.ts +5 -0
- package/dist/MediaCaption/index.d.ts +3 -0
- package/dist/Meta/Meta.mock.d.ts +12 -0
- package/dist/Meta/Meta.types.d.ts +19 -0
- package/dist/Meta/MetaContainer.d.ts +3 -0
- package/dist/Meta/index.d.ts +3 -0
- package/dist/MetaItem/MetaItem.types.d.ts +7 -0
- package/dist/MetaItem/index.d.ts +3 -0
- package/dist/MetaItemLive/MetaItemLive.types.d.ts +3 -0
- package/dist/MetaItemLive/index.d.ts +3 -0
- package/dist/Popover/Popover.types.d.ts +5 -0
- package/dist/Popover/index.d.ts +3 -0
- package/dist/QuoteBlock/QuoteBlock.types.d.ts +6 -0
- package/dist/QuoteBlock/index.d.ts +3 -0
- package/dist/RawHtmlBlock/RawHtmlBlock.types.d.ts +17 -0
- package/dist/RawHtmlBlock/index.d.ts +3 -0
- package/dist/RelatedBlock/RelatedBlock.types.d.ts +17 -0
- package/dist/RelatedBlock/index.d.ts +3 -0
- package/dist/RelatedBook/RelatedBook.mock.d.ts +65 -0
- package/dist/RelatedBook/RelatedBook.types.d.ts +4 -0
- package/dist/RelatedBook/index.d.ts +3 -0
- package/dist/RelatedRichBlock/RelatedRichBlock.types.d.ts +4 -0
- package/dist/RelatedRichBlock/index.d.ts +3 -0
- package/dist/RenderBlocks/RenderBlocks.types.d.ts +11 -0
- package/dist/RenderBlocks/index.d.ts +3 -0
- package/dist/RichTitle/RichTitle.types.d.ts +12 -0
- package/dist/RichTitle/index.d.ts +3 -0
- package/dist/SensitiveBlock/SensitiveBlock.types.d.ts +15 -0
- package/dist/SensitiveBlock/index.d.ts +3 -0
- package/dist/ShopRelatedBlock/ShopRelatedBlock.types.d.ts +4 -0
- package/dist/ShopRelatedBlock/index.d.ts +3 -0
- package/dist/SimpleBlock/SimpleBlock.types.d.ts +5 -0
- package/dist/SimpleBlock/index.d.ts +3 -0
- package/dist/SimpleTitle/SimpleTitle.types.d.ts +9 -0
- package/dist/SimpleTitle/index.d.ts +3 -0
- package/dist/SourceBlock/SourceBlock.types.d.ts +15 -0
- package/dist/SourceBlock/index.d.ts +3 -0
- package/dist/Spoiler/Spoiler.types.d.ts +4 -0
- package/dist/Spoiler/index.d.ts +3 -0
- package/dist/SvgSymbol/SvgSymbol.types.d.ts +8 -0
- package/dist/SvgSymbol/icons.d.ts +167 -0
- package/dist/Switcher/Switcher.types.d.ts +11 -0
- package/dist/Table/Table.types.d.ts +25 -0
- package/dist/Table/index.d.ts +3 -0
- package/dist/Tag/Tag.types.d.ts +12 -0
- package/dist/Tag/index.d.ts +3 -0
- package/dist/Timestamp/Timestamp.types.d.ts +5 -0
- package/dist/Timestamp/index.d.ts +4 -0
- package/dist/Toolbar/Toolbar.d.ts +3 -0
- package/dist/Toolbar/Toolbar.types.d.ts +7 -0
- package/dist/Toolbar/ToolbarItem.d.ts +3 -0
- package/dist/Toolbar/index.d.ts +2 -0
- package/dist/ToolbarButton/ToolbarButton.types.d.ts +10 -0
- package/dist/ToolbarButton/index.d.ts +3 -0
- package/dist/Tooltip/Tooltip.d.ts +3 -0
- package/dist/Tooltip/Tooltip.types.d.ts +8 -0
- package/dist/Tooltip/TooltipFooter.d.ts +3 -0
- package/dist/Tooltip/index.d.ts +2 -0
- package/dist/VersesBlock/VersesBlock.types.d.ts +9 -0
- package/dist/VersesBlock/index.d.ts +3 -0
- package/dist/constants.d.ts +41 -0
- package/dist/index.d.ts +46 -0
- package/dist/types.d.ts +20 -0
- package/dist/ui-kit-2.cjs.development.js +2833 -0
- package/dist/ui-kit-2.cjs.development.js.map +1 -0
- package/dist/ui-kit-2.cjs.production.min.js +2 -0
- package/dist/ui-kit-2.cjs.production.min.js.map +1 -0
- package/dist/ui-kit-2.esm.js +2778 -0
- package/dist/ui-kit-2.esm.js.map +1 -0
- package/dist/ui-kit-game.css +7161 -0
- package/dist/ui-kit.css +7161 -0
- package/dist/utils/BlockContext.d.ts +8 -0
- package/dist/utils/DangerousHtml.d.ts +8 -0
- package/dist/utils/capitalizeFirstLetter.d.ts +1 -0
- package/dist/utils/converCase.d.ts +2 -0
- package/dist/utils/generateGradient.d.ts +2 -0
- package/dist/utils/getElementPositionRelativeToViewport.d.ts +2 -0
- package/dist/utils/makeStyleContext.d.ts +3 -0
- package/dist/utils/pluralize.d.ts +2 -0
- package/dist/utils/postMessage.d.ts +2 -0
- package/dist/utils/viewportSize.d.ts +6 -0
- package/package.json +1 -1
- package/src/ListViewSwitcher/ListViewSwitcher.module.css +109 -0
- package/src/ListViewSwitcher/ListViewSwitcher.stories.module.css +6 -0
- package/src/ListViewSwitcher/ListViewSwitcher.stories.tsx +38 -0
- package/src/ListViewSwitcher/ListViewSwitcher.test.tsx +35 -0
- package/src/ListViewSwitcher/ListViewSwitcher.types.ts +7 -0
- package/src/ListViewSwitcher/index.tsx +30 -0
- package/src/Switcher/Switcher.module.css +4 -21
- package/src/Switcher/Switcher.stories.module.css +3 -21
- package/src/Switcher/Switcher.stories.tsx +13 -31
- package/src/Switcher/Switcher.types.ts +2 -4
- package/src/Switcher/index.tsx +7 -7
- package/src/_storybook/PreviewWrapper/index.tsx +0 -1
- package/src/index.tsx +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const capitalizeFirstLetter: (string: string) => string;
|
package/package.json
CHANGED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
position: relative;
|
|
3
|
+
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
flex-flow: row nowrap;
|
|
7
|
+
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
user-select: none;
|
|
10
|
+
|
|
11
|
+
border-radius: 40px;
|
|
12
|
+
background-color: #fff;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.input {
|
|
16
|
+
position: absolute;
|
|
17
|
+
top: 0;
|
|
18
|
+
left: 0;
|
|
19
|
+
|
|
20
|
+
visibility: hidden;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.knob {
|
|
24
|
+
position: relative;
|
|
25
|
+
z-index: $zIndex-2;
|
|
26
|
+
|
|
27
|
+
display: block;
|
|
28
|
+
|
|
29
|
+
transition: 0.25s ease-in-out;
|
|
30
|
+
|
|
31
|
+
border-radius: 15px;
|
|
32
|
+
background: #000;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.sm {
|
|
36
|
+
width: 35px;
|
|
37
|
+
height: 18px;
|
|
38
|
+
padding: 2px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.md {
|
|
42
|
+
width: 52px;
|
|
43
|
+
height: 26px;
|
|
44
|
+
padding: 2px 3px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.md .knob {
|
|
48
|
+
width: 22px;
|
|
49
|
+
height: 22px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.grid,
|
|
53
|
+
.list {
|
|
54
|
+
position: absolute;
|
|
55
|
+
|
|
56
|
+
background-size: contain;
|
|
57
|
+
background-repeat: no-repeat;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.grid {
|
|
61
|
+
background-image: url("data:image/svg+xml,%3Csvg width='13' height='13' viewBox='0 0 13 13' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='.359' y='.5' width='5.42' height='5.42' rx='1.044' fill='%23000'/%3E%3Crect x='.359' y='7.078' width='5.42' height='5.42' rx='1.044' fill='%23000'/%3E%3Crect x='6.938' y='.5' width='5.42' height='5.42' rx='1.044' fill='%23000'/%3E%3Crect x='6.938' y='7.078' width='5.42' height='5.42' rx='1.044' fill='%23000'/%3E%3C/svg%3E");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.list {
|
|
65
|
+
background-image: url("data:image/svg+xml,%3Csvg width='13' height='13' viewBox='0 0 13 13' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='.359' y='.5' width='12' height='3' rx='1.044' fill='%23000'/%3E%3Crect x='.359' y='5' width='12' height='3' rx='1.044' fill='%23000'/%3E%3Crect x='.359' y='9.5' width='12' height='3' rx='1.044' fill='%23000'/%3E%3C/svg%3E");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.md .input:checked ~ .knob {
|
|
69
|
+
transform: translateX(24px);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.md .grid,
|
|
73
|
+
.md .list {
|
|
74
|
+
width: 13px;
|
|
75
|
+
height: 13px;
|
|
76
|
+
top: 7px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.md .grid {
|
|
80
|
+
left: 10px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.md .list {
|
|
84
|
+
right: 10px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.sm .grid {
|
|
88
|
+
left: 5px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.sm .list {
|
|
92
|
+
right: 5px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.sm .knob {
|
|
96
|
+
width: 14px;
|
|
97
|
+
height: 14px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.sm .grid,
|
|
101
|
+
.sm .list {
|
|
102
|
+
width: 8px;
|
|
103
|
+
height: 8px;
|
|
104
|
+
top: 5px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.sm .input:checked ~ .knob {
|
|
108
|
+
transform: translateX(16px);
|
|
109
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { ListViewSwitcher } from '.'
|
|
3
|
+
import { PreviewWrapper } from '../_storybook/PreviewWrapper'
|
|
4
|
+
|
|
5
|
+
import styles from './ListViewSwitcher.stories.module.css'
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Main / ListViewSwitcher',
|
|
9
|
+
component: ListViewSwitcher,
|
|
10
|
+
parameters: {
|
|
11
|
+
themeWrapperSideBySide: true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const Example: React.FC = () => {
|
|
16
|
+
const [enabledOne, setEnabledOne] = useState(false)
|
|
17
|
+
const [enabledTwo, setEnabledTwo] = useState(false)
|
|
18
|
+
return (
|
|
19
|
+
<div className={styles.root}>
|
|
20
|
+
<ListViewSwitcher
|
|
21
|
+
enabled={enabledOne}
|
|
22
|
+
size="sm"
|
|
23
|
+
onChange={(e) => setEnabledOne(e.target.checked)}
|
|
24
|
+
/>
|
|
25
|
+
<ListViewSwitcher
|
|
26
|
+
enabled={enabledTwo}
|
|
27
|
+
size="md"
|
|
28
|
+
onChange={(e) => setEnabledTwo(e.target.checked)}
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const Default: React.FC = () => (
|
|
35
|
+
<PreviewWrapper theme="dark">
|
|
36
|
+
<Example />
|
|
37
|
+
</PreviewWrapper>
|
|
38
|
+
)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render, fireEvent, RenderResult } from '@testing-library/react'
|
|
3
|
+
import { ListViewSwitcher } from '.'
|
|
4
|
+
import { ListViewSwitcherProps } from './ListViewSwitcher.types'
|
|
5
|
+
|
|
6
|
+
import styles from './Switcher.module.css'
|
|
7
|
+
|
|
8
|
+
describe('ListViewSwitcher', () => {
|
|
9
|
+
let props: ListViewSwitcherProps
|
|
10
|
+
|
|
11
|
+
const renderComponent = (): RenderResult =>
|
|
12
|
+
render(<ListViewSwitcher {...props} />)
|
|
13
|
+
|
|
14
|
+
it('should have root style', () => {
|
|
15
|
+
const { getByTestId } = renderComponent()
|
|
16
|
+
|
|
17
|
+
const switcher = getByTestId('listViewSwitcher')
|
|
18
|
+
|
|
19
|
+
expect(switcher).toHaveClass(styles.root)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('should check on click', () => {
|
|
23
|
+
let checked = false
|
|
24
|
+
const onChange = (e): void => (checked = e.target.checked)
|
|
25
|
+
const renderComponent = (): RenderResult =>
|
|
26
|
+
render(<ListViewSwitcher onChange={onChange} {...props} />)
|
|
27
|
+
const { getByTestId } = renderComponent()
|
|
28
|
+
|
|
29
|
+
const switcher = getByTestId('listViewSwitcher')
|
|
30
|
+
|
|
31
|
+
fireEvent.click(switcher)
|
|
32
|
+
|
|
33
|
+
expect(checked).toBe(true)
|
|
34
|
+
})
|
|
35
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { ListViewSwitcherProps } from './ListViewSwitcher.types'
|
|
3
|
+
import styles from './ListViewSwitcher.module.css'
|
|
4
|
+
import makeClassName from '../utils/makeClassName'
|
|
5
|
+
|
|
6
|
+
export const ListViewSwitcher: React.FC<ListViewSwitcherProps> = ({
|
|
7
|
+
enabled,
|
|
8
|
+
onChange,
|
|
9
|
+
size = 'md'
|
|
10
|
+
}) => (
|
|
11
|
+
<label
|
|
12
|
+
data-testid="listViewSwitcher"
|
|
13
|
+
className={makeClassName([
|
|
14
|
+
[styles.root, true],
|
|
15
|
+
[styles[size], true]
|
|
16
|
+
])}
|
|
17
|
+
>
|
|
18
|
+
<input
|
|
19
|
+
className={styles.input}
|
|
20
|
+
type="checkbox"
|
|
21
|
+
checked={enabled}
|
|
22
|
+
onChange={onChange}
|
|
23
|
+
/>
|
|
24
|
+
|
|
25
|
+
<span className={styles.knob} />
|
|
26
|
+
|
|
27
|
+
<span className={styles.grid} />
|
|
28
|
+
<span className={styles.list} />
|
|
29
|
+
</label>
|
|
30
|
+
)
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
cursor: pointer;
|
|
14
14
|
|
|
15
15
|
user-select: none;
|
|
16
|
+
|
|
17
|
+
gap: 6px;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
.dark {
|
|
@@ -93,31 +95,13 @@
|
|
|
93
95
|
left: 18px;
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
.children.left {
|
|
97
|
-
margin-right: 6px;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.children.right {
|
|
101
|
-
margin-left: 6px;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/* panel */
|
|
105
|
-
.isInPanel .children {
|
|
106
|
-
|
|
107
|
-
color: #999;
|
|
108
|
-
|
|
109
|
-
font-size: 13px;
|
|
110
|
-
letter-spacing: 0.5px;
|
|
111
|
-
text-transform: uppercase;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
98
|
/* menu */
|
|
115
99
|
.isInMenu {
|
|
116
100
|
font-weight: normal;
|
|
117
101
|
}
|
|
118
102
|
|
|
119
|
-
.isInMenu
|
|
120
|
-
|
|
103
|
+
.isInMenu {
|
|
104
|
+
gap: 8px;
|
|
121
105
|
}
|
|
122
106
|
|
|
123
107
|
.isInMenu .control {
|
|
@@ -143,7 +127,6 @@
|
|
|
143
127
|
|
|
144
128
|
/* live */
|
|
145
129
|
.isInLive .children {
|
|
146
|
-
|
|
147
130
|
color: #7f7f7f;
|
|
148
131
|
|
|
149
132
|
font-size: 13px;
|
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
.root {
|
|
2
|
-
display: block;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.preview {
|
|
6
|
-
display: inline-block;
|
|
7
|
-
width: 100%;
|
|
8
|
-
padding: 16px;
|
|
9
|
-
|
|
10
|
-
border: 1px #e8e8e8 solid;
|
|
11
|
-
border-radius: 3px;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.row {
|
|
15
2
|
display: flex;
|
|
16
|
-
flex-flow:
|
|
17
|
-
|
|
18
|
-
padding: 15px;
|
|
19
|
-
}
|
|
3
|
+
flex-flow: column wrap;
|
|
20
4
|
|
|
21
|
-
|
|
22
|
-
color: #fff;
|
|
5
|
+
font-size: 16px;
|
|
23
6
|
|
|
24
|
-
|
|
25
|
-
border-radius: 10px;
|
|
7
|
+
gap: 24px;
|
|
26
8
|
}
|
|
@@ -20,37 +20,19 @@ const Example: React.FC = () => {
|
|
|
20
20
|
return (
|
|
21
21
|
<>
|
|
22
22
|
<div className={styles.root}>
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
styleContext="isInMenu"
|
|
37
|
-
onChange={(e) => setEnabledTwo(e.target.checked)}
|
|
38
|
-
theme="dark"
|
|
39
|
-
>
|
|
40
|
-
<span>Показывать по порядку</span>
|
|
41
|
-
</Switcher>
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
<div className={styles.preview}>
|
|
45
|
-
<Switcher
|
|
46
|
-
enabled={enabledThree}
|
|
47
|
-
styleContext="isInLive"
|
|
48
|
-
onChange={(e) => setEnabledThree(e.target.checked)}
|
|
49
|
-
childrenPosition="right"
|
|
50
|
-
>
|
|
51
|
-
<span>Перевернуть трансляцию</span>
|
|
52
|
-
</Switcher>
|
|
53
|
-
</div>
|
|
23
|
+
<Switcher
|
|
24
|
+
enabled={enabledOne}
|
|
25
|
+
styleContext="isInPanel"
|
|
26
|
+
onChange={(e) => setEnabledOne(e.target.checked)}
|
|
27
|
+
childrenLeft={<span>Показывать по порядку</span>}
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
<Switcher
|
|
31
|
+
enabled={enabledThree}
|
|
32
|
+
styleContext="isInLive"
|
|
33
|
+
onChange={(e) => setEnabledThree(e.target.checked)}
|
|
34
|
+
childrenRight={<span>Перевернуть трансляцию</span>}
|
|
35
|
+
/>
|
|
54
36
|
</div>
|
|
55
37
|
</>
|
|
56
38
|
)
|
|
@@ -4,13 +4,11 @@ export type SwitcherStyleContexts = 'isInLive' | 'isInPanel' | 'isInMenu'
|
|
|
4
4
|
|
|
5
5
|
export type SwitcherThemes = 'light' | 'dark'
|
|
6
6
|
|
|
7
|
-
export type SwitcherChildrenPositions = 'left' | 'right'
|
|
8
|
-
|
|
9
7
|
export interface SwitcherProps {
|
|
10
8
|
enabled: boolean
|
|
11
9
|
styleContext: SwitcherStyleContexts
|
|
12
10
|
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
|
|
13
11
|
theme?: SwitcherThemes
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
childrenLeft?: JSX.Element
|
|
13
|
+
childrenRight?: JSX.Element
|
|
16
14
|
}
|
package/src/Switcher/index.tsx
CHANGED
|
@@ -5,11 +5,11 @@ import styles from './Switcher.module.css'
|
|
|
5
5
|
|
|
6
6
|
export const Switcher: React.FC<SwitcherProps> = ({
|
|
7
7
|
enabled,
|
|
8
|
-
children,
|
|
9
|
-
childrenPosition = 'left',
|
|
10
8
|
onChange,
|
|
11
9
|
styleContext,
|
|
12
|
-
theme = 'light'
|
|
10
|
+
theme = 'light',
|
|
11
|
+
childrenLeft,
|
|
12
|
+
childrenRight
|
|
13
13
|
}) => (
|
|
14
14
|
<label
|
|
15
15
|
data-testid="switcher"
|
|
@@ -19,14 +19,14 @@ export const Switcher: React.FC<SwitcherProps> = ({
|
|
|
19
19
|
[styles[styleContext], !!styles[styleContext]]
|
|
20
20
|
])}
|
|
21
21
|
>
|
|
22
|
-
{
|
|
22
|
+
{childrenLeft && (
|
|
23
23
|
<div
|
|
24
24
|
className={makeClassName([
|
|
25
25
|
[styles.children, true],
|
|
26
26
|
[styles.left, true]
|
|
27
27
|
])}
|
|
28
28
|
>
|
|
29
|
-
{
|
|
29
|
+
{childrenLeft}
|
|
30
30
|
</div>
|
|
31
31
|
)}
|
|
32
32
|
<input
|
|
@@ -38,14 +38,14 @@ export const Switcher: React.FC<SwitcherProps> = ({
|
|
|
38
38
|
<span className={styles.control}>
|
|
39
39
|
<span className={styles.knob} />
|
|
40
40
|
</span>
|
|
41
|
-
{
|
|
41
|
+
{childrenRight && (
|
|
42
42
|
<div
|
|
43
43
|
className={makeClassName([
|
|
44
44
|
[styles.children, true],
|
|
45
45
|
[styles.right, true]
|
|
46
46
|
])}
|
|
47
47
|
>
|
|
48
|
-
{
|
|
48
|
+
{childrenRight}
|
|
49
49
|
</div>
|
|
50
50
|
)}
|
|
51
51
|
</label>
|
package/src/index.tsx
CHANGED
|
@@ -26,6 +26,7 @@ export * from './HalfBlock'
|
|
|
26
26
|
export * from './RawHtmlBlock'
|
|
27
27
|
export * from './ImportantLead'
|
|
28
28
|
export * from './ListBlock'
|
|
29
|
+
export * from './ListViewSwitcher'
|
|
29
30
|
export * from './RelatedBlock'
|
|
30
31
|
export * from './RichTitle'
|
|
31
32
|
export * from './SimpleBlock'
|