@meduza/ui-kit-2 0.8.629 → 0.8.690

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.
Files changed (36) hide show
  1. package/dist/ListViewSwitcher/ListViewSwitcher.types.d.ts +6 -0
  2. package/dist/ListViewSwitcher/index.d.ts +3 -0
  3. package/dist/SvgSymbol/SvgSymbol.types.d.ts +1 -1
  4. package/dist/Switcher/Switcher.types.d.ts +2 -3
  5. package/dist/ToolbarButton/ToolbarButton.types.d.ts +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/types.d.ts +1 -1
  8. package/dist/ui-kit-2.cjs.development.js +254 -232
  9. package/dist/ui-kit-2.cjs.development.js.map +1 -1
  10. package/dist/ui-kit-2.cjs.production.min.js +1 -1
  11. package/dist/ui-kit-2.cjs.production.min.js.map +1 -1
  12. package/dist/ui-kit-2.esm.js +254 -233
  13. package/dist/ui-kit-2.esm.js.map +1 -1
  14. package/dist/ui-kit-game.css +138 -31
  15. package/dist/ui-kit.css +138 -31
  16. package/package.json +1 -1
  17. package/src/EmbedBlock/EmbedBlock.module.css +9 -0
  18. package/src/EmbedBlock/EmbedBlock.tsx +15 -4
  19. package/src/Image/index.tsx +1 -4
  20. package/src/ListViewSwitcher/ListViewSwitcher.module.css +109 -0
  21. package/src/ListViewSwitcher/ListViewSwitcher.stories.module.css +6 -0
  22. package/src/ListViewSwitcher/ListViewSwitcher.stories.tsx +38 -0
  23. package/src/ListViewSwitcher/ListViewSwitcher.test.tsx +35 -0
  24. package/src/ListViewSwitcher/ListViewSwitcher.types.ts +7 -0
  25. package/src/ListViewSwitcher/index.tsx +30 -0
  26. package/src/Spoiler/Spoiler.module.css +10 -9
  27. package/src/SvgSymbol/SvgSymbol.types.ts +0 -2
  28. package/src/Switcher/Switcher.module.css +4 -21
  29. package/src/Switcher/Switcher.stories.module.css +3 -21
  30. package/src/Switcher/Switcher.stories.tsx +13 -32
  31. package/src/Switcher/Switcher.types.ts +2 -4
  32. package/src/Switcher/index.tsx +7 -7
  33. package/src/ToolbarButton/ToolbarButton.types.ts +0 -2
  34. package/src/_storybook/PreviewWrapper/index.tsx +0 -1
  35. package/src/index.tsx +1 -0
  36. package/src/types.ts +0 -3
@@ -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,7 @@
1
+ import React from 'react'
2
+
3
+ export interface ListViewSwitcherProps {
4
+ enabled: boolean
5
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
6
+ size?: 'sm' | 'md'
7
+ }
@@ -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
+ )
@@ -61,17 +61,16 @@
61
61
  margin-top: 0;
62
62
  margin-bottom: 18px;
63
63
 
64
- font-weight: 700;
65
- font-size: 21px;
66
-
67
64
  font-family: $secondaryFont;
68
- line-height: 26px;
65
+ font-size: calc(17rem / 16);
66
+ font-weight: 700;
67
+ line-height: calc(21rem / 16);
69
68
 
70
69
  @media $mobile {
71
70
  margin-bottom: 20px;
72
71
 
73
- font-size: 28px;
74
- line-height: 34px;
72
+ font-size: 21px;
73
+ line-height: 28px;
75
74
  }
76
75
  }
77
76
 
@@ -120,9 +119,11 @@
120
119
  margin-left: -20px;
121
120
  padding: 12px 20px 20px;
122
121
 
