@razzusharma/accent-theme 2.0.1 → 2.0.2

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/dist/index.d.mts CHANGED
@@ -14,6 +14,7 @@ interface AccentThemeContextType {
14
14
  accentColor: AccentColor;
15
15
  setAccentColor: (color: AccentColor) => void;
16
16
  accentConfig: AccentColorConfig;
17
+ colors: Record<string, AccentColorConfig>;
17
18
  mounted: boolean;
18
19
  defaultColor: AccentColor;
19
20
  resetToDefault: () => void;
@@ -35,6 +36,7 @@ interface BaseComponentProps {
35
36
  interface AccentColorPickerProps extends BaseComponentProps {
36
37
  variant?: "dropdown" | "inline" | "menu";
37
38
  columns?: number;
39
+ align?: "start" | "center" | "end";
38
40
  onChange?: (color: AccentColor) => void;
39
41
  label?: string;
40
42
  showColorName?: boolean;
@@ -92,6 +94,7 @@ declare function useAccentColor(): {
92
94
  declare function useAccentDarkMode(): boolean;
93
95
 
94
96
  declare function AccentColorSwatch({ color, isSelected, onClick, size, className, showCheckmark, }: AccentColorSwatchProps): React.DetailedReactHTMLElement<{
97
+ type: string;
95
98
  onClick: (() => void) | undefined;
96
99
  className: string;
97
100
  style: {
@@ -102,7 +105,7 @@ declare function AccentColorSwatch({ color, isSelected, onClick, size, className
102
105
  "aria-label": string;
103
106
  "aria-pressed": boolean | undefined;
104
107
  }, HTMLElement> | null;
105
- declare function AccentColorPicker({ size, variant, columns, className, onChange, label, showColorName, }: AccentColorPickerProps): React.DetailedReactHTMLElement<{
108
+ declare function AccentColorPicker({ size, variant, columns, className, align, onChange, label, showColorName, }: AccentColorPickerProps): React.DetailedReactHTMLElement<{
106
109
  className: string;
107
110
  }, HTMLElement> | React.FunctionComponentElement<AccentColorMenuProps>;
108
111
  declare function AccentColorSwatches({ className, size, onChange, showCheckmark, gap, }: AccentColorSwatchesProps): React.DetailedReactHTMLElement<{
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ interface AccentThemeContextType {
14
14
  accentColor: AccentColor;
15
15
  setAccentColor: (color: AccentColor) => void;
16
16
  accentConfig: AccentColorConfig;
17
+ colors: Record<string, AccentColorConfig>;
17
18
  mounted: boolean;
18
19
  defaultColor: AccentColor;
19
20
  resetToDefault: () => void;
@@ -35,6 +36,7 @@ interface BaseComponentProps {
35
36
  interface AccentColorPickerProps extends BaseComponentProps {
36
37
  variant?: "dropdown" | "inline" | "menu";
37
38
  columns?: number;
39
+ align?: "start" | "center" | "end";
38
40
  onChange?: (color: AccentColor) => void;
39
41
  label?: string;
40
42
  showColorName?: boolean;
@@ -92,6 +94,7 @@ declare function useAccentColor(): {
92
94
  declare function useAccentDarkMode(): boolean;
93
95
 
94
96
  declare function AccentColorSwatch({ color, isSelected, onClick, size, className, showCheckmark, }: AccentColorSwatchProps): React.DetailedReactHTMLElement<{
97
+ type: string;
95
98
  onClick: (() => void) | undefined;
96
99
  className: string;
97
100
  style: {
@@ -102,7 +105,7 @@ declare function AccentColorSwatch({ color, isSelected, onClick, size, className
102
105
  "aria-label": string;
103
106
  "aria-pressed": boolean | undefined;
104
107
  }, HTMLElement> | null;
105
- declare function AccentColorPicker({ size, variant, columns, className, onChange, label, showColorName, }: AccentColorPickerProps): React.DetailedReactHTMLElement<{
108
+ declare function AccentColorPicker({ size, variant, columns, className, align, onChange, label, showColorName, }: AccentColorPickerProps): React.DetailedReactHTMLElement<{
106
109
  className: string;
107
110
  }, HTMLElement> | React.FunctionComponentElement<AccentColorMenuProps>;
108
111
  declare function AccentColorSwatches({ className, size, onChange, showCheckmark, gap, }: AccentColorSwatchesProps): React.DetailedReactHTMLElement<{
package/dist/index.js CHANGED
@@ -139,6 +139,7 @@ var defaultContext = {
139
139
  setAccentColor: () => {
140
140
  },
141
141
  accentConfig: defaultAccentColors.teal,
142
+ colors: defaultAccentColors,
142
143
  mounted: false,
143
144
  defaultColor: "teal",
144
145
  resetToDefault: () => {
@@ -240,6 +241,7 @@ function AccentThemeProvider({
240
241
  accentColor,
241
242
  setAccentColor,
242
243
  accentConfig: colors[accentColor] || colors[defaultColor],
244
+ colors,
243
245
  mounted,
244
246
  defaultColor,
245
247
  resetToDefault
@@ -317,6 +319,20 @@ var CheckmarkIcon = ({ className = "" }) => /* @__PURE__ */ (0, import_jsx_runti
317
319
  }
318
320
  ) });
319
321
  var ChevronIcon = ({ className = "" }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className, fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) });
322
+ var PaletteIcon = ({ className = "" }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { className, fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: [
323
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
324
+ "path",
325
+ {
326
+ strokeLinecap: "round",
327
+ strokeLinejoin: "round",
328
+ strokeWidth: 1.8,
329
+ d: "M12 3a9 9 0 100 18h1.4a2.6 2.6 0 000-5.2H11a1.5 1.5 0 010-3h4.8a3.2 3.2 0 003.2-3.2C19 6 15.9 3 12 3z"
330
+ }
331
+ ),
332
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "7.5", cy: "10.2", r: "1" }),
333
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "10.5", cy: "7.5", r: "1" }),
334
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "14.2", cy: "7.3", r: "1" })
335
+ ] });
320
336
  var ResetIcon = ({ className = "" }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { className, fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" }) });
321
337
  function AccentColorSwatch({
322
338
  color,
@@ -326,9 +342,11 @@ function AccentColorSwatch({
326
342
  className = "",
327
343
  showCheckmark = true
328
344
  }) {
329
- const config = defaultAccentColors[color];
345
+ const { colors } = useAccentTheme();
346
+ const config = colors[color] || defaultAccentColors[color];
330
347
  if (!config) return null;
331
348
  return React2.createElement("button", {
349
+ type: "button",
332
350
  onClick,
333
351
  className: `
334
352
  relative rounded-full transition-all duration-200 flex-shrink-0
@@ -354,11 +372,12 @@ function AccentColorPicker({
354
372
  variant = "dropdown",
355
373
  columns = 4,
356
374
  className = "",
375
+ align = "end",
357
376
  onChange,
358
377
  label = "Theme",
359
378
  showColorName = true
360
379
  }) {
361
- const { accentColor, setAccentColor, mounted } = useAccentTheme();
380
+ const { accentColor, setAccentColor, mounted, colors } = useAccentTheme();
362
381
  const { primary } = useAccentColor();
363
382
  const [isOpen, setIsOpen] = (0, import_react2.useState)(false);
364
383
  const dropdownRef = (0, import_react2.useRef)(null);
@@ -390,7 +409,7 @@ function AccentColorPicker({
390
409
  return React2.createElement("div", {
391
410
  className: `grid ${gapClasses.md} ${className}`,
392
411
  style: { gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` }
393
- }, Object.entries(defaultAccentColors).map(([color]) => {
412
+ }, Object.entries(colors).map(([color]) => {
394
413
  const isSelected = accentColor === color;
395
414
  return React2.createElement(AccentColorSwatch, {
396
415
  key: color,
@@ -406,7 +425,8 @@ function AccentColorPicker({
406
425
  size,
407
426
  className,
408
427
  onChange,
409
- label
428
+ label,
429
+ align
410
430
  });
411
431
  }
412
432
  return React2.createElement(
@@ -416,14 +436,14 @@ function AccentColorPicker({
416
436
  className: `relative inline-block ${className}`
417
437
  },
418
438
  React2.createElement("button", {
439
+ type: "button",
419
440
  onClick: () => setIsOpen(!isOpen),
420
441
  className: `
421
- flex items-center gap-2 px-3 py-2 rounded-lg
422
- bg-white dark:bg-gray-800
423
- border border-gray-200 dark:border-gray-700
424
- hover:bg-gray-50 dark:hover:bg-gray-700
425
- transition-colors focus:outline-none focus:ring-2
426
- focus:ring-offset-2 focus:ring-offset-white dark:focus:ring-offset-gray-900
442
+ flex items-center gap-2 px-3.5 py-2 rounded-full
443
+ text-slate-100 bg-slate-900/70 backdrop-blur-md
444
+ border border-white/10 hover:bg-slate-900/85
445
+ transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2
446
+ focus:ring-offset-slate-950 shadow-lg shadow-slate-950/30
427
447
  `,
428
448
  style: { ["--tw-ring-color"]: primary },
429
449
  "aria-expanded": isOpen,
@@ -431,16 +451,16 @@ function AccentColorPicker({
431
451
  }, [
432
452
  React2.createElement("div", {
433
453
  key: "swatch",
434
- className: "w-5 h-5 rounded-full shadow-sm",
454
+ className: "w-5 h-5 rounded-full shadow-sm ring-1 ring-white/20",
435
455
  style: { background: primary }
436
456
  }),
437
457
  showColorName && React2.createElement("span", {
438
458
  key: "label",
439
- className: "text-sm font-medium text-gray-700 dark:text-gray-300"
440
- }, defaultAccentColors[accentColor]?.name || label),
459
+ className: "text-sm font-medium text-slate-100"
460
+ }, colors[accentColor]?.name || label),
441
461
  React2.createElement(ChevronIcon, {
442
462
  key: "chevron",
443
- className: `w-4 h-4 text-gray-500 dark:text-gray-400 transition-transform duration-200 ${isOpen ? "rotate-180" : ""}`
463
+ className: `w-4 h-4 text-rose-300 transition-transform duration-200 ${isOpen ? "rotate-180" : ""}`
444
464
  })
445
465
  ]),
446
466
  isOpen && React2.createElement(React2.Fragment, {}, [
@@ -452,45 +472,75 @@ function AccentColorPicker({
452
472
  React2.createElement("div", {
453
473
  key: "dropdown",
454
474
  className: `
455
- absolute right-0 mt-2 p-3
456
- bg-white dark:bg-gray-800
457
- rounded-xl shadow-xl
458
- border border-gray-200 dark:border-gray-700
459
- z-50 min-w-[200px]
475
+ absolute right-0 mt-3 p-4
476
+ rounded-2xl z-50 min-w-[290px]
477
+ bg-gradient-to-b from-slate-800/95 to-slate-900/95
478
+ border border-slate-600/40
479
+ shadow-2xl shadow-slate-950/50 backdrop-blur-xl
460
480
  `,
461
481
  role: "listbox"
462
482
  }, [
483
+ React2.createElement("div", {
484
+ key: "header",
485
+ className: "flex items-start gap-3 mb-3"
486
+ }, [
487
+ React2.createElement("div", {
488
+ key: "icon-wrap",
489
+ className: "w-7 h-7 rounded-full grid place-items-center border border-rose-400/40 bg-rose-500/15"
490
+ }, React2.createElement(PaletteIcon, {
491
+ className: "w-4 h-4 text-rose-300"
492
+ })),
493
+ React2.createElement("div", { key: "titles" }, [
494
+ React2.createElement("p", {
495
+ key: "title",
496
+ className: "text-[1.15rem] font-semibold text-slate-100 leading-5"
497
+ }, "Theme Color"),
498
+ React2.createElement("p", {
499
+ key: "subtitle",
500
+ className: "text-sm text-slate-300 mt-1"
501
+ }, "Choose your preferred accent color")
502
+ ])
503
+ ]),
463
504
  React2.createElement("div", {
464
505
  key: "grid",
465
- className: "grid grid-cols-4 gap-2"
466
- }, Object.entries(defaultAccentColors).map(([color, config]) => {
506
+ className: "grid grid-cols-4 gap-3 border-t border-white/10 pt-4"
507
+ }, Object.entries(colors).map(([color, config]) => {
467
508
  const isSelected = accentColor === color;
468
509
  return React2.createElement("button", {
469
510
  key: color,
511
+ type: "button",
470
512
  onClick: () => handleColorChange(color),
471
513
  className: `
472
- relative w-10 h-10 rounded-lg transition-all duration-200
473
- hover:scale-110 focus:outline-none focus:ring-2 focus:ring-offset-2
474
- focus:ring-offset-white dark:focus:ring-offset-gray-900
475
- ${isSelected ? "ring-2 ring-offset-2 scale-105" : ""}
514
+ relative w-12 h-12 rounded-xl transition-all duration-200
515
+ hover:-translate-y-0.5 hover:brightness-110
516
+ focus:outline-none focus:ring-2 ring-offset-0
517
+ ${isSelected ? "ring-2 ring-white/70 scale-[1.03]" : "ring-1 ring-white/10"}
476
518
  `,
477
519
  style: {
478
- background: `hsl(${config.primary})`,
479
- ["--tw-ring-color"]: `hsl(${config.light})`
520
+ background: `hsl(${config.primary})`
480
521
  },
481
522
  title: config.name,
482
523
  role: "option",
483
524
  "aria-selected": isSelected
484
525
  }, isSelected && React2.createElement(CheckmarkIcon, {
485
- className: "absolute inset-0 w-full h-full p-2 text-white drop-shadow-md"
526
+ className: "absolute inset-0 w-full h-full p-3 text-white drop-shadow-md"
486
527
  }));
487
528
  })),
488
529
  React2.createElement("div", {
489
530
  key: "footer",
490
- className: "mt-3 pt-3 border-t border-gray-100 dark:border-gray-700"
491
- }, React2.createElement("p", {
492
- className: "text-xs text-gray-500 dark:text-gray-400 text-center"
493
- }, `Current: ${defaultAccentColors[accentColor]?.name || accentColor}`))
531
+ className: "mt-4 pt-4 border-t border-white/10 flex items-center justify-between gap-3"
532
+ }, [
533
+ React2.createElement("p", {
534
+ key: "current-text",
535
+ className: "text-[1.05rem] text-slate-200"
536
+ }, `Current: ${colors[accentColor]?.name || accentColor}`),
537
+ React2.createElement("span", {
538
+ key: "current-pill",
539
+ className: "w-14 h-7 rounded-full ring-1 ring-white/20",
540
+ style: { background: primary },
541
+ "aria-hidden": true
542
+ })
543
+ ])
494
544
  ])
495
545
  ])
496
546
  );
@@ -502,7 +552,7 @@ function AccentColorSwatches({
502
552
  showCheckmark = true,
503
553
  gap = "md"
504
554
  }) {
505
- const { accentColor, setAccentColor, mounted } = useAccentTheme();
555
+ const { accentColor, setAccentColor, mounted, colors } = useAccentTheme();
506
556
  const handleColorChange = (color) => {
507
557
  setAccentColor(color);
508
558
  onChange?.(color);
@@ -517,7 +567,7 @@ function AccentColorSwatches({
517
567
  }
518
568
  return React2.createElement("div", {
519
569
  className: `flex flex-wrap ${gapClasses[gap]} ${className}`
520
- }, Object.entries(defaultAccentColors).map(([color]) => {
570
+ }, Object.entries(colors).map(([color]) => {
521
571
  const isSelected = accentColor === color;
522
572
  return React2.createElement(AccentColorSwatch, {
523
573
  key: color,
@@ -536,7 +586,7 @@ function AccentColorMenu({
536
586
  align = "end",
537
587
  label = "Theme"
538
588
  }) {
539
- const { accentColor, setAccentColor, mounted } = useAccentTheme();
589
+ const { accentColor, setAccentColor, mounted, colors } = useAccentTheme();
540
590
  const { primary } = useAccentColor();
541
591
  const [isOpen, setIsOpen] = (0, import_react2.useState)(false);
542
592
  const menuRef = (0, import_react2.useRef)(null);
@@ -573,6 +623,7 @@ function AccentColorMenu({
573
623
  className: `relative inline-block ${className}`
574
624
  },
575
625
  React2.createElement("button", {
626
+ type: "button",
576
627
  onClick: () => setIsOpen(!isOpen),
577
628
  className: `
578
629
  flex items-center gap-2 px-3 py-2 rounded-lg
@@ -608,10 +659,11 @@ function AccentColorMenu({
608
659
  z-50 min-w-[160px]
609
660
  ${alignClasses[align]}
610
661
  `
611
- }, Object.entries(defaultAccentColors).map(([color, config]) => {
662
+ }, Object.entries(colors).map(([color, config]) => {
612
663
  const isSelected = accentColor === color;
613
664
  return React2.createElement("button", {
614
665
  key: color,
666
+ type: "button",
615
667
  onClick: () => handleColorChange(color),
616
668
  className: `
617
669
  w-full flex items-center gap-3 px-3 py-2 rounded-md
@@ -643,9 +695,9 @@ function AccentColorButton({
643
695
  showLabel = false,
644
696
  buttonVariant = "default"
645
697
  }) {
646
- const { accentColor, mounted } = useAccentTheme();
698
+ const { accentColor, mounted, colors } = useAccentTheme();
647
699
  const { primary } = useAccentColor();
648
- const colorConfig = defaultAccentColors[accentColor];
700
+ const colorConfig = colors[accentColor] || defaultAccentColors[accentColor];
649
701
  const variantClasses = {
650
702
  default: "bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-700",
651
703
  ghost: "hover:bg-gray-100 dark:hover:bg-gray-800",
@@ -662,6 +714,7 @@ function AccentColorButton({
662
714
  });
663
715
  }
664
716
  return React2.createElement("button", {
717
+ type: "button",
665
718
  onClick,
666
719
  className: `
667
720
  inline-flex items-center gap-2 rounded-lg
@@ -733,6 +786,7 @@ function AccentThemeReset({
733
786
  });
734
787
  }
735
788
  return React2.createElement("button", {
789
+ type: "button",
736
790
  onClick: handleReset,
737
791
  disabled: isDefault,
738
792
  className: `
@@ -757,9 +811,9 @@ function CurrentAccentIndicator({
757
811
  showName = false,
758
812
  pulseOnChange = false
759
813
  }) {
760
- const { accentColor, mounted } = useAccentTheme();
814
+ const { accentColor, mounted, colors } = useAccentTheme();
761
815
  const { primary } = useAccentColor();
762
- const config = defaultAccentColors[accentColor];
816
+ const config = colors[accentColor] || defaultAccentColors[accentColor];
763
817
  const [isPulsing, setIsPulsing] = (0, import_react2.useState)(false);
764
818
  const prevColorRef = (0, import_react2.useRef)(accentColor);
765
819
  (0, import_react2.useEffect)(() => {
@@ -810,7 +864,7 @@ function AccentColorGrid({
810
864
  showLabels = false,
811
865
  gap = "md"
812
866
  }) {
813
- const { accentColor, setAccentColor, mounted } = useAccentTheme();
867
+ const { accentColor, setAccentColor, mounted, colors } = useAccentTheme();
814
868
  const handleColorChange = (color) => {
815
869
  setAccentColor(color);
816
870
  onChange?.(color);
@@ -833,11 +887,12 @@ function AccentColorGrid({
833
887
  }
834
888
  return React2.createElement("div", {
835
889
  className: `grid ${gridCols[columns]} ${gapClasses[gap]} ${className}`
836
- }, Object.entries(defaultAccentColors).map(([color, config]) => {
890
+ }, Object.entries(colors).map(([color, config]) => {
837
891
  const isSelected = accentColor === color;
838
892
  if (showLabels) {
839
893
  return React2.createElement("button", {
840
894
  key: color,
895
+ type: "button",
841
896
  onClick: () => handleColorChange(color),
842
897
  className: `
843
898
  flex flex-col items-center gap-1.5 p-2 rounded-lg