@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 CHANGED
@@ -1,3 +1,7 @@
1
+ ## v1.5.1
2
+
3
+ - Переработан FontInput - теперь вместо названий переменных для font-size/line-height он возвращает их значения
4
+
1
5
  ## v1.5.0
2
6
 
3
7
  - Для AJAX-форм добавлена поддержка поля `trigger`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formixru/b2b-ui",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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="$font-size-3xs">8</option>
30
- <option value="$font-size-2xs">10</option>
31
- <option value="$font-size-xs">12</option>
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="$line-height-s">1.2</option>
44
- <option value="$line-height">1.4</option>
45
- <option value="$line-height-l">1.6</option>
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
- parsedFont.value[index][item[0]] = item[1];
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
- $input.value.dispatchEvent(new Event('change', { bubbles: true }));
117
- emit('input', currentFont.value);
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) => {
@@ -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;