@sequent-org/moodboard 1.2.62 → 1.2.63

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 +21 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sequent-org/moodboard",
3
- "version": "1.2.62",
3
+ "version": "1.2.63",
4
4
  "type": "module",
5
5
  "description": "Interactive moodboard",
6
6
  "main": "./src/index.js",
package/src/ui/Topbar.js CHANGED
@@ -199,12 +199,32 @@ export class Topbar {
199
199
  setPaintButtonHex(btnHex) {
200
200
  if (!btnHex) return;
201
201
  if (this._paintBtn) {
202
- try { this._paintBtn.style.setProperty('--paint-btn-color', btnHex); } catch (_) {}
202
+ try {
203
+ this._paintBtn.style.setProperty('--paint-btn-color', btnHex);
204
+ // Прямое применение фона/бордера, чтобы цвет был виден сразу
205
+ this._paintBtn.style.background = btnHex;
206
+ const darker = this._darkenHex ? this._darkenHex(btnHex, 0.35) : btnHex;
207
+ this._paintBtn.style.borderColor = darker;
208
+ } catch (_) {}
203
209
  } else {
204
210
  this._pendingPaintHex = btnHex;
205
211
  }
206
212
  }
207
213
 
214
+ /** Утилита: затемнить hex-цвет на долю amount */
215
+ _darkenHex(hex, amount = 0.25) {
216
+ try {
217
+ const h = String(hex).replace('#','');
218
+ const r = parseInt(h.substring(0,2), 16);
219
+ const g = parseInt(h.substring(2,4), 16);
220
+ const b = parseInt(h.substring(4,6), 16);
221
+ const dr = Math.max(0, Math.min(255, Math.round(r * (1 - amount))));
222
+ const dg = Math.max(0, Math.min(255, Math.round(g * (1 - amount))));
223
+ const db = Math.max(0, Math.min(255, Math.round(b * (1 - amount))));
224
+ return `#${dr.toString(16).padStart(2,'0')}${dg.toString(16).padStart(2,'0')}${db.toString(16).padStart(2,'0')}`;
225
+ } catch (_) { return hex; }
226
+ }
227
+
208
228
  setActive(type) {
209
229
  const buttons = this.element.querySelectorAll('.moodboard-topbar__button');
210
230
  buttons.forEach((b) => b.classList.remove('moodboard-topbar__button--active'));