@formixru/b2b-ui 1.5.0 → 1.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 +4 -0
- package/package.json +1 -1
- package/src/components/font-input/index.vue +37 -17
- package/src/variables.scss +2 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -26,23 +26,18 @@
|
|
|
26
26
|
<span class="font-input__label">Размер</span>
|
|
27
27
|
<select v-model="font['font-size']" class="font-input__select select" @change="setFont()">
|
|
28
28
|
<option value=""></option>
|
|
29
|
-
<option value="
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<option value="$font-size-s">14</option>
|
|
33
|
-
<option value="$font-size">16</option>
|
|
34
|
-
<option value="$font-size-l">20</option>
|
|
35
|
-
<option value="$font-size-xl">24</option>
|
|
36
|
-
<option value="$font-size-2xl">28</option>
|
|
29
|
+
<option v-for="(fontSizeValue, key) in fontSizeMap" :key="key" :value="fontSizeValue">
|
|
30
|
+
{{ fontSizeValue.replace('px', '') }}
|
|
31
|
+
</option>
|
|
37
32
|
</select>
|
|
38
33
|
</label>
|
|
39
34
|
<label class="font-input__item">
|
|
40
35
|
<span class="font-input__label">Интерлиньяж</span>
|
|
41
36
|
<select v-model="font['line-height']" class="font-input__select select" @change="setFont()">
|
|
42
37
|
<option value=""></option>
|
|
43
|
-
<option value="
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
<option v-for="(lineHeightValue, key) in lineHeightMap" :key="key" :value="lineHeightValue">
|
|
39
|
+
{{ lineHeightValue }}
|
|
40
|
+
</option>
|
|
46
41
|
</select>
|
|
47
42
|
</label>
|
|
48
43
|
</div>
|
|
@@ -88,17 +83,43 @@ const visibleFontIndex = ref(0);
|
|
|
88
83
|
const $root = ref();
|
|
89
84
|
const $input = ref();
|
|
90
85
|
|
|
86
|
+
const fontSizeMap = {
|
|
87
|
+
'$font-size-3xs': '8px',
|
|
88
|
+
'$font-size-2xs': '10px',
|
|
89
|
+
'$font-size-xs': '12px',
|
|
90
|
+
'$font-size-s': '14px',
|
|
91
|
+
'$font-size': '16px',
|
|
92
|
+
'$font-size-l': '20px',
|
|
93
|
+
'$font-size-xl': '24px',
|
|
94
|
+
'$font-size-2xl': '28px',
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const lineHeightMap = {
|
|
98
|
+
'$line-height-s': 1.2,
|
|
99
|
+
'$line-height': 1.4,
|
|
100
|
+
'$line-height-l': 1.6,
|
|
101
|
+
};
|
|
102
|
+
|
|
91
103
|
const parseFont = () => {
|
|
92
104
|
for (const [index, font] of currentFont.value.split(/, ?(?=\()/).entries()) {
|
|
93
105
|
const parsed = font.match(/'([\dA-Za-z-]+)': (\$?[\dA-Za-z-]+)/g) || [];
|
|
94
106
|
for (let item of parsed) {
|
|
95
107
|
item = item.replaceAll(/'| /g, '').split(':');
|
|
96
|
-
|
|
108
|
+
let value = item[1];
|
|
109
|
+
|
|
110
|
+
// Преобразуем переменные в значения
|
|
111
|
+
if (item[0] === 'font-size' && fontSizeMap[value]) {
|
|
112
|
+
value = fontSizeMap[value];
|
|
113
|
+
} else if (item[0] === 'line-height' && lineHeightMap[value]) {
|
|
114
|
+
value = lineHeightMap[value];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
parsedFont.value[index][item[0]] = value;
|
|
97
118
|
}
|
|
98
119
|
}
|
|
99
120
|
};
|
|
100
121
|
|
|
101
|
-
const setFont = () => {
|
|
122
|
+
const setFont = async () => {
|
|
102
123
|
currentFont.value = parsedFont.value
|
|
103
124
|
.map((font) => {
|
|
104
125
|
font = Object.entries(font)
|
|
@@ -112,10 +133,9 @@ const setFont = () => {
|
|
|
112
133
|
return `(${font.join(', ')})`;
|
|
113
134
|
})
|
|
114
135
|
.join(',');
|
|
115
|
-
nextTick(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
136
|
+
await nextTick();
|
|
137
|
+
$input.value.dispatchEvent(new Event('change', { bubbles: true }));
|
|
138
|
+
emit('input', currentFont.value);
|
|
119
139
|
};
|
|
120
140
|
|
|
121
141
|
watch(value, (newValue) => {
|
package/src/variables.scss
CHANGED
|
@@ -288,6 +288,8 @@ $font-color-error: $color-error !default;
|
|
|
288
288
|
|
|
289
289
|
$font-family: 'PT Sans', system-ui !default;
|
|
290
290
|
|
|
291
|
+
// При изменении значений $font-size/$line-height их так же нужно поменять в FontInput
|
|
292
|
+
|
|
291
293
|
$font-size: 16px !default;
|
|
292
294
|
$font-size-3xs: 8px !default; // Надо будет избавиться от этого размера
|
|
293
295
|
$font-size-2xs: 10px !default;
|