@meduza/ui-kit-2 0.8.7 → 0.8.601

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 (37) hide show
  1. package/dist/SvgSymbol/SvgSymbol.types.d.ts +1 -1
  2. package/dist/SvgSymbol/icons.d.ts +5 -0
  3. package/dist/Switcher/Switcher.types.d.ts +3 -2
  4. package/dist/index.d.ts +0 -1
  5. package/dist/ui-kit-2.cjs.development.js +243 -254
  6. package/dist/ui-kit-2.cjs.development.js.map +1 -1
  7. package/dist/ui-kit-2.cjs.production.min.js +1 -1
  8. package/dist/ui-kit-2.cjs.production.min.js.map +1 -1
  9. package/dist/ui-kit-2.esm.js +244 -254
  10. package/dist/ui-kit-2.esm.js.map +1 -1
  11. package/dist/ui-kit-game.css +45 -126
  12. package/dist/ui-kit.css +45 -126
  13. package/package.json +1 -1
  14. package/src/Image/index.tsx +4 -1
  15. package/src/Meta/Meta.module.css +6 -0
  16. package/src/Meta/MetaContainer.tsx +12 -1
  17. package/src/RichTitle/RichTitle.module.css +4 -0
  18. package/src/Spoiler/Spoiler.module.css +9 -10
  19. package/src/SvgSymbol/SvgSymbol.types.ts +1 -0
  20. package/src/SvgSymbol/icons.ts +7 -0
  21. package/src/Switcher/Switcher.module.css +21 -4
  22. package/src/Switcher/Switcher.stories.module.css +21 -3
  23. package/src/Switcher/Switcher.stories.tsx +31 -13
  24. package/src/Switcher/Switcher.types.ts +4 -2
  25. package/src/Switcher/index.tsx +7 -7
  26. package/src/Tag/Tag.module.css +4 -0
  27. package/src/_storybook/PreviewWrapper/index.tsx +1 -0
  28. package/src/index.tsx +0 -1
  29. package/dist/ListViewSwitcher/ListViewSwitcher.types.d.ts +0 -6
  30. package/dist/ListViewSwitcher/index.d.ts +0 -3
  31. package/src/.DS_Store +0 -0
  32. package/src/ListViewSwitcher/ListViewSwitcher.module.css +0 -109
  33. package/src/ListViewSwitcher/ListViewSwitcher.stories.module.css +0 -6
  34. package/src/ListViewSwitcher/ListViewSwitcher.stories.tsx +0 -38
  35. package/src/ListViewSwitcher/ListViewSwitcher.test.tsx +0 -35
  36. package/src/ListViewSwitcher/ListViewSwitcher.types.ts +0 -7
  37. package/src/ListViewSwitcher/index.tsx +0 -30
@@ -20,19 +20,37 @@ const Example: React.FC = () => {
20
20
  return (
21
21
  <>
22
22
  <div className={styles.root}>
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
- />
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>
36
54
  </div>
37
55
  </>
38
56
  )
@@ -4,11 +4,13 @@ export type SwitcherStyleContexts = 'isInLive' | 'isInPanel' | 'isInMenu'
4
4
 
5
5
  export type SwitcherThemes = 'light' | 'dark'
6
6
 
7
+ export type SwitcherChildrenPositions = 'left' | 'right'
8
+
7
9
  export interface SwitcherProps {
8
10
  enabled: boolean
9
11
  styleContext: SwitcherStyleContexts
10
12
  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
11
13
  theme?: SwitcherThemes
12
- childrenLeft?: JSX.Element
13
- childrenRight?: JSX.Element
14
+ children: JSX.Element[] | JSX.Element
15
+ childrenPosition?: SwitcherChildrenPositions
14
16
  }
@@ -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',
8
10
  onChange,
9
11
  styleContext,
10
- theme = 'light',
11
- childrenLeft,
12
- childrenRight
12
+ theme = 'light'
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
- {childrenLeft && (
22
+ {children && childrenPosition === 'left' && (
23
23
  <div
24
24
  className={makeClassName([
25
25
  [styles.children, true],
26
26
  [styles.left, true]
27
27
  ])}
28
28
  >
29
- {childrenLeft}
29
+ {children}
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
- {childrenRight && (
41
+ {children && childrenPosition === 'right' && (
42
42
  <div
43
43
  className={makeClassName([
44
44
  [styles.children, true],
45
45
  [styles.right, true]
46
46
  ])}
47
47
  >
48
- {childrenRight}
48
+ {children}
49
49
  </div>
50
50
  )}
51
51
  </label>
@@ -124,6 +124,10 @@
124
124
  }
125
125
  }
126
126
 
127
+ .isInDynamicBlock {
128
+ opacity: 0.5;
129
+ }
130
+
127
131
  .mobile {
128
132
  @media $mobile {
129
133
  display: none;
@@ -17,6 +17,7 @@ export const PreviewWrapper: React.FC<PreviewWrapperProps> = ({
17
17
  [styles[theme], !!theme]
18
18
  ])}
19
19
  >
20
+ <h2>{theme === 'dark' ? 'Dark theme' : 'Light theme'}</h2>
20
21
  {children}
21
22
  </div>
22
23
  )
package/src/index.tsx CHANGED
@@ -26,7 +26,6 @@ export * from './HalfBlock'
26
26
  export * from './RawHtmlBlock'
27
27
  export * from './ImportantLead'
28
28
  export * from './ListBlock'
29
- export * from './ListViewSwitcher'
30
29
  export * from './RelatedBlock'
31
30
  export * from './RichTitle'
32
31
  export * from './SimpleBlock'
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- export interface ListViewSwitcherProps {
3
- enabled: boolean;
4
- onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
5
- size?: 'sm' | 'md';
6
- }
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- import { ListViewSwitcherProps } from './ListViewSwitcher.types';
3
- export declare const ListViewSwitcher: React.FC<ListViewSwitcherProps>;
package/src/.DS_Store DELETED
Binary file
@@ -1,109 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- .root {
2
- display: flex;
3
- flex-flow: row wrap;
4
-
5
- gap: 24px;
6
- }
@@ -1,38 +0,0 @@
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
- )
@@ -1,35 +0,0 @@
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
- })
@@ -1,7 +0,0 @@
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
- }
@@ -1,30 +0,0 @@
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
- )