@marianmeres/stuic 2.1.5 → 2.1.7

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.
@@ -31,6 +31,9 @@
31
31
  classMenuLi?: string;
32
32
  classButton?: string;
33
33
  classSpinnerBox?: string;
34
+ defaultIcons?: Partial<
35
+ Record<"info" | "success" | "warn" | "error" | "spinner", () => string | undefined>
36
+ >;
34
37
  }
35
38
 
36
39
  let {
@@ -49,6 +52,7 @@
49
52
  classMenuLi,
50
53
  classButton,
51
54
  classSpinnerBox,
55
+ defaultIcons = acpDefaultIcons,
52
56
  }: Props = $props();
53
57
 
54
58
  let current = $derived(acp?.current!);
@@ -56,7 +60,7 @@
56
60
  let iconFn = $derived.by(() => {
57
61
  let out = current.iconFn;
58
62
  if (current.iconFn === true) {
59
- out = acpDefaultIcons[current.variant];
63
+ out = defaultIcons[current.variant];
60
64
  }
61
65
  return out;
62
66
  });
@@ -15,6 +15,7 @@ interface Props {
15
15
  classMenuLi?: string;
16
16
  classButton?: string;
17
17
  classSpinnerBox?: string;
18
+ defaultIcons?: Partial<Record<"info" | "success" | "warn" | "error" | "spinner", () => string | undefined>>;
18
19
  }
19
20
  declare const Current: import("svelte").Component<Props, {}, "isPending">;
20
21
  type Current = ReturnType<typeof Current>;
@@ -9,12 +9,13 @@
9
9
  rounded-md
10
10
  inline-flex items-center justify-center gap-x-2
11
11
  px-3 py-2
12
+ select-none
12
13
 
13
- hover:brightness-[1.05]
14
- active:brightness-[0.95]
14
+ hover:brightness-105
15
+ active:brightness-95
15
16
  disabled:hover:brightness-100
16
17
 
17
- focus:brightness-[1.05]
18
+ focus:brightness-105
18
19
  focus:border-button-border-focus focus:dark:border-button-border-focus-dark
19
20
 
20
21
  focus:outline-4 focus:outline-black/10 focus:dark:outline-white/20
@@ -42,6 +43,11 @@
42
43
  active:shadow-none active:translate-[1px]
43
44
  disabled:shadow-none disabled:active:shadow-none disabled:active:translate-none
