@meduza/ui-kit-2 0.2.21 → 0.2.22

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.21",
2
+ "version": "0.2.22",
3
3
  "license": "MIT",
4
4
  "description": "UIKit for Meduza",
5
5
  "repository": "https://github.com/meduza-corp/ui-kit-2.git",
@@ -206,6 +206,13 @@
206
206
  }
207
207
  }
208
208
 
209
+ .shareBookmark {
210
+ width: 8px;
211
+ height: auto;
212
+
213
+ cursor: pointer;
214
+ }
215
+
209
216
  .isInToolbar.bookmark {
210
217
  width: 14px;
211
218
  }
@@ -29,6 +29,7 @@ export type Icons =
29
29
  | 'download'
30
30
  | 'play'
31
31
  | 'pause'
32
+ | 'shareBookmark'
32
33
  | 'speedHalf'
33
34
  | 'speedOne'
34
35
  | 'speedOneHalf'
@@ -195,6 +195,13 @@ export const icons = {
195
195
  '<path d="M16 20l-7.5-6.333L1 20V1h15z" stroke="currentColor" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"/>'
196
196
  },
197
197
 
198
+ shareBookmark: {
199
+ width: 8,
200
+ height: 11,
201
+ content:
202
+ '<path clip-rule="evenodd" d="M7 10 4 7l-3 3V1h6v9Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>'
203
+ },
204
+
198
205
  receipt: {
199
206
  width: 10,
200
207
  height: 13,
@@ -12,14 +12,10 @@
12
12
  display: flex;
13
13
  flex-flow: row wrap;
14
14
 
15
- margin: 0 0 0 -10px;
15
+ margin: 0 0 0 -11px;
16
16
  padding: 0;
17
17
 
18
18
  list-style: none;
19
-
20
- @media $landscapeTablet {
21
- margin: 0 0 0 -15px;
22
- }
23
19
  }
24
20
 
25
21
  .item {
@@ -27,8 +23,8 @@
27
23
 
28
24
  min-width: 42px;
29
25
  height: 32px;
30
- padding-right: 10px;
31
- padding-left: 10px;
26
+ padding-right: 11px;
27
+ padding-left: 11px;
32
28
 
33
29
  cursor: pointer;
34
30
  transition: color 250ms ease;
@@ -37,11 +33,6 @@
37
33
  color: #808080;
38
34
 
39
35
  line-height: 1;
40
-
41
- @media $landscapeTablet {
42
- padding-right: 15px;
43
- padding-left: 15px;
44
- }
45
36
  }
46
37
 
