@meduza/ui-kit-2 0.8.628 → 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 (46) hide show
  1. package/dist/ListViewSwitcher/ListViewSwitcher.types.d.ts +6 -0
  2. package/dist/ListViewSwitcher/index.d.ts +3 -0
  3. package/dist/Meta/Meta.types.d.ts +0 -1
  4. package/dist/RawHtmlBlock/RawHtmlBlock.types.d.ts +0 -1
  5. package/dist/RenderBlocks/RenderBlocks.types.d.ts +0 -1
  6. package/dist/SvgSymbol/SvgSymbol.types.d.ts +1 -1
  7. package/dist/Switcher/Switcher.types.d.ts +2 -3
  8. package/dist/ToolbarButton/ToolbarButton.types.d.ts +1 -1
  9. package/dist/index.d.ts +1 -0
  10. package/dist/types.d.ts +1 -1
  11. package/dist/ui-kit-2.cjs.development.js +360 -370
  12. package/dist/ui-kit-2.cjs.development.js.map +1 -1
  13. package/dist/ui-kit-2.cjs.production.min.js +1 -1
  14. package/dist/ui-kit-2.cjs.production.min.js.map +1 -1
  15. package/dist/ui-kit-2.esm.js +360 -371
  16. package/dist/ui-kit-2.esm.js.map +1 -1
  17. package/dist/ui-kit-game.css +138 -47
  18. package/dist/ui-kit.css +138 -47
  19. package/package.json +1 -1
  20. package/src/EmbedBlock/EmbedBlock.module.css +9 -0
  21. package/src/EmbedBlock/EmbedBlock.tsx +15 -4
  22. package/src/Image/index.tsx +1 -4
  23. package/src/ListViewSwitcher/ListViewSwitcher.module.css +109 -0
  24. package/src/ListViewSwitcher/ListViewSwitcher.stories.module.css +6 -0
  25. package/src/ListViewSwitcher/ListViewSwitcher.stories.tsx +38 -0
  26. package/src/ListViewSwitcher/ListViewSwitcher.test.tsx +35 -0
  27. package/src/ListViewSwitcher/ListViewSwitcher.types.ts +7 -0
  28. package/src/ListViewSwitcher/index.tsx +30 -0
  29. package/src/Meta/Meta.module.css +0 -16
  30. package/src/Meta/Meta.types.ts +0 -1
  31. package/src/Meta/MetaContainer.tsx +0 -27
  32. package/src/RawHtmlBlock/RawHtmlBlock.types.ts +0 -1
  33. package/src/RawHtmlBlock/index.tsx +1 -3
  34. package/src/RenderBlocks/RenderBlocks.types.ts +0 -1
  35. package/src/RenderBlocks/index.tsx +1 -3
  36. package/src/Spoiler/Spoiler.module.css +10 -9
  37. package/src/SvgSymbol/SvgSymbol.types.ts +0 -2
  38. package/src/Switcher/Switcher.module.css +4 -21
  39. package/src/Switcher/Switcher.stories.module.css +3 -21
  40. package/src/Switcher/Switcher.stories.tsx +13 -32
  41. package/src/Switcher/Switcher.types.ts +2 -4
  42. package/src/Switcher/index.tsx +7 -7
  43. package/src/ToolbarButton/ToolbarButton.types.ts +0 -2
  44. package/src/_storybook/PreviewWrapper/index.tsx +0 -1
  45. package/src/index.tsx +1 -0
  46. package/src/types.ts +0 -3
