@sequent-org/moodboard 1.2.53 → 1.2.54

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/ui/Topbar.js +14 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequent-org/moodboard",
3
- "version": "1.2.53",
3
+ "version": "1.2.54",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
package/src/ui/Topbar.js CHANGED
@@ -277,11 +277,21 @@ export class Topbar {
277
277
  });
278
278
  pop.appendChild(grid);
279
279
 
280
- // Выделяем активный цвет галочкой
280
+ // Выделяем активный цвет галочкой (надежно — по data-hex)
281
281
  try {
282
+ // 1) Пытаемся получить текущий цвет фона канваса
282
283
  const boardHex = this._getCurrentBoardBackgroundHex();
283
- const targetHex = (this.mapBoardToBtnHex(boardHex) || '#B3E5FC').toLowerCase();
284
- const match = grid.querySelector(`[data-hex="${targetHex}"]`);
284
+ // 2) Маппим к hex кнопки палитры
285
+ let targetHex = this.mapBoardToBtnHex(boardHex || '') || '';
286
+ // 3) Если не удалось — пробуем взять цвет с кнопки (custom prop)
287
+ if (!targetHex && this._paintBtn) {
288
+ const prop = getComputedStyle(this._paintBtn).getPropertyValue('--paint-btn-color') || '';
289
+ targetHex = prop.trim();
290
+ }
291
+ // 4) Фолбэк — первый цвет из палитры
292
+ if (!targetHex) targetHex = '#B3E5FC';
293
+ const normalized = String(targetHex).trim().toLowerCase();
294
+ const match = grid.querySelector(`[data-hex="${normalized}"]`);
285
295
  if (match) match.classList.add('is-active');
286
296
  } catch (_) {}
287
297
 
@@ -291,16 +301,7 @@ export class Topbar {
291
301
  pop.style.left = `${rect.left - this.element.getBoundingClientRect().left}px`;
292
302
  pop.style.top = `${rect.bottom - this.element.getBoundingClientRect().top + 6}px`;
293
303
 
294
- // Подсветить текущий активный кружок галочкой)
295
- try {
296
- const currentBtnHex = (this._paintBtn && getComputedStyle(this._paintBtn).getPropertyValue('--paint-btn-color')) || '';
297
- const normalized = currentBtnHex.trim() || '#B3E5FC';
298
- const match = Array.from(grid.children).find((el) => {
299
- const bg = el && el.style && el.style.background ? el.style.background.toLowerCase() : '';
300
- return bg === normalized.toLowerCase();
301
- });
302
- if (match) match.classList.add('is-active');
303
- } catch (_) {}
304
+ // (дополнительная подсветка не требуется активируем по data-hex выше)
304
305
 
305
306
  this.element.appendChild(pop);
306
307
  this._paintPopover = pop;