123
- background-image: linear-gradient(180deg,
124
- rgba(255, 255, 255, 0) 0%,
125
- #fff 64%);
122
+ background-image: linear-gradient(
123
+ 180deg,
124
+ rgba(255, 255, 255, 0) 0%,
125
+ #fff 64%
126
+ );
126
127
 
127
128
  animation: spoilerSticky 500ms ease both;
128
129
 
@@ -20,8 +20,6 @@ export type Icons =
20
20
  | 'menu'
21
21
  | 'fb'
22
22
  | 'tw'
23
- | 'vk'
24
- | 'ok'
25
23
  | 'tg'
26
24
  | 'chat'
27
25
  | 'magic'
@@ -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 .children {
120
- margin-right: 8px;
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: row wrap;
17
-
18
- padding: 15px;
19
- }
3
+ flex-flow: column wrap;
20
4
 
21
- .row[data-theme='dark'] {
22
- color: #fff;
5
+ font-size: 16px;
23
6
 
24
- background: #262626;
25
- border-radius: 10px;
7
+ gap: 24px;
26
8
  }
@@ -14,43 +14,24 @@ export default {
14
14
 
15
15
  const Example: React.FC = () => {
16
16
  const [enabledOne, setEnabledOne] = useState(false)
17
- const [enabledTwo, setEnabledTwo] = useState(false)
18
17
  const [enabledThree, setEnabledThree] = useState(false)
19
18
 
20
19
  return (
21
20
  <>
22
21
  <div className={styles.root}>
23
- <div className={styles.preview}>
24
- <Switcher
25
- enabled={enabledOne}
26
- styleContext="isInPanel"
27
- onChange={(e) => setEnabledOne(e.target.checked)}
28
- >
29
- <span>Показывать по порядку</span>
30
- </Switcher>
31
- </div>
32
- <div className={styles.preview}>
33
- <div className={styles.row} data-theme="dark">
34
- <Switcher
35
- enabled={enabledTwo}
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>
22
+ <Switcher
23
+ enabled={enabledOne}
24
+ styleContext="isInPanel"
25
+ onChange={(e) => setEnabledOne(e.target.checked)}
26
+ childrenLeft={<span>Показывать по порядку</span>}
27
+ />
28
+
29
+ <Switcher
30
+ enabled={enabledThree}
31
+ styleContext="isInLive"
32
+ onChange={(e) => setEnabledThree(e.target.checked)}
33
+ childrenRight={<span>Перевернуть трансляцию</span>}
34
+ />
54
35
  </div>
55
36
  </>
56
37
  )
@@ -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
- children: JSX.Element[] | JSX.Element
15
- childrenPosition?: SwitcherChildrenPositions
12
+ childrenLeft?: JSX.Element
13
+ childrenRight?: JSX.Element
16
14
  }
@@ -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
- {children && childrenPosition === 'left' && (
22
+ {childrenLeft && (
23
23
  <div
24
24
  className={makeClassName([
25
25
  [styles.children, true],
26
26
  [styles.left, true]
27
27
  ])}
28
28
  >
29
- {children}
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
- {children && childrenPosition === 'right' && (
41
+ {childrenRight && (
42
42
  <div
43
43
  className={makeClassName([
44
44
  [styles.children, true],
45
45
  [styles.right, true]
46
46
  ])}
47
47
  >
48
- {children}
48
+ {childrenRight}
49
49
  </div>
50
50
  )}
51
51
  </label>
@@ -1,9 +1,7 @@
1
1
  export type ToolbarButtonTypes =
2
- | 'vk'
3
2
  | 'fb'
4
3
  | 'tw'
5
4
  | 'tg'
6
- | 'ok'
7
5
  | 'reaction'
8
6
  | 'pdf'
9
7
  | 'bookmark'
@@ -17,7 +17,6 @@ export const PreviewWrapper: React.FC<PreviewWrapperProps> = ({
17
17
  [styles[theme], !!theme]
18
18
  ])}
19
19
  >
20
- <h2>{theme === 'dark' ? 'Dark theme' : 'Light theme'}</h2>
21
20
  {children}
22
21
  </div>
23
22
  )
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'
package/src/types.ts CHANGED
@@ -8,10 +8,7 @@ export interface OptimizedImageItem {
8
8
  export type CallToActions =
9
9
  | 'fb'
10
10
  | 'tw'
11
- | 'vk'
12
- | 'ok'
13
11
  | 'tg'
14
- | 'wp'
15
12
  | 'reaction'
16
13
  | 'pdf'
17
14
  | 'bookmark'