44
45
  `,
46
+ inverse: `
47
+ bg-transparent dark:bg-transparent
48
+ hover:bg-button-bg hover:dark:bg-button-bg-dark
49
+ hover:brightness-100
50
+ `,
45
51
  };
46
52
  </script>
47
53
 
@@ -58,7 +64,9 @@
58
64
  size?: "sm" | "md" | "lg" | string;
59
65
  muted?: boolean;
60
66
  noshadow?: boolean;
67
+ noborder?: boolean;
61
68
  unstyled?: boolean;
69
+ inverse?: boolean; // a.k.a. formerly "outlined"
62
70
  class?: string;
63
71
  href?: string;
64
72
  children?: Snippet<[{ checked?: boolean }]>;
@@ -74,6 +82,8 @@
74
82
  class: classProp,
75
83
  muted,
76
84
  noshadow,
85
+ noborder,
86
+ inverse,
77
87
  unstyled,
78
88
  href,
79
89
  children,
@@ -108,12 +118,15 @@
108
118
  size,
109
119
  muted && "muted",
110
120
  noshadow && "no-shadow",
121
+ noborder && "border-none",
122
+ inverse && "inverse",
111
123
  // now, attach the default tw classes (unless not explicitly forbidden)
112
124
  !unstyled && _base,
113
125
  !unstyled && size && _preset.size[size],
114
126
  !unstyled && variant && _preset.variant[variant],
115
127
  !unstyled && muted && _preset.muted,
116
128
  !unstyled && !noshadow && _preset.shadow,
129
+ !unstyled && inverse && _preset.inverse,
117
130
  ]
118
131
  .filter(Boolean)
119
132
  .join(" ")
@@ -1,4 +1,4 @@
1
- export declare const BUTTON_STUIC_BASE_CLASSES = "\n\t\tbg-button-bg text-button-text \n\t\tdark:bg-button-bg-dark dark:text-button-text-dark\n\t\tfont-mono text-sm text-center \n\t\tleading-none\n\t\tborder-1\n\t\tborder-button-border dark:border-button-border-dark\n\t\trounded-md\n\t\tinline-flex items-center justify-center gap-x-2\n\t\tpx-3 py-2\n\n\t\thover:brightness-[1.05]\n\t\tactive:brightness-[0.95]\n\t\tdisabled:hover:brightness-100\n\n\t\tfocus:brightness-[1.05] \n\t\tfocus:border-button-border-focus focus:dark:border-button-border-focus-dark\n\n\t\t focus:outline-4 focus:outline-black/10 focus:dark:outline-white/20\n\t\tfocus-visible:outline-4 focus-visible:outline-black/10 focus-visible:dark:outline-white/20\n\t";
1
+ export declare const BUTTON_STUIC_BASE_CLASSES = "\n\t\tbg-button-bg text-button-text \n\t\tdark:bg-button-bg-dark dark:text-button-text-dark\n\t\tfont-mono text-sm text-center \n\t\tleading-none\n\t\tborder-1\n\t\tborder-button-border dark:border-button-border-dark\n\t\trounded-md\n\t\tinline-flex items-center justify-center gap-x-2\n\t\tpx-3 py-2\n\t\tselect-none\n\n\t\thover:brightness-105\n\t\tactive:brightness-95\n\t\tdisabled:hover:brightness-100\n\n\t\tfocus:brightness-105\n\t\tfocus:border-button-border-focus focus:dark:border-button-border-focus-dark\n\n\t\t focus:outline-4 focus:outline-black/10 focus:dark:outline-white/20\n\t\tfocus-visible:outline-4 focus-visible:outline-black/10 focus-visible:dark:outline-white/20\n\t";
2
2
  export declare const BUTTON_STUIC_PRESET_CLASSES: any;
3
3
  import type { Snippet } from "svelte";
4
4
  import type { HTMLButtonAttributes } from "svelte/elements";
@@ -8,7 +8,9 @@ interface Props extends HTMLButtonAttributes {
8
8
  size?: "sm" | "md" | "lg" | string;
9
9
  muted?: boolean;
10
10
  noshadow?: boolean;
11
+ noborder?: boolean;
11
12
  unstyled?: boolean;
13
+ inverse?: boolean;
12
14
  class?: string;
13
15
  href?: string;
14
16
  children?: Snippet<[{
@@ -7,7 +7,7 @@
7
7
  --color-button-text-dark: var(--color-button-text-dark, var(--color-white));
8
8
 
9
9
  --color-button-border: var(--color-button-border, var(--color-neutral-400));
10
- --color-button-border-dark: var(--color-button-border-dark, var(--color-neutral-800));
10
+ --color-button-border-dark: var(--color-button-border-dark, var(--color-neutral-600));
11
11
 
12
12
  --color-button-border-focus: var(--color-button-border-focus, var(--color-neutral-500));
13
13
  --color-button-border-focus-dark: var(--color-button-border-focus-dark, var(--color-neutral-500));
@@ -93,7 +93,7 @@
93
93
 
94
94
  transition-colors duration-100
95
95
 
96
- hover:brightness-[1.05] active:brightness-[0.95]
96
+ hover:brightness-105 active:brightness-95
97
97
  data-[disabled=true]:!cursor-not-allowed data-[disabled=true]:!opacity-50 data-[disabled=true]:hover:brightness-100
98
98
 
99
99
  bg-neutral-400 dark:bg-neutral-400
@@ -68,7 +68,7 @@
68
68
 
69
69
  transition-colors duration-100
70
70
 
71
- hover:brightness-[1.05] active:brightness-[0.95]
71
+ hover:brightness-105 active:brightness-95
72
72
  disabled:!cursor-not-allowed disabled:!opacity-50 disabled:hover:brightness-100
73
73
 
74
74
  bg-neutral-400 dark:bg-neutral-400
package/dist/index.css CHANGED
@@ -29,6 +29,6 @@ so, since we need to override, sticking with that*/
29
29
  [role="button"]:disabled,
30
30
  input:disabled {
31
31
  cursor: not-allowed !important;
32
- opacity: 0.5 !important;
32
+ /* opacity: 0.5 !important; */
33
33
  }
34
34
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ /**
3
+ * Converts a hex color string to OKLCH
4
+ * @param {string} hex - The hex color string (with or without leading #)
5
+ * @returns {Object} An object with l (lightness), c (chroma), and h (hue) properties
6
+ */
7
+ function hexToOklch(hex) {
8
+ // Remove the hash if it exists
9
+ hex = hex.replace(/^#/, "");
10
+ // Handle both 3-digit and 6-digit formats
11
+ if (hex.length === 3) {
12
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
13
+ }
14
+ // Parse the hex values to RGB (0-1)
15
+ const r = parseInt(hex.substring(0, 2), 16) / 255;
16
+ const g = parseInt(hex.substring(2, 4), 16) / 255;
17
+ const b = parseInt(hex.substring(4, 6), 16) / 255;
18
+ // Convert RGB to linear RGB (removing gamma correction)
19
+ const linearR = r <= 0.04045 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4);
20
+ const linearG = g <= 0.04045 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4);
21
+ const linearB = b <= 0.04045 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4);
22
+ // Convert to XYZ
23
+ const x = 0.4124 * linearR + 0.3576 * linearG + 0.1805 * linearB;
24
+ const y = 0.2126 * linearR + 0.7152 * linearG + 0.0722 * linearB;
25
+ const z = 0.0193 * linearR + 0.1192 * linearG + 0.9505 * linearB;
26
+ // Convert XYZ to LMS (cone response)
27
+ const l = 0.819 * x + 0.3619 * y - 0.1289 * z;
28
+ const m = 0.0329 * x + 0.9293 * y + 0.0361 * z;
29
+ const s = 0.0482 * x + 0.2645 * y + 0.6886 * z;
30
+ // Apply non-linearity to LMS
31
+ const lp = Math.cbrt(l);
32
+ const mp = Math.cbrt(m);
33
+ const sp = Math.cbrt(s);
34
+ // Convert to Oklab
35
+ const L = 0.2104 * lp + 0.7936 * mp - 0.004 * sp;
36
+ const a = 1.9779 * lp - 2.4285 * mp + 0.4505 * sp;
37
+ const bb = 0.0259 * lp + 0.7827 * mp - 0.8086 * sp;
38
+ // Convert Oklab to Oklch
39
+ const C = Math.sqrt(a * a + bb * bb);
40
+ let h = (Math.atan2(bb, a) * 180) / Math.PI;
41
+ // Ensure hue is positive
42
+ if (h < 0) {
43
+ h += 360;
44
+ }
45
+ return {
46
+ l: parseFloat(L.toFixed(4)),
47
+ c: parseFloat(C.toFixed(4)),
48
+ h: parseFloat(h.toFixed(2)),
49
+ };
50
+ }
51
+ // Example usage:
52
+ // const oklch = hexToOklch("#ff5733");
53
+ // console.log(oklch); // Example output: { l: 0.6321, c: 0.1549, h: 27.23 }
@@ -0,0 +1,6 @@
1
+ /** Will convert #fff or #ffffff to {r: 255, g: 255, b: 255} */
2
+ export declare function hexToRgb(hex: string): {
3
+ r: number;
4
+ g: number;
5
+ b: number;
6
+ };
@@ -0,0 +1,12 @@
1
+ /** Will convert #fff or #ffffff to {r: 255, g: 255, b: 255} */
2
+ export function hexToRgb(hex) {
3
+ hex = hex.replace(/^#/, "");
4
+ // both 3-digit and 6-digit formats
5
+ if (hex.length === 3) {
6
+ hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
7
+ }
8
+ const r = parseInt(hex.substring(0, 2), 16);
9
+ const g = parseInt(hex.substring(2, 4), 16);
10
+ const b = parseInt(hex.substring(4, 6), 16);
11
+ return { r, g, b };
12
+ }
@@ -5,6 +5,8 @@ export * from "./escape-regex.js";
5
5
  export * from "./event-emitter.js";
6
6
  export * from "./event-modifiers.js";
7
7
  export * from "./get-id.js";
8
+ export * from "./hex-to-oklch.js";
9
+ export * from "./hex-to-rgb.js";
8
10
  export * from "./is-browser.js";
9
11
  export * from "./is-mac.js";
10
12
  export * from "./is-nullish.js";
@@ -5,6 +5,8 @@ export * from "./escape-regex.js";
5
5
  export * from "./event-emitter.js";
6
6
  export * from "./event-modifiers.js";
7
7
  export * from "./get-id.js";
8
+ export * from "./hex-to-oklch.js";
9
+ export * from "./hex-to-rgb.js";
8
10
  export * from "./is-browser.js";
9
11
  export * from "./is-mac.js";
10
12
  export * from "./is-nullish.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",