47
38
  .item:last-child {
@@ -50,15 +41,13 @@
50
41
 
51
42
  .item::before {
52
43
  position: absolute;
53
- top: 7px;
44
+ top: 50%;
54
45
  left: 0;
55
46
 
56
- height: 18px;
57
-
58
- content: '';
59
- vertical-align: middle;
47
+ content: '·';
48
+ transform: translateY(-50%);
60
49
 
61
- border-left: 1px solid rgba(0, 0, 0, 0.15);
50
+ font-size: 14px;
62
51
  }
63
52
 
64
53
  .item:empty {
@@ -14,11 +14,21 @@ export default {
14
14
  }
15
15
  }
16
16
 
17
- const buttons: { type: ToolbarButtonTypes; label?: string }[] = [
17
+ const buttons: {
18
+ type: ToolbarButtonTypes
19
+ label?: string
20
+ icon?: 'shareBookmark'
21
+ }[] = [
22
+ {
23
+ type: 'tg'
24
+ },
18
25
  {
19
26
  type: 'fb',
20
27
  label: '23,4K'
21
28
  },
29
+ {
30
+ type: 'tw'
31
+ },
22
32
  {
23
33
  type: 'vk',
24
34
  label: '481'
@@ -27,17 +37,11 @@ const buttons: { type: ToolbarButtonTypes; label?: string }[] = [
27
37
  type: 'ok'
28
38
  },
29
39
  {
30
- type: 'tw'
31
- },
32
- {
33
- type: 'tg'
34
- },
35
- {
36
- type: 'reaction',
37
- label: 'Связаться с редакцией'
40
+ type: 'bookmark',
41
+ icon: 'shareBookmark'
38
42
  },
39
43
  {
40
- type: 'bookmark'
44
+ type: 'reaction'
41
45
  }
42
46
  ]
43
47
 
@@ -66,6 +70,8 @@ const Example: React.FC<{ theme?: string }> = ({ theme }) => {
66
70
  }
67
71
  key={`${index}-${button.type}`}
68
72
  isActive={button.type === 'bookmark' && bookmark}
73
+ lang="ru"
74
+ icon={button.icon}
69
75
  >
70
76
  {button.label && button.label}
71
77
  </ToolbarButton>
@@ -7,7 +7,7 @@
7
7
 
8
8
  cursor: pointer;
9
9
 
10
- color: inherit;
10
+ color: #000;
11
11
  border-width: 0;
12
12
  outline: none;
13
13
  background-color: transparent;
@@ -82,21 +82,35 @@
82
82
  visibility: hidden;
83
83
  }
84
84
 
85
+ .icon {
86
+ display: inline-block;
87
+ vertical-align: middle;
88
+ margin-top: -1px;
89
+ padding-right: 5px;
90
+
91
+ @media $landscapeTablet {
92
+ padding-left: 5px;
93
+ }
94
+ }
95
+
85
96
  .text {
86
97
  display: inline-block;
87
98
 
88
- padding-left: 5px;
99
+ vertical-align: middle;
100
+ }
89
101
 
102
+ .counter {
103
+ color: #8c8c8c;
104
+ display: inline-block;
90
105
  vertical-align: middle;
106
+ padding-left: 3px;
91
107
  }
92
108
 
93
- .text:empty {
109
+ .counter:empty {
94
110
  display: none;
95
111
  }
96
112
 
97
113
  .bookmark {
98
- color: #999;
99
-
100
114
  fill: transparent;
101
115
  }
102
116
 
@@ -20,6 +20,7 @@ const Example: React.FC<{ theme?: string }> = ({ theme }) => {
20
20
  type="fb"
21
21
  theme={theme}
22
22
  onClick={(): void => alert('Hello Button')}
23
+ lang="ru"
23
24
  >
24
25
  42
25
26
  </ToolbarButton>
@@ -10,7 +10,11 @@ describe('Toolbar Button', () => {
10
10
 
11
11
  const renderComponent = () =>
12
12
  render(
13
- <ToolbarButton type="fb" onClick={(): void => alert('Hello Button')}>
13
+ <ToolbarButton
14
+ lang="ru"
15
+ type="fb"
16
+ onClick={(): void => alert('Hello Button')}
17
+ >
14
18
  42
15
19
  </ToolbarButton>
16
20
  )
@@ -13,6 +13,8 @@ export type ToolbarButtonTypes =
13
13
  export interface ToolbarButtonProps {
14
14
  type: ToolbarButtonTypes
15
15
  theme?: string
16
+ lang: 'ru' | 'en'
17
+ icon?: 'shareBookmark'
16
18
  isActive?: boolean
17
19
  onClick: (type: string) => void
18
20
  children?: React.ReactNode | JSX.Element[] | JSX.Element
@@ -5,12 +5,15 @@ import { makeClassName, ClassNames } from '../utils/makeClassName'
5
5
 
6
6
  import toolbarStyles from '../Toolbar/Toolbar.module.css'
7
7
  import styles from './ToolbarButton.module.css'
8
+ import { SocialLabels } from '../constants'
8
9
 
9
10
  export const ToolbarButton: React.FC<ToolbarButtonProps> = ({
10
11
  children,
11
12
  type,
12
13
  theme,
13
14
  isActive,
15
+ lang = 'ru',
16
+ icon,
14
17
  onClick
15
18
  }) => {
16
19
  const classNames: ClassNames = [
@@ -20,6 +23,8 @@ export const ToolbarButton: React.FC<ToolbarButtonProps> = ({
20
23
  [styles.isActive, !!isActive]
21
24
  ]
22
25
 
26
+ const label = SocialLabels[lang][type]
27
+
23
28
  return (
24
29
  <li className={toolbarStyles.item}>
25
30
  <button
@@ -28,8 +33,18 @@ export const ToolbarButton: React.FC<ToolbarButtonProps> = ({
28
33
  type="button"
29
34
  onClick={(): void => onClick(type)}
30
35
  >
31
- <SvgSymbol size="medium" icon={type} styleContext="isInToolbar" />
32
- {children && <span className={styles.text}>{children}</span>}
36
+ {icon && (
37
+ <div className={styles.icon}>
38
+ <SvgSymbol size="medium" icon={icon} styleContext="isInToolbar" />
39
+ </div>
40
+ )}
41
+ <span className={styles.text}>{label}</span>
42
+ {children && (
43
+ <span className={styles.counter}>
44
+ {` `}
45
+ {children}
46
+ </span>
47
+ )}
33
48
  </button>
34
49
  </li>
35
50
  )
package/src/constants.ts CHANGED
@@ -22,3 +22,23 @@ export const imageConditionalKeys = {
22
22
  default: [650, 520, 325],
23
23
  narrow: [600, 325]
24
24
  }
25
+
26
+ export const SocialLabels = {
27
+ ru: {
28
+ tg: 'Telegram',
29
+ fb: 'Фб',
30
+ vk: 'Вк',
31
+ ok: 'Ок',
32
+ tw: 'Твиттер',
33
+ bookmark: 'В закладки',
34
+ reaction: 'Напишите нам'
35
+ },
36
+ en: {
37
+ tg: 'Telegram',
38
+ fb: 'Fb',
39
+ vk: 'Vk',
40
+ ok: 'Ok',
41
+ tw: 'Twitter',
42
+ bookmark: 'Add to bookmarks'
43
+ }
44
+ }