@@ -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,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
+ )
@@ -1,19 +1,3 @@
1
- /* .containerInDynamicBlock {
2
- position: absolute;
3
- bottom: 20px;
4
- left: 57px;
5
- width: auto;
6
- } */
7
-
8
- /* .containerInDynamicBlockAndMaterial {
9
- left: 65px;
10
-
11
- @media $landscapeTablet {
12
- left: auto;
13
- bottom: 35px;
14
- }
15
- } */
16
-
17
1
  .root {
18
2
  font-size: 12px;
19
3
 
@@ -10,7 +10,6 @@ export interface MetaContainerProps {
10
10
  bookmarkAction?: (service: CallToActions, place: string) => void
11
11
  lightBox?: () => void
12
12
  lang: 'ru' | 'en'
13
- type?: any
14
13
  }
15
14
 
16
15
  export interface MetaProps {
@@ -9,7 +9,6 @@ import { DocumentItemsCount } from '../DocumentItemsCount'
9
9
  import { BookmarkButton } from '../BookmarkButton'
10
10
  import { Timestamp } from '../Timestamp'
11
11
  import { SvgSymbol } from '../SvgSymbol'
12
- // import { makeClassName, ClassNames } from '../utils/makeClassName'
13
12
 
14
13
  import { TimestampProps } from '../Timestamp/Timestamp.types'
15
14
 
@@ -26,7 +25,6 @@ export const MetaContainer: React.FC<MetaContainerProps> = ({
26
25
  data: { components, theme }
27
26
  },
28
27
  styleContext
29
- // type
30
28
  }) => {
31
29
  const themeColor =
32
30
  styleContext && styleContext.indexOf('dark') !== -1 ? 'light' : 'unset'
@@ -43,19 +41,7 @@ export const MetaContainer: React.FC<MetaContainerProps> = ({
43
41
 
44
42
  const hasSource = !!components.find((item) => item.type === 'source_name')
45
43
 
46
- // const classNames: ClassNames = [
47
- // [
48
- // styles.containerInDynamicBlock,
49
- // styleContext === 'isInDynamicBlock' || styleContext.includes('episode')
50
- // ],
51
- // [
52
- // styles.containerInDynamicBlockAndMaterial,
53
- // styleContext === 'isInDynamicBlock' && type === 'isInMaterial'
54
- // ]
55
- // ]
56
-
57
44
  return (
58
- // <div className={makeClassName(classNames)}>
59
45
  <Meta
60
46
  styleContext={context}
61
47
  theme={theme || themeColor}
@@ -84,13 +70,6 @@ export const MetaContainer: React.FC<MetaContainerProps> = ({
84
70
  )
85
71
  }
86
72
  case 'duration': {
87
- // if (styleContext === 'isInDynamicBlock') {
88
- // return (
89
- // <MetaItem hasSource={hasSource} bullets key={component.id}>
90
- // {component.text}
91
- // </MetaItem>
92
- // )
93
- // }
94
73
  return (
95
74
  <MetaItem hasSource={hasSource} bullets key={component.id}>
96
75
  <>
@@ -115,11 +94,6 @@ export const MetaContainer: React.FC<MetaContainerProps> = ({
115
94
  >
116
95
  <Timestamp
117
96
  publishedAt={component.datetime}
118
- // type={
119
- // styleContext === 'isInDynamicBlock'
120
- // ? 'fromNow'
121
- // : format || 'date'
122
- // }
123
97
  type={format || 'date'}
124
98
  locale={lang}
125
99
  />
@@ -192,6 +166,5 @@ export const MetaContainer: React.FC<MetaContainerProps> = ({
192
166
  </div>
193
167
  )}
194
168
  </Meta>
195
- // </div>
196
169
  )
197
170
  }
@@ -17,5 +17,4 @@ export interface RawHtmlBlockProps {
17
17
  bookmarkAction?: (service: CallToActions, place: string) => void
18
18
  lightBox?: LightboxContext | null | undefined
19
19
  lang?: 'ru' | 'en'
20
- type?: any
21
20
  }
@@ -18,8 +18,7 @@ export const RawHtmlBlock: React.FC<RawHtmlBlockProps> = ({
18
18
  isInBookmarks,
19
19
  bookmarkAction,
20
20
  lightBox,
21
- lang,
22
- type = 'default'
21
+ lang
23
22
  }) => {
24
23
  const context = {
25
24
  lightBox: lightBox || null
@@ -69,7 +68,6 @@ export const RawHtmlBlock: React.FC<RawHtmlBlockProps> = ({
69
68
  isInBookmarks={isInBookmarks}
70
69
  bookmarkAction={bookmarkAction}
71
70
  lang={lang}
72
- type={type}
73
71
  />
74
72
  </BlockProvider>
75
73
  )
@@ -10,5 +10,4 @@ export interface RenderBlocksProps {
10
10
  bookmarkAction?: (service: CallToActions, place: string) => void
11
11
  lightBox?: LightboxContext | null | undefined
12
12
  lang?: 'ru' | 'en'
13
- type?: any
14
13
  }
@@ -27,8 +27,7 @@ export const RenderBlocks: React.FC<RenderBlocksProps> = ({
27
27
  isRead,
28
28
  isListened,
29
29
  bookmarkAction,
30
- isInBookmarks,
31
- type = 'default'
30
+ isInBookmarks
32
31
  }) => {
33
32
  switch (block.type) {
34
33
  case 'tag': {
@@ -62,7 +61,6 @@ export const RenderBlocks: React.FC<RenderBlocksProps> = ({
62
61
  isListened={isListened}
63
62
  isInBookmarks={isInBookmarks}
64
63
  bookmarkAction={bookmarkAction}
65
- type={type}
66
64
  />
67
65
  )
68
66
  }
@@ -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'