@sequent-org/moodboard 1.0.18 → 1.0.20
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
|
@@ -582,6 +582,21 @@
|
|
|
582
582
|
margin: 0 6px 0 2px;
|
|
583
583
|
}
|
|
584
584
|
|
|
585
|
+
/* Active state for topbar buttons */
|
|
586
|
+
.moodboard-topbar__button--active {
|
|
587
|
+
background: #dbeafe;
|
|
588
|
+
color: #1d4ed8;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/* Paint button specific styles */
|
|
592
|
+
.moodboard-topbar__button--paint {
|
|
593
|
+
background: #f0f0f0;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
.moodboard-topbar__button--paint:hover {
|
|
597
|
+
background: #e6e6e6;
|
|
598
|
+
}
|
|
599
|
+
|
|
585
600
|
/* Paint popover */
|
|
586
601
|
.moodboard-topbar__paint-popover {
|
|
587
602
|
position: absolute;
|
|
@@ -9,20 +9,68 @@ export class TopbarIconLoader {
|
|
|
9
9
|
|
|
10
10
|
async init() {
|
|
11
11
|
try {
|
|
12
|
-
//
|
|
13
|
-
// Это гарантирует работу в любом окружении (npm пакет, CDN, локальная разработка)
|
|
12
|
+
// Сначала загружаем встроенные иконки как основной источник
|
|
14
13
|
this.loadBuiltInIcons();
|
|
15
14
|
|
|
15
|
+
// Затем пытаемся загрузить из файлов (если доступно)
|
|
16
|
+
await this.loadTopbarIcons();
|
|
17
|
+
|
|
16
18
|
console.log('✅ Иконки верхней панели загружены успешно');
|
|
17
19
|
|
|
18
20
|
} catch (error) {
|
|
19
21
|
console.error('❌ Критическая ошибка загрузки иконок верхней панели:', error);
|
|
20
|
-
//
|
|
21
|
-
this.loadBuiltInIcons();
|
|
22
|
+
// В случае ошибки у нас уже есть встроенные иконки
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
async loadTopbarIcons() {
|
|
27
|
+
// Список иконок, которые нужно загрузить
|
|
28
|
+
const iconNames = ['grid-line', 'grid-dot', 'grid-cross', 'grid-off', 'paint'];
|
|
29
|
+
|
|
30
|
+
for (const iconName of iconNames) {
|
|
31
|
+
try {
|
|
32
|
+
const svgContent = await this.loadIconFromFile(iconName);
|
|
33
|
+
if (svgContent) {
|
|
34
|
+
this.icons.set(iconName, svgContent);
|
|
35
|
+
console.log(`✅ Загружена иконка из файла: ${iconName}`);
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.warn(`⚠️ Не удалось загрузить иконку ${iconName} из файла:`, error.message);
|
|
39
|
+
// Оставляем встроенную версию
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
console.log(`📦 Всего загружено ${this.icons.size} иконок верхней панели`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async loadIconFromFile(iconName) {
|
|
47
|
+
// Пробуем несколько способов загрузки для разных окружений
|
|
48
|
+
const paths = [
|
|
49
|
+
`/src/assets/icons/topbar/${iconName}.svg`,
|
|
50
|
+
`./src/assets/icons/topbar/${iconName}.svg`,
|
|
51
|
+
`../assets/icons/topbar/${iconName}.svg`,
|
|
52
|
+
`assets/icons/topbar/${iconName}.svg`,
|
|
53
|
+
`/assets/icons/topbar/${iconName}.svg`
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
for (const path of paths) {
|
|
57
|
+
try {
|
|
58
|
+
const response = await fetch(path);
|
|
59
|
+
if (response.ok) {
|
|
60
|
+
const svgContent = await response.text();
|
|
61
|
+
console.log(`✅ Иконка ${iconName} загружена с пути: ${path}`);
|
|
62
|
+
return svgContent;
|
|
63
|
+
}
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.warn(`⚠️ Не удалось загрузить ${iconName} с пути ${path}:`, error.message);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return null; // Возвращаем null вместо ошибки
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
getBuiltInIcon(iconName) {
|
|
26
74
|
// Встроенные иконки как основной источник
|
|
27
75
|
const builtInIcons = {
|
|
28
76
|
'grid-line': `<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -71,9 +119,18 @@ export class TopbarIconLoader {
|
|
|
71
119
|
</svg>`
|
|
72
120
|
};
|
|
73
121
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
122
|
+
return builtInIcons[iconName];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
loadBuiltInIcons() {
|
|
126
|
+
// Загружаем встроенные иконки как основной источник
|
|
127
|
+
const iconNames = ['grid-line', 'grid-dot', 'grid-cross', 'grid-off', 'paint'];
|
|
128
|
+
|
|
129
|
+
for (const iconName of iconNames) {
|
|
130
|
+
const builtInIcon = this.getBuiltInIcon(iconName);
|
|
131
|
+
if (builtInIcon) {
|
|
132
|
+
this.icons.set(iconName, builtInIcon);
|
|
133
|
+
}
|
|
77
134
|
}
|
|
78
135
|
|
|
79
136
|
console.log(`📦 Загружено ${this.icons.size} встроенных иконок верхней панели`);
|