@skbkontur/colors 0.5.0 → 0.5.1
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/CHANGELOG.md +8 -0
- package/README.md +128 -75
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.5.1](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/colors@0.5.0...@skbkontur/colors@0.5.1) (2024-08-08)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @skbkontur/colors
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [0.5.0](https://git.skbkontur.ru/ui/ui-parking/compare/@skbkontur/colors@0.4.4...@skbkontur/colors@0.5.0) (2024-06-25)
|
|
7
15
|
|
|
8
16
|
|
package/README.md
CHANGED
|
@@ -1,115 +1,168 @@
|
|
|
1
1
|
# Библиотека цветов
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
NPM-пакет для доступа к цветам из общей Figma-библиотеки [Kontur.Colors](https://www.figma.com/file/XuiIin3JAOEcHHPihtthOJ/%E2%9A%A1%EF%B8%8F-Kontur-Colors?node-id=0%3A1&t=pL38Ju5ZOo3VC6vt-0)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
## Установка
|
|
6
7
|
|
|
7
8
|
```bash
|
|
8
9
|
npm i @skbkontur/colors
|
|
9
10
|
```
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
## Использование
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
16
|
-
- `--blueDark30` для colors.css
|
|
17
|
-
- `KonturColors.blueDark30` для colors.ts
|
|
14
|
+
- JS/TS токены содержатся в объекте `KonturColors`
|
|
15
|
+
- В Less виде препроцессорных `@переменных`
|
|
16
|
+
- В CSS в виде глобальных `--css-переменных` в `:root { ... }`
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
#### JS/TS
|
|
20
19
|
|
|
21
|
-
```
|
|
22
|
-
|
|
20
|
+
```js static
|
|
21
|
+
import { KonturColors } from '@skbkontur/colors';
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
const text = `<div style="color: ${KonturColors.blueDark90}">Цвет blueDark90</div>`;
|
|
24
|
+
```
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
#### React
|
|
27
|
+
|
|
28
|
+
```jsx static
|
|
29
|
+
import { KonturColors } from '@skbkontur/colors';
|
|
30
|
+
|
|
31
|
+
const Component = () => {
|
|
32
|
+
return <div style={{ color: KonturColors.blueDark90 }}>Цвет blueDark90</div>
|
|
28
33
|
}
|
|
29
34
|
```
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
#### CSS
|
|
32
37
|
|
|
33
38
|
```css
|
|
34
|
-
// styles.css
|
|
35
|
-
|
|
36
39
|
@import '@skbkontur/colors/colors.css';
|
|
37
40
|
|
|
38
41
|
.class {
|
|
39
|
-
color: var(--
|
|
42
|
+
color: var(--blueDark90);
|
|
40
43
|
}
|
|
41
44
|
```
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
#### Less
|
|
44
47
|
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
import { KonturColors } from '@skbkontur/colors';
|
|
48
|
+
```less
|
|
49
|
+
@import '@skbkontur/colors/colors.less';
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
<div style={{color: KonturColors.blue10}}>some content</div>
|
|
53
|
-
)
|
|
51
|
+
.class {
|
|
52
|
+
color: @blueDark90;
|
|
54
53
|
}
|
|
55
54
|
```
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
## Как работает
|
|
59
|
-
Все цвета описаны в файле `src/colors.ts`.
|
|
60
|
-
В файле `generate.ts` живёт сам код генерации файлов, а запускается генерация командой `npm run build`
|
|
61
|
-
|
|
62
56
|
## Палитра
|
|
63
57
|
|
|
64
|
-
```
|
|
58
|
+
```jsx
|
|
65
59
|
import { KonturColors } from '@skbkontur/colors';
|
|
60
|
+
import { Toast } from '@skbkontur/react-ui';
|
|
61
|
+
import { css } from '@skbkontur/react-ui/lib/theming/Emotion';
|
|
66
62
|
|
|
67
63
|
const styles = {
|
|
68
|
-
|
|
69
|
-
display:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
64
|
+
colors: css`
|
|
65
|
+
display: grid;
|
|
66
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
67
|
+
gap: 24px;
|
|
68
|
+
`,
|
|
69
|
+
colorGroup: css`
|
|
70
|
+
break-inside: avoid;
|
|
71
|
+
margin-bottom: 64px;
|
|
72
|
+
`,
|
|
73
|
+
colorBlock: css`
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
gap: 10px;
|
|
77
|
+
width: 100%;
|
|
78
|
+
border: none;
|
|
79
|
+
text-align: left;
|
|
80
|
+
background: none;
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
padding: 8px;
|
|
83
|
+
border-radius: 8px;
|
|
84
|
+
transition: .1s ease;
|
|
85
|
+
|
|
86
|
+
&:hover {
|
|
87
|
+
background: rgba(0,0,0,.06);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&:active {
|
|
91
|
+
background: rgba(0,0,0,.1);
|
|
92
|
+
}
|
|
93
|
+
`,
|
|
94
|
+
colorTile: css`
|
|
95
|
+
display: block;
|
|
96
|
+
height: 32px;
|
|
97
|
+
width: 32px;
|
|
98
|
+
border: 1px solid rgba(0, 0, 0, 0.08);
|
|
99
|
+
border-radius: 8px;
|
|
100
|
+
flex-shrink: 0;
|
|
101
|
+
`,
|
|
102
|
+
groupTitle: css`
|
|
103
|
+
display: block;
|
|
104
|
+
font-size: 20px;
|
|
105
|
+
font-weight: 600;
|
|
106
|
+
margin: 0 8px 12px;
|
|
107
|
+
`,
|
|
108
|
+
title: css`
|
|
109
|
+
display: block;
|
|
110
|
+
padding: 1px 0 0 8px;
|
|
111
|
+
`,
|
|
112
|
+
colorName: css`
|
|
113
|
+
display: block;
|
|
114
|
+
font-size: 14px;
|
|
115
|
+
line-height: 1.2;
|
|
116
|
+
`,
|
|
117
|
+
colorValue: css`
|
|
118
|
+
display: block;
|
|
119
|
+
fontSize: 12px;
|
|
120
|
+
color: #8b8b8b;
|
|
121
|
+
}`
|
|
92
122
|
};
|
|
93
123
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
124
|
+
const colorGroups = Object.entries(KonturColors)
|
|
125
|
+
.reduce((acc, [colorKey, colorValue]) => {
|
|
126
|
+
const firstWord =
|
|
127
|
+
['greenMint', 'blueDark'].find((color) => colorKey.match(color)) || colorKey.match(/^[a-z]+/)[0];
|
|
128
|
+
|
|
129
|
+
acc[firstWord] = { ...acc[firstWord], [colorKey]: colorValue };
|
|
130
|
+
|
|
131
|
+
return acc;
|
|
132
|
+
}, {});
|
|
133
|
+
|
|
134
|
+
<div className={styles.colors}>
|
|
135
|
+
{Object.entries(colorGroups).map(([group, colors]) => {
|
|
97
136
|
return (
|
|
98
|
-
|
|
99
|
-
<div
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
137
|
+
<div className={styles.colorGroup}>
|
|
138
|
+
<div className={styles.groupTitle}>{group}</div>
|
|
139
|
+
|
|
140
|
+
{Object.keys(colors).map((colorName) => {
|
|
141
|
+
const colorValue = KonturColors[colorName];
|
|
142
|
+
return (
|
|
143
|
+
<button
|
|
144
|
+
className={styles.colorBlock}
|
|
145
|
+
onClick={() => {
|
|
146
|
+
navigator.clipboard.writeText(colorName)
|
|
147
|
+
Toast.push('Цвет скопирован', null, 1000);
|
|
148
|
+
}}
|
|
149
|
+
>
|
|
150
|
+
<span className={styles.colorTile} style={{ backgroundColor: colorValue }} />
|
|
151
|
+
<span>
|
|
152
|
+
<span className={styles.colorName}>{colorName}</span>
|
|
153
|
+
<span className={styles.colorValue}>{colorValue}</span>
|
|
154
|
+
</span>
|
|
155
|
+
</button>
|
|
156
|
+
);
|
|
157
|
+
})}
|
|
158
|
+
</div>
|
|
159
|
+
)
|
|
113
160
|
})}
|
|
114
161
|
</div>
|
|
115
162
|
```
|
|
163
|
+
|
|
164
|
+
## Разработка
|
|
165
|
+
|
|
166
|
+
- Токены выгружаются в формате `camelCase`
|
|
167
|
+
- `src/colors.ts` — файл с токенами
|
|
168
|
+
- `npm run build` — сборка пакета в `/dist`
|