@sequent-org/moodboard 1.2.61 → 1.2.62
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 +1 -1
- package/src/ui/Topbar.js +19 -20
package/package.json
CHANGED
package/src/ui/Topbar.js
CHANGED
|
@@ -37,7 +37,7 @@ export class Topbar {
|
|
|
37
37
|
this.createTopbar();
|
|
38
38
|
this.attachEvents();
|
|
39
39
|
// Активируем дефолтную кнопку (line) до прихода события из ядра
|
|
40
|
-
|
|
40
|
+
// не подсвечиваем дефолт до прихода актуального типа из ядра
|
|
41
41
|
|
|
42
42
|
// Синхронизация активного состояния по событию из ядра
|
|
43
43
|
this.eventBus.on(Events.UI.GridCurrent, ({ type }) => {
|
|
@@ -50,11 +50,13 @@ export class Topbar {
|
|
|
50
50
|
this.setPaintButtonHex(btnHex);
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
// Инициализация цвета кнопки "краска" из
|
|
53
|
+
// Инициализация цвета кнопки "краска" из настроек (или фона рендерера)
|
|
54
54
|
try {
|
|
55
|
-
const
|
|
55
|
+
const ap = window?.moodboard?.coreMoodboard?.settingsApplier;
|
|
56
|
+
const bgHex = (ap && ap.get && ap.get().backgroundColor) || this._getCurrentBoardBackgroundHex();
|
|
56
57
|
if (bgHex) {
|
|
57
|
-
|
|
58
|
+
this._currentBoardHex = String(bgHex).toLowerCase();
|
|
59
|
+
const mapped = this.mapBoardToBtnHex(this._currentBoardHex);
|
|
58
60
|
this.setPaintButtonHex(mapped);
|
|
59
61
|
}
|
|
60
62
|
} catch (_) {}
|
|
@@ -178,7 +180,7 @@ export class Topbar {
|
|
|
178
180
|
/** Возвращает текущий цвет фона канваса как hex-строку #RRGGBB */
|
|
179
181
|
_getCurrentBoardBackgroundHex() {
|
|
180
182
|
try {
|
|
181
|
-
const app = window?.moodboard?.core?.pixi?.app;
|
|
183
|
+
const app = window?.moodboard?.coreMoodboard?.pixi?.app || window?.moodboard?.core?.pixi?.app;
|
|
182
184
|
const colorInt = app?.renderer?.background?.color ?? app?.renderer?.backgroundColor;
|
|
183
185
|
if (typeof colorInt !== 'number') return null;
|
|
184
186
|
const hex = `#${colorInt.toString(16).padStart(6, '0')}`;
|
|
@@ -255,8 +257,9 @@ export class Topbar {
|
|
|
255
257
|
b.style.borderColor = darken(c.hex, 0.35);
|
|
256
258
|
// Цвет галочки — чёрный для максимальной видимости
|
|
257
259
|
b.style.color = '#111';
|
|
258
|
-
// Для надёжного сравнения — сохраняем
|
|
260
|
+
// Для надёжного сравнения — сохраняем оба значения в dataset
|
|
259
261
|
b.dataset.hex = String(c.hex).toLowerCase();
|
|
262
|
+
b.dataset.board = String(c.board).toLowerCase();
|
|
260
263
|
// Галочка по центру
|
|
261
264
|
const tick = document.createElement('i');
|
|
262
265
|
tick.className = 'moodboard-topbar__paint-tick';
|
|
@@ -279,11 +282,16 @@ export class Topbar {
|
|
|
279
282
|
});
|
|
280
283
|
pop.appendChild(grid);
|
|
281
284
|
|
|
282
|
-
// Выделяем активный цвет галочкой
|
|
285
|
+
// Выделяем активный цвет галочкой по фактическому boardHex
|
|
283
286
|
try {
|
|
284
|
-
const
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
+
const ap = window?.moodboard?.coreMoodboard?.settingsApplier;
|
|
288
|
+
const boardHex = (
|
|
289
|
+
(ap && ap.get && ap.get().backgroundColor) ||
|
|
290
|
+
this._currentBoardHex ||
|
|
291
|
+
this._getCurrentBoardBackgroundHex() ||
|
|
292
|
+
''
|
|
293
|
+
).toLowerCase();
|
|
294
|
+
const match = boardHex ? grid.querySelector(`[data-board="${boardHex}"]`) : null;
|
|
287
295
|
if (match) match.classList.add('is-active');
|
|
288
296
|
} catch (_) {}
|
|
289
297
|
|
|
@@ -293,16 +301,7 @@ export class Topbar {
|
|
|
293
301
|
pop.style.left = `${rect.left - this.element.getBoundingClientRect().left}px`;
|
|
294
302
|
pop.style.top = `${rect.bottom - this.element.getBoundingClientRect().top + 6}px`;
|
|
295
303
|
|
|
296
|
-
//
|
|
297
|
-
try {
|
|
298
|
-
const currentBtnHex = (this._paintBtn && getComputedStyle(this._paintBtn).getPropertyValue('--paint-btn-color')) || '';
|
|
299
|
-
const normalized = currentBtnHex.trim() || '#B3E5FC';
|
|
300
|
-
const match = Array.from(grid.children).find((el) => {
|
|
301
|
-
const bg = el && el.style && el.style.background ? el.style.background.toLowerCase() : '';
|
|
302
|
-
return bg === normalized.toLowerCase();
|
|
303
|
-
});
|
|
304
|
-
if (match) match.classList.add('is-active');
|
|
305
|
-
} catch (_) {}
|
|
304
|
+
// (дополнительная подсветка не требуется — см. блок выше)
|
|
306
305
|
|
|
307
306
|
this.element.appendChild(pop);
|
|
308
307
|
this._paintPopover = pop;
|