@pathscale/ui 1.1.14 → 1.1.15

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.
@@ -110,56 +110,261 @@ const isNearColor = (color, item)=>{
110
110
  const lightnessDelta = Math.abs(color.hsl.l - item.lightness);
111
111
  return hueDelta <= 2 && saturationDelta <= 2 && lightnessDelta <= 2;
112
112
  };
113
- const COLORS = [
114
- createColorItem("outer-1", "rgb(80,80,80)", 47.631, -27.5),
115
- createColorItem("outer-2", "rgb(80,60,50)", 27.5, -47.631),
116
- createColorItem("outer-3", "rgb(80,50,50)", 0, -55),
117
- createColorItem("outer-4", "rgb(80,50,70)", -27.5, -47.631),
118
- createColorItem("outer-5", "rgb(70,50,80)", -47.631, -27.5),
119
- createColorItem("outer-6", "rgb(55,50,80)", -55, 0),
120
- createColorItem("outer-7", "rgb(50,55,80)", -47.631, 27.5),
121
- createColorItem("outer-8", "rgb(50,65,80)", -27.5, 47.631),
122
- createColorItem("outer-9", "rgb(50,80,80)", 0, 55),
123
- createColorItem("outer-10", "rgb(50,80,65)", 27.5, 47.631),
124
- createColorItem("outer-11", "rgb(55,80,50)", 47.631, 27.5),
125
- createColorItem("outer-12", "rgb(70,80,50)", 55, 0),
126
- createColorItem("middle-1", "rgb(245,245,61)", 34.641, -20),
127
- createColorItem("middle-2", "rgb(245,153,61)", 20, -34.641),
128
- createColorItem("middle-3", "rgb(245,61,61)", 0, -40),
129
- createColorItem("middle-4", "rgb(245,61,153)", -20, -34.641),
130
- createColorItem("middle-5", "rgb(245,61,245)", -34.641, -20),
131
- createColorItem("middle-6", "rgb(153,61,245)", -40, 0),
132
- createColorItem("middle-7", "rgb(61,61,245)", -34.641, 20),
133
- createColorItem("middle-8", "rgb(61,153,245)", -20, 34.641),
134
- createColorItem("middle-9", "rgb(61,245,245)", 0, 40),
135
- createColorItem("middle-10", "rgb(61,245,153)", 20, 34.641),
136
- createColorItem("middle-11", "rgb(61,245,61)", 34.641, 20),
137
- createColorItem("middle-12", "rgb(153,245,61)", 40, 0),
138
- createColorItem("inner-1", "rgb(240,217,194)", 10, -17.3205),
139
- createColorItem("inner-2", "rgb(240,194,217)", -10, -17.3205),
140
- createColorItem("inner-3", "rgb(217,194,240)", -20, 0),
141
- createColorItem("inner-4", "rgb(194,217,240)", -10, 17.3205),
142
- createColorItem("inner-5", "rgb(194,240,217)", 10, 17.3205),
143
- createColorItem("inner-6", "rgb(217,240,194)", 20, 0),
144
- createColorItem("center", "rgb(255,255,255)", 0, 0, {
113
+ const LAYOUT = [
114
+ {
115
+ id: "outer-1",
116
+ offsetX: 47.631,
117
+ offsetY: -27.5
118
+ },
119
+ {
120
+ id: "outer-2",
121
+ offsetX: 27.5,
122
+ offsetY: -47.631
123
+ },
124
+ {
125
+ id: "outer-3",
126
+ offsetX: 0,
127
+ offsetY: -55
128
+ },
129
+ {
130
+ id: "outer-4",
131
+ offsetX: -27.5,
132
+ offsetY: -47.631
133
+ },
134
+ {
135
+ id: "outer-5",
136
+ offsetX: -47.631,
137
+ offsetY: -27.5
138
+ },
139
+ {
140
+ id: "outer-6",
141
+ offsetX: -55,
142
+ offsetY: 0
143
+ },
144
+ {
145
+ id: "outer-7",
146
+ offsetX: -47.631,
147
+ offsetY: 27.5
148
+ },
149
+ {
150
+ id: "outer-8",
151
+ offsetX: -27.5,
152
+ offsetY: 47.631
153
+ },
154
+ {
155
+ id: "outer-9",
156
+ offsetX: 0,
157
+ offsetY: 55
158
+ },
159
+ {
160
+ id: "outer-10",
161
+ offsetX: 27.5,
162
+ offsetY: 47.631
163
+ },
164
+ {
165
+ id: "outer-11",
166
+ offsetX: 47.631,
167
+ offsetY: 27.5
168
+ },
169
+ {
170
+ id: "outer-12",
171
+ offsetX: 55,
172
+ offsetY: 0
173
+ },
174
+ {
175
+ id: "middle-1",
176
+ offsetX: 34.641,
177
+ offsetY: -20
178
+ },
179
+ {
180
+ id: "middle-2",
181
+ offsetX: 20,
182
+ offsetY: -34.641
183
+ },
184
+ {
185
+ id: "middle-3",
186
+ offsetX: 0,
187
+ offsetY: -40
188
+ },
189
+ {
190
+ id: "middle-4",
191
+ offsetX: -20,
192
+ offsetY: -34.641
193
+ },
194
+ {
195
+ id: "middle-5",
196
+ offsetX: -34.641,
197
+ offsetY: -20
198
+ },
199
+ {
200
+ id: "middle-6",
201
+ offsetX: -40,
202
+ offsetY: 0
203
+ },
204
+ {
205
+ id: "middle-7",
206
+ offsetX: -34.641,
207
+ offsetY: 20
208
+ },
209
+ {
210
+ id: "middle-8",
211
+ offsetX: -20,
212
+ offsetY: 34.641
213
+ },
214
+ {
215
+ id: "middle-9",
216
+ offsetX: 0,
217
+ offsetY: 40
218
+ },
219
+ {
220
+ id: "middle-10",
221
+ offsetX: 20,
222
+ offsetY: 34.641
223
+ },
224
+ {
225
+ id: "middle-11",
226
+ offsetX: 34.641,
227
+ offsetY: 20
228
+ },
229
+ {
230
+ id: "middle-12",
231
+ offsetX: 40,
232
+ offsetY: 0
233
+ },
234
+ {
235
+ id: "inner-1",
236
+ offsetX: 10,
237
+ offsetY: -17.3205
238
+ },
239
+ {
240
+ id: "inner-2",
241
+ offsetX: -10,
242
+ offsetY: -17.3205
243
+ },
244
+ {
245
+ id: "inner-3",
246
+ offsetX: -20,
247
+ offsetY: 0
248
+ },
249
+ {
250
+ id: "inner-4",
251
+ offsetX: -10,
252
+ offsetY: 17.3205
253
+ },
254
+ {
255
+ id: "inner-5",
256
+ offsetX: 10,
257
+ offsetY: 17.3205
258
+ },
259
+ {
260
+ id: "inner-6",
261
+ offsetX: 20,
262
+ offsetY: 0
263
+ },
264
+ {
265
+ id: "center",
266
+ offsetX: 0,
267
+ offsetY: 0,
145
268
  isCenter: true
146
- })
269
+ }
147
270
  ];
148
- const CENTER_INDEX = COLORS.findIndex((item)=>item.isCenter);
149
- const MAX_RADIUS = Math.max(...COLORS.map((item)=>Math.sqrt(item.offsetX ** 2 + item.offsetY ** 2)));
150
- const MAX_WAVE_DISTANCE = 2 * MAX_RADIUS;
151
- const MAX_WAVE_DELAY = 0.12;
152
- const RAINBOW_GRADIENT = `conic-gradient(
271
+ const LIGHT_RGBS = [
272
+ "rgb(249,168,37)",
273
+ "rgb(239,108,0)",
274
+ "rgb(198,40,40)",
275
+ "rgb(173,20,87)",
276
+ "rgb(106,27,154)",
277
+ "rgb(69,39,160)",
278
+ "rgb(40,53,147)",
279
+ "rgb(21,101,192)",
280
+ "rgb(0,131,143)",
281
+ "rgb(0,105,92)",
282
+ "rgb(46,125,50)",
283
+ "rgb(85,139,47)",
284
+ "rgb(255,235,59)",
285
+ "rgb(255,152,0)",
286
+ "rgb(244,67,54)",
287
+ "rgb(233,30,99)",
288
+ "rgb(156,39,176)",
289
+ "rgb(103,58,183)",
290
+ "rgb(63,81,181)",
291
+ "rgb(33,150,243)",
292
+ "rgb(0,188,212)",
293
+ "rgb(0,150,136)",
294
+ "rgb(76,175,80)",
295
+ "rgb(139,195,74)",
296
+ "rgb(239,154,154)",
297
+ "rgb(206,147,216)",
298
+ "rgb(144,202,249)",
299
+ "rgb(128,222,234)",
300
+ "rgb(165,214,167)",
301
+ "rgb(255,224,130)",
302
+ "rgb(255,255,255)"
303
+ ];
304
+ const DARK_RGBS = [
305
+ "rgb(255,238,88)",
306
+ "rgb(255,167,38)",
307
+ "rgb(239,83,80)",
308
+ "rgb(236,64,122)",
309
+ "rgb(171,71,188)",
310
+ "rgb(126,87,194)",
311
+ "rgb(92,107,192)",
312
+ "rgb(66,165,245)",
313
+ "rgb(38,198,218)",
314
+ "rgb(38,166,154)",
315
+ "rgb(102,187,106)",
316
+ "rgb(156,204,101)",
317
+ "rgb(255,245,157)",
318
+ "rgb(255,204,128)",
319
+ "rgb(239,154,154)",
320
+ "rgb(244,143,177)",
321
+ "rgb(206,147,216)",
322
+ "rgb(179,157,219)",
323
+ "rgb(159,168,218)",
324
+ "rgb(144,202,249)",
325
+ "rgb(128,222,234)",
326
+ "rgb(128,203,196)",
327
+ "rgb(165,214,167)",
328
+ "rgb(197,225,165)",
329
+ "rgb(255,205,210)",
330
+ "rgb(225,190,231)",
331
+ "rgb(187,222,251)",
332
+ "rgb(178,235,242)",
333
+ "rgb(200,230,201)",
334
+ "rgb(255,236,179)",
335
+ "rgb(255,255,255)"
336
+ ];
337
+ const LIGHT_RAINBOW = `conic-gradient(
338
+ from 0deg,
339
+ rgb(244,67,54) 0deg,
340
+ rgb(255,152,0) 30deg,
341
+ rgb(255,235,59) 60deg,
342
+ rgb(76,175,80) 120deg,
343
+ rgb(0,188,212) 180deg,
344
+ rgb(63,81,181) 240deg,
345
+ rgb(156,39,176) 300deg,
346
+ rgb(244,67,54) 360deg
347
+ )`;
348
+ const DARK_RAINBOW = `conic-gradient(
153
349
  from 0deg,
154
- rgb(245,61,61) 0deg,
155
- rgb(245,153,61) 30deg,
156
- rgb(245,245,61) 60deg,
157
- rgb(61,245,61) 120deg,
158
- rgb(61,245,245) 180deg,
159
- rgb(61,61,245) 240deg,
160
- rgb(245,61,245) 300deg,
161
- rgb(245,61,61) 360deg
350
+ rgb(239,154,154) 0deg,
351
+ rgb(255,204,128) 30deg,
352
+ rgb(255,245,157) 60deg,
353
+ rgb(165,214,167) 120deg,
354
+ rgb(128,222,234) 180deg,
355
+ rgb(159,168,218) 240deg,
356
+ rgb(206,147,216) 300deg,
357
+ rgb(239,154,154) 360deg
162
358
  )`;
359
+ function buildColors(rgbs) {
360
+ return LAYOUT.map((layout, i)=>createColorItem(layout.id, rgbs[i], layout.offsetX, layout.offsetY, layout.isCenter ? {
361
+ isCenter: true
362
+ } : void 0));
363
+ }
364
+ const CENTER_INDEX = LAYOUT.findIndex((l)=>l.isCenter);
365
+ const MAX_RADIUS = Math.max(...LAYOUT.map((l)=>Math.sqrt(l.offsetX ** 2 + l.offsetY ** 2)));
366
+ const MAX_WAVE_DISTANCE = 2 * MAX_RADIUS;
367
+ const MAX_WAVE_DELAY = 0.12;
163
368
  const ColorWheelFlower = (props)=>{
164
369
  const context = (0, __WEBPACK_EXTERNAL_MODULE__colorpickerContext_js_45c33b20__.useColorPickerContext)();
165
370
  const [selectedIndex, setSelectedIndex] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(null);
@@ -171,6 +376,22 @@ const ColorWheelFlower = (props)=>{
171
376
  active: false
172
377
  });
173
378
  const [pulseState, setPulseState] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(null);
379
+ const [currentTheme, setCurrentTheme] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)("undefined" != typeof document ? document.documentElement.getAttribute("data-theme") ?? "light" : "light");
380
+ if ("undefined" != typeof window) {
381
+ const observer = new MutationObserver(()=>{
382
+ const t = document.documentElement.getAttribute("data-theme");
383
+ setCurrentTheme("dark" === t ? "dark" : "light");
384
+ });
385
+ observer.observe(document.documentElement, {
386
+ attributes: true,
387
+ attributeFilter: [
388
+ "data-theme"
389
+ ]
390
+ });
391
+ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.onCleanup)(()=>observer.disconnect());
392
+ }
393
+ const colors = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>buildColors("dark" === currentTheme() ? DARK_RGBS : LIGHT_RGBS));
394
+ const rainbowGradient = ()=>"dark" === currentTheme() ? DARK_RAINBOW : LIGHT_RAINBOW;
174
395
  const reduceMotion = (0, __WEBPACK_EXTERNAL_MODULE__motion_index_js_58495715__.prefersReducedMotion)();
175
396
  const ringTransition = reduceMotion ? {
176
397
  duration: 0
@@ -188,11 +409,12 @@ const ColorWheelFlower = (props)=>{
188
409
  let outerRingControl = null;
189
410
  const closestIndex = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>{
190
411
  const current = context.color();
412
+ const items = colors();
191
413
  if (current.hsl.s <= 6 && current.hsl.l >= 95 && CENTER_INDEX >= 0) return CENTER_INDEX;
192
414
  let closest = 0;
193
415
  let bestScore = Number.POSITIVE_INFINITY;
194
- for(let index = 0; index < COLORS.length; index += 1){
195
- const item = COLORS[index];
416
+ for(let index = 0; index < items.length; index += 1){
417
+ const item = items[index];
196
418
  if (item.isCenter) continue;
197
419
  const hueDelta = hueDistance(current.hsl.h, item.hue);
198
420
  const saturationDelta = Math.abs(current.hsl.s - item.saturation);
@@ -219,11 +441,12 @@ const ColorWheelFlower = (props)=>{
219
441
  };
220
442
  const handlePickerChange = (selectedHex)=>{
221
443
  if (context.disabled()) return;
222
- const index = COLORS.findIndex((item)=>item.hex === selectedHex.toUpperCase());
444
+ const items = colors();
445
+ const index = items.findIndex((item)=>item.hex === selectedHex.toUpperCase());
223
446
  if (index < 0) return;
224
447
  triggerPulse(index);
225
448
  const selected = selectedIndex();
226
- const item = COLORS[index];
449
+ const item = items[index];
227
450
  if (selected === index && !item.isCenter) {
228
451
  setSelectedIndex(null);
229
452
  context.onChange((0, __WEBPACK_EXTERNAL_MODULE__ColorUtils_js_8c38ee50__.createColorFromHsl)(0, 0, 100, context.color().hsl.a));
@@ -237,7 +460,7 @@ const ColorWheelFlower = (props)=>{
237
460
  const selected = selectedIndex();
238
461
  const current = context.color();
239
462
  if (null === selected) return;
240
- const selectedItem = COLORS[selected];
463
+ const selectedItem = colors()[selected];
241
464
  if (!selectedItem) return;
242
465
  if (!isNearColor(current, selectedItem)) setSelectedIndex(null);
243
466
  });
@@ -269,8 +492,8 @@ const ColorWheelFlower = (props)=>{
269
492
  };
270
493
  const outerRingBackground = ()=>{
271
494
  const selected = selectedIndex();
272
- if (null === selected) return RAINBOW_GRADIENT;
273
- const color = COLORS[selected];
495
+ if (null === selected) return rainbowGradient();
496
+ const color = colors()[selected];
274
497
  return `conic-gradient(${color.rgb}, ${color.rgb})`;
275
498
  };
276
499
  const outerRingTarget = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>{
@@ -295,7 +518,7 @@ const ColorWheelFlower = (props)=>{
295
518
  if (context.disabled()) return "none";
296
519
  const index = hoveredIndex() ?? selectedIndex();
297
520
  if (null === index) return "0 0 10px rgba(255,255,255,0.08)";
298
- const color = COLORS[index].rgb;
521
+ const color = colors()[index].rgb;
299
522
  return `0 0 10px rgba(255,255,255,0.16), 0 0 20px ${toRgba(color, 0.35)}`;
300
523
  });
301
524
  (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
@@ -309,7 +532,7 @@ const ColorWheelFlower = (props)=>{
309
532
  if (void 0 !== pulseTimeout) clearTimeout(pulseTimeout);
310
533
  if (void 0 !== pointerTimeout) clearTimeout(pointerTimeout);
311
534
  });
312
- const pickerValue = ()=>COLORS[visualSelectedIndex()]?.hex;
535
+ const pickerValue = ()=>colors()[visualSelectedIndex()]?.hex;
313
536
  return (()=>{
314
537
  var _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.firstChild;
315
538
  _el$.addEventListener("mouseleave", handlePointerLeave);
@@ -331,7 +554,9 @@ const ColorWheelFlower = (props)=>{
331
554
  "aria-label": "Flower color palette",
332
555
  get children () {
333
556
  return (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(__WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.For, {
334
- each: COLORS,
557
+ get each () {
558
+ return colors();
559
+ },
335
560
  children: (item, index)=>{
336
561
  let motionRef;
337
562
  let dotControl = null;
@@ -346,12 +571,12 @@ const ColorWheelFlower = (props)=>{
346
571
  y: 0
347
572
  };
348
573
  const pointerState = pointer();
349
- const anchorIndex = hoveredIndex();
574
+ const anchorIdx = hoveredIndex();
350
575
  let scale = 1;
351
576
  let offsetX = 0;
352
577
  let offsetY = 0;
353
- if (null !== anchorIndex && pointerState.active) {
354
- const anchor = COLORS[anchorIndex];
578
+ if (null !== anchorIdx && pointerState.active) {
579
+ const anchor = colors()[anchorIdx];
355
580
  const distance = Math.sqrt((item.offsetX - anchor.offsetX) ** 2 + (item.offsetY - anchor.offsetY) ** 2);
356
581
  const waveRadius = 0.9 * MAX_RADIUS;
357
582
  const influence = Math.max(0, 1 - distance / waveRadius);
@@ -397,11 +622,11 @@ const ColorWheelFlower = (props)=>{
397
622
  if (reduceMotion) return {
398
623
  duration: 0
399
624
  };
400
- const anchorIndex = hoveredIndex();
625
+ const anchorIdx = hoveredIndex();
401
626
  const pointerState = pointer();
402
627
  let delay = 0;
403
- if (null !== anchorIndex && pointerState.active) {
404
- const anchor = COLORS[anchorIndex];
628
+ if (null !== anchorIdx && pointerState.active) {
629
+ const anchor = colors()[anchorIdx];
405
630
  const distance = Math.sqrt((item.offsetX - anchor.offsetX) ** 2 + (item.offsetY - anchor.offsetY) ** 2);
406
631
  delay = Math.min(MAX_WAVE_DELAY, distance / MAX_WAVE_DISTANCE * MAX_WAVE_DELAY);
407
632
  }
@@ -10,6 +10,10 @@ export interface ThemeColorPickerProps extends IComponentBaseProps {
10
10
  * Callback when color changes
11
11
  */
12
12
  onColorChange?: (hue: number | null, saturation: number) => void;
13
+ /**
14
+ * Callback to switch light/dark theme (triggered by grayscale selection)
15
+ */
16
+ onThemeSwitch?: (theme: "light" | "dark") => void;
13
17
  /**
14
18
  * ARIA label for the button
15
19
  */
@@ -16,6 +16,7 @@ const ThemeColorPicker_ThemeColorPicker = (props)=>{
16
16
  const [local, others] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.splitProps)(props, [
17
17
  "storagePrefix",
18
18
  "onColorChange",
19
+ "onThemeSwitch",
19
20
  "aria-label",
20
21
  "children",
21
22
  "class",
@@ -73,6 +74,8 @@ const ThemeColorPicker_ThemeColorPicker = (props)=>{
73
74
  const handleGrayscale = (lightnessOffset)=>{
74
75
  store().setHueShift(0, 0, lightnessOffset);
75
76
  local.onColorChange?.(null, 0);
77
+ if (lightnessOffset >= 5) local.onThemeSwitch?.("light");
78
+ else if (lightnessOffset <= -10) local.onThemeSwitch?.("dark");
76
79
  };
77
80
  (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
78
81
  if (!isOpen()) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pathscale/ui",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
4
4
  "author": "pathscale",
5
5
  "repository": {
6
6
  "type": "git",