@brandup/ui-kit 1.0.9 → 1.0.11

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Installation and use
4
4
 
5
- Install NPM package [@brandup/ui](https://www.npmjs.com/package/@brandup/ui-kit).
5
+ Install NPM package [@brandup/ui-kit](https://www.npmjs.com/package/@brandup/ui-kit).
6
6
 
7
7
  ```
8
8
  npm i @brandup/ui-kit@latest
@@ -147,3 +147,54 @@ PopupManager.open(DOM.getById("popup3"));
147
147
  ```
148
148
 
149
149
  If the initiator is specified, then when the popup is opened again, it will be closed.
150
+
151
+ ### Style variables
152
+
153
+ Сreate uikit.vars.less in the root of the project.
154
+
155
+ Connecting script to webpack:
156
+
157
+ ```JS
158
+ const parseLessVars = require("@brandup/ui-kit/build/parse-less-vars.cjs");
159
+ ```
160
+
161
+ Getting variables from a Less file.
162
+
163
+ The function takes the path to the Less file (string) and returns an object with variables in the format:
164
+
165
+ The key is the name of a variable with the @ symbol (for example, @MainColor).
166
+ Value — a string with the value of a variable from a file (for example, #ff0000).
167
+
168
+ Example of a Less file:
169
+
170
+ ```Less
171
+ @main-color: #ff0000;
172
+ @secondary-color: rgba(0, 0, 0, 0.5);
173
+ @font-size: 16px;
174
+ ```
175
+
176
+ Result of parseLessVars:
177
+
178
+ ```JS
179
+ {
180
+ '@main-color': '#ff0000',
181
+ '@secondary-color': 'rgba(0,0,0,0.5)',
182
+ '@font-size': '16px'
183
+ }
184
+ ```
185
+
186
+ ```JS
187
+ const variables = parseLessVars('path/to/your/variables.less');
188
+ ```
189
+
190
+ if no parameter has been set, the function will refer to the uikit.vars.less into root directory.
191
+
192
+ Usage in the less-loader configuration.
193
+
194
+ ```JS
195
+ {
196
+ lessOption: {
197
+ modifyVars: parseLessVars()
198
+ }
199
+ }
200
+ ```
@@ -0,0 +1,18 @@
1
+ const fs = require("fs");
2
+
3
+ function parseLessVars(filePath) {
4
+ if (!filePath) {
5
+ filePath = 'uikit.vars.less';
6
+ }
7
+
8
+ const content = fs.readFileSync(filePath, 'utf-8');
9
+
10
+ let variables = {};
11
+
12
+ content.split('\n').forEach(line => {
13
+ const match = line.match(/@([\w-]+)\s*:\s*(.+);/);
14
+ if (match) variables[`@${match[1]}`] = match[2].trim();
15
+ });
16
+ return variables;
17
+ }
18
+ module.exports = parseLessVars;
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "type": "module",
24
24
  "license": "Apache-2.0",
25
- "version": "1.0.9",
25
+ "version": "1.0.11",
26
26
  "main": "source/index.ts",
27
27
  "types": "source/index.ts",
28
28
  "dependencies": {
@@ -30,6 +30,8 @@
30
30
  },
31
31
  "files": [
32
32
  "source",
33
+ "build",
34
+ "vars.less",
33
35
  "README.md"
34
36
  ]
35
37
  }
@@ -1,10 +1,4 @@
1
- @adaptive-desktop-small: 1650px;
2
- @adaptive-notebook: 1550px;
3
- @adaptive-notebook-small: 1370px;
4
- @adaptive-tablet: 1030px;
5
- @adaptive-tablet-small: 850px;
6
- @adaptive-mobile: 500px;
7
- @adaptive-mobile-small: 370px;
1
+ @import "../vars.less";
8
2
 
9
3
  .adaptive-desktop-small(@rules) {
10
4
  @media all and (max-width: @adaptive-desktop-small) {
@@ -55,7 +49,7 @@
55
49
  }
56
50
 
57
51
  .adaptive-mobile-small(@rules) {
58
- @media all and (max-width: var(-adaptive-mobile-small)) {
52
+ @media all and (max-width: @adaptive-mobile-small) {
59
53
  @rules();
60
54
  }
61
55
  }
@@ -1,43 +1,43 @@
1
1
  :root {
2
2
  // body
3
- --main-background: #fff;
4
- --font-size: 14px;
5
- --font-family: system-ui, 'Segoe UI', Helvetica, 'Gill Sans', 'Verdana', 'Arial', sans-serif;
6
- --font-weight: 400;
7
- --line-height: 130%;
8
- --text-color: #222;
3
+ --main-background: @main-background;
4
+ --font-size: @font-size;
5
+ --font-family:@font-family;
6
+ --font-weight: @font-weight;
7
+ --line-height: @line-height;
8
+ --text-color: @text-color;
9
9
 
10
10
  // headers
11
- --h-line-height: 130%;
12
- --h1-font-size: 56px;
13
- --h1-font-weight: 600;
14
- --h2-font-size: 50px;
15
- --h2-font-weight: 600;
16
- --h3-font-size: 28px;
17
- --h3-font-weight: 600;
18
- --h4-font-size: 22px;
19
- --h4-font-weight: 600;
20
- --h5-font-size: 18px;
21
- --h5-font-weight: 600;
11
+ --h-line-height: @h-line-height;
12
+ --h1-font-size: @h1-font-size;
13
+ --h1-font-weight: @h1-font-weight;
14
+ --h2-font-size: @h2-font-size;
15
+ --h2-font-weight: @h2-font-weight;
16
+ --h3-font-size: @h3-font-size;
17
+ --h3-font-weight: @h3-font-weight;
18
+ --h4-font-size: @h4-font-size;
19
+ --h4-font-weight: @h4-font-weight;
20
+ --h5-font-size: @h5-font-size;
21
+ --h5-font-weight: @h5-font-weight;
22
22
 
23
23
  // content-width
24
- --content-max-width: 1280px; // максимальная ширина контентной области
25
- --content-min-width: 320px; // минимальная ширина контентной области
26
- --content-padding-lr: 40px; // отступы контентной области слева и справа до краёв браузера
24
+ --content-max-width: @content-max-width; // максимальная ширина контентной области
25
+ --content-min-width: @content-min-width; // минимальная ширина контентной области
26
+ --content-padding-lr: @content-padding-lr; // отступы контентной области слева и справа до краёв браузера
27
27
 
28
28
  // svg
29
- --svg-size: 20px;
30
- --svg-fill: var(--text-color);
31
- --svg-stroke: none;
29
+ --svg-size: @svg-size;
30
+ --svg-fill: @svg-fill;
31
+ --svg-stroke: @svg-stroke;
32
32
 
33
33
  // popup
34
34
 
35
- --popup-fill: var(--main-background);
36
- --popup-border-style: solid;
37
- --popup-border-width: 1px;
38
- --popup-border-color: #aaa;
39
- --popup-border-radius: 5px;
40
- --popup-box-shadow: 0px 4px 8px 2px rgba(0, 0, 0, 0.12);
35
+ --popup-fill: @popup-fill;
36
+ --popup-border-style: @popup-border-style;
37
+ --popup-border-width: @popup-border-width;
38
+ --popup-border-color: @popup-border-color;
39
+ --popup-border-radius: @popup-border-radius;
40
+ --popup-box-shadow: @popup-box-shadow;
41
41
  }
42
42
 
43
43
  // Body styles
@@ -98,7 +98,7 @@ h5 {
98
98
  svg {
99
99
  display: block;
100
100
  width: var(--svg-size);
101
- height: var(---svg-size);
101
+ height: var(--svg-size);
102
102
  fill: var(--svg-fill);
103
103
  stroke: var(--svg-stroke);
104
104
  }
package/source/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { UiKitMiddleware } from "./middleware";
2
2
  export * from "./popup"
3
+ export { IS_TOUCH_DEVICE } from "./utils/compatibility";
3
4
  import "./styles.less";
4
5
 
5
6
  export const uiKitMiddlewareFactory = () => new UiKitMiddleware();
@@ -7,49 +7,56 @@
7
7
 
8
8
  :root {
9
9
  // placeholder
10
- --placeholder-font-weight: inherit;
11
- --placeholder-font-style: inherit;
12
- --placeholder-color: inherit;
10
+ --placeholder-font-weight: @placeholder-font-weight;
11
+ --placeholder-font-style: @placeholder-font-style;
12
+ --placeholder-color: @placeholder-color;
13
13
 
14
14
  // border
15
- --input-border-width: 1px;
16
- --input-border-color: #aaa;
17
- --input-border-type: solid;
18
- --input-border-radius: 0;
19
- --input-fill: #fff;
15
+ --input-border-width: @input-border-width;
16
+ --input-border-color: @input-border-color;
17
+ --input-border-type: @input-border-type;
18
+ --input-border-radius: @input-border-radius;
19
+ --input-fill: @input-fill;
20
20
 
21
21
  // size
22
- --input-width: auto;
23
- --input-height: 42px;
24
- --input-padding-lr: 13px;
25
- --textarea-size: 100px;
22
+ --input-width: @input-width;
23
+ --input-height: @input-height;
24
+ --input-padding-lr: @input-padding-lr;
25
+ --textarea-size: @textarea-size;
26
26
 
27
27
  // font
28
- --input-color: var(--text-color);
29
- --input-font-size: inherit;
30
- --input-font-weight: inherit;
31
- --input-font-style: inherit;
28
+ --input-color: @input-color;
29
+ --input-font-size: @input-font-size;
30
+ --input-font-weight: @input-font-weight;
31
+ --input-font-style: @input-font-style;
32
+ --input-line-height: @input-line-height;
32
33
 
33
- --hover--input-border-color: #666;
34
- --hover--input-fill: var(--input-fill);
35
- --hover--input-color: var(--input-color);
34
+ --hover--input-border-color: @hover--input-border-color;
35
+ --hover--input-fill: @hover--input-fill;
36
+ --hover--input-color: @hover--input-color;
36
37
 
37
- --focus--input-border-color: #222;
38
- --focus--input-fill: var(--hover--input-fill);
39
- --focus--input-color: var(--hover--input-color);
38
+ --focus--input-border-color: @focus--input-border-color;
39
+ --focus--input-fill: @focus--input-fill;
40
+ --focus--input-color: @focus--input-color;
40
41
 
41
- --disabled--input-border-color: #aaa;
42
- --disabled--input-fill: #eee;
43
- --disabled--input-color: var(--input-color);
42
+ --readonly--input-fill: @readonly--input-fill;
43
+ --readonly--input-color: @readonly--input-color;
44
44
 
45
- --invalid--input-border-color: red;
46
- --invalid--input-fill: var(--input-fill);
47
- --invalid--input-color: var(--input-color);
45
+ --disabled--input-border-color: @disabled--input-border-color;
46
+ --disabled--input-fill: @disabled--input-fill;
47
+ --disabled--input-color: @disabled--input-color;
48
+
49
+ --invalid--input-border-color: @invalid--input-border-color;
50
+ --invalid--input-fill: @invalid--input-fill;
51
+ --invalid--input-color: @invalid--input-color;
52
+
53
+ --incorrect--input-fill: @incorrect--input-fill;
54
+ --incorrect--input-color: @input-color;
48
55
 
49
56
  // toggler
50
- --toggler-height: 30px;
51
- --toggler-padding: 3px;
52
- --toggler-round-fill: var(--focus--input-border-color); // цвет круглешка
57
+ --toggler-height: @toggler-height;
58
+ --toggler-padding: @toggler-padding;
59
+ --toggler-round-fill: @toggler-round-fill; // цвет круглешка
53
60
  }
54
61
 
55
62
  input,
@@ -62,7 +69,7 @@ select {
62
69
  font-weight: var(--input-font-weight);
63
70
  font-style: var(--input-font-style);
64
71
  color: var(--input-color);
65
- line-height: unset;
72
+ line-height: var(--input-line-height);
66
73
  box-sizing: border-box;
67
74
  padding: 0;
68
75
  margin: 0;
@@ -116,6 +123,8 @@ select {
116
123
 
117
124
  &:read-only {
118
125
  cursor: default;
126
+ background: var(--readonly--input-fill);
127
+ color: var(--readonly--input-color);
119
128
  }
120
129
 
121
130
  &:disabled {
@@ -188,18 +197,20 @@ input[type=checkbox] {
188
197
 
189
198
  &:hover {
190
199
  border-color: var(--hover--input-border-color);
191
- background: var(--hover--input-fill);
200
+ background-color: var(--hover--input-fill);
192
201
  color: var(--hover--input-color);
193
202
  }
194
203
 
195
204
  &:focus {
196
205
  border-color: var(--focus--input-border-color);
197
- background: var(--focus--input-fill);
206
+ background-color: var(--focus--input-fill);
198
207
  color: var(--focus--input-color);
199
208
  }
200
209
 
201
210
  &[readonly] {
202
211
  pointer-events: none;
212
+ touch-action: none;
213
+ background-color: var(--readonly--input-fill);
203
214
  }
204
215
 
205
216
  &:checked {
@@ -214,7 +225,7 @@ input[type=checkbox] {
214
225
 
215
226
  &:disabled {
216
227
  border-color: var(--disabled--input-border-color);
217
- background: var(--disabled--input-fill);
228
+ background-color: var(--disabled--input-fill);
218
229
  color: var(--disabled--input-color);
219
230
  cursor: default;
220
231
 
@@ -226,7 +237,7 @@ input[type=checkbox] {
226
237
 
227
238
  &:user-invalid {
228
239
  border-color: var(--invalid--input-border-color);
229
- background: var(--invalid--input-fill);
240
+ background-color: var(--invalid--input-fill);
230
241
  color: var(--invalid--input-color);
231
242
  }
232
243
  }
@@ -1,3 +1,4 @@
1
1
  @import "reset.less";
2
2
  @import "common.less";
3
- @import "inputs.less";
3
+ @import "inputs.less";
4
+ @import "../vars.less";
@@ -0,0 +1 @@
1
+ export const IS_TOUCH_DEVICE = window.document.documentElement ? "ontouchstart" in window.document.documentElement : false;
package/vars.less ADDED
@@ -0,0 +1,95 @@
1
+ // adaptive
2
+
3
+ @adaptive-desktop-small: 1650px;
4
+ @adaptive-notebook: 1550px;
5
+ @adaptive-notebook-small: 1370px;
6
+ @adaptive-tablet: 1030px;
7
+ @adaptive-tablet-small: 850px;
8
+ @adaptive-mobile: 500px;
9
+ @adaptive-mobile-small: 370px;
10
+
11
+ // common
12
+
13
+ @main-background: #fff;
14
+
15
+ @font-size: 14px;
16
+ @font-family: system-ui, 'Segoe UI', Helvetica, 'Gill Sans', 'Verdana', 'Arial', sans-serif;
17
+ @font-weight: 400;
18
+ @line-height: 130%;
19
+ @text-color: #222;
20
+
21
+ @h-line-height: 130%;
22
+ @h1-font-size: 56px;
23
+ @h1-font-weight: 600;
24
+ @h2-font-size: 50px;
25
+ @h2-font-weight: 600;
26
+ @h3-font-size: 28px;
27
+ @h3-font-weight: 600;
28
+ @h4-font-size: 22px;
29
+ @h4-font-weight: 600;
30
+ @h5-font-size: 18px;
31
+ @h5-font-weight: 600;
32
+
33
+ @content-max-width: 1280px;
34
+ @content-min-width: 320px;
35
+ @content-padding-lr: 40px;
36
+
37
+ @svg-size: 20px;
38
+ @svg-fill: @text-color;
39
+ @svg-stroke: none;
40
+
41
+ @popup-fill: @main-background;
42
+ @popup-border-style: solid;
43
+ @popup-border-width: 1px;
44
+ @popup-border-color: #aaa;
45
+ @popup-border-radius: 5px;
46
+ @popup-box-shadow: 0px 4px 8px 2px rgba(0, 0, 0, 0.12);
47
+
48
+ // inputs
49
+
50
+ @placeholder-font-weight: inherit;
51
+ @placeholder-font-style: inherit;
52
+ @placeholder-color: inherit;
53
+
54
+ @input-border-width: 1px;
55
+ @input-border-color: #aaa;
56
+ @input-border-type: solid;
57
+ @input-border-radius: 0;
58
+ @input-fill: #fff;
59
+
60
+ @input-width: auto;
61
+ @input-height: 42px;
62
+ @input-padding-lr: 13px;
63
+ @textarea-size: 100px;
64
+
65
+ @input-color: @text-color;
66
+ @input-font-size: 14px;
67
+ @input-line-height: 1.2rem;
68
+ @input-font-weight: inherit;
69
+ @input-font-style: inherit;
70
+
71
+ @hover--input-border-color: #666;
72
+ @hover--input-fill: @input-fill;
73
+ @hover--input-color: @input-color;
74
+
75
+ @focus--input-border-color: #222;
76
+ @focus--input-fill: @input-fill;
77
+ @focus--input-color: @input-color;
78
+
79
+ @readonly--input-fill: #f7f7f7;
80
+ @readonly--input-color: @input-color;
81
+
82
+ @disabled--input-border-color: #aaa;
83
+ @disabled--input-fill: #eee;
84
+ @disabled--input-color: @input-color;
85
+
86
+ @invalid--input-border-color: red;
87
+ @invalid--input-fill: rgb(255, 220, 220);
88
+ @invalid--input-color: @input-color;
89
+
90
+ @incorrect--input-fill: rgb(255, 220, 220);
91
+ @incorrect--input-color: inherit;
92
+
93
+ @toggler-height: 30px;
94
+ @toggler-padding: 3px;
95
+ @toggler-round-fill: @focus--input-border-color;