@thesage/ui 0.0.12 → 0.0.13
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/README.md +5 -5
- package/dist/index.d.mts +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +89 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -51
- package/dist/index.mjs.map +1 -1
- package/dist/providers.js +44 -0
- package/dist/providers.js.map +1 -1
- package/dist/providers.mjs +44 -0
- package/dist/providers.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9558,13 +9558,30 @@ var AnimatedBeam = ({
|
|
|
9558
9558
|
import { Mesh as Mesh3, Program as Program3, Renderer as Renderer3, Triangle as Triangle3, Vec3 } from "ogl";
|
|
9559
9559
|
import { useEffect as useEffect12, useRef as useRef5 } from "react";
|
|
9560
9560
|
import { jsx as jsx85 } from "react/jsx-runtime";
|
|
9561
|
+
function hexToRgb4(hex) {
|
|
9562
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
9563
|
+
if (!result) return [0, 0, 0];
|
|
9564
|
+
return [
|
|
9565
|
+
parseInt(result[1], 16) / 255,
|
|
9566
|
+
parseInt(result[2], 16) / 255,
|
|
9567
|
+
parseInt(result[3], 16) / 255
|
|
9568
|
+
];
|
|
9569
|
+
}
|
|
9570
|
+
function getCSSVariable2(name, fallback) {
|
|
9571
|
+
if (typeof window === "undefined") return fallback;
|
|
9572
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue(name).trim();
|
|
9573
|
+
return value || fallback;
|
|
9574
|
+
}
|
|
9561
9575
|
function OrbBackground({
|
|
9562
9576
|
className,
|
|
9563
9577
|
hue = 0,
|
|
9564
9578
|
hoverIntensity = 0.2,
|
|
9565
9579
|
rotateOnHover = true,
|
|
9566
9580
|
forceHoverState = false,
|
|
9567
|
-
backgroundColor
|
|
9581
|
+
backgroundColor,
|
|
9582
|
+
orbColor1,
|
|
9583
|
+
orbColor2,
|
|
9584
|
+
orbColor3
|
|
9568
9585
|
}) {
|
|
9569
9586
|
const ctnDom = useRef5(null);
|
|
9570
9587
|
const vert = (
|
|
@@ -9592,6 +9609,10 @@ function OrbBackground({
|
|
|
9592
9609
|
uniform float rot;
|
|
9593
9610
|
uniform float hoverIntensity;
|
|
9594
9611
|
uniform vec3 backgroundColor;
|
|
9612
|
+
// THEME-AWARE: Orb colors from theme (to revert: change back to const)
|
|
9613
|
+
uniform vec3 orbColor1;
|
|
9614
|
+
uniform vec3 orbColor2;
|
|
9615
|
+
uniform vec3 orbColor3;
|
|
9595
9616
|
varying vec2 vUv;
|
|
9596
9617
|
|
|
9597
9618
|
vec3 rgb2yiq(vec3 c) {
|
|
@@ -9660,10 +9681,12 @@ function OrbBackground({
|
|
|
9660
9681
|
float a = max(max(colorIn.r, colorIn.g), colorIn.b);
|
|
9661
9682
|
return vec4(colorIn.rgb / (a + 1e-5), a);
|
|
9662
9683
|
}
|
|
9663
|
-
|
|
9664
|
-
|
|
9665
|
-
|
|
9666
|
-
const vec3
|
|
9684
|
+
|
|
9685
|
+
// THEME-AWARE: Colors now come from uniforms (orbColor1, orbColor2, orbColor3)
|
|
9686
|
+
// To revert to hardcoded: uncomment these and remove uniforms above
|
|
9687
|
+
// const vec3 baseColor1 = vec3(0.611765, 0.262745, 0.996078);
|
|
9688
|
+
// const vec3 baseColor2 = vec3(0.298039, 0.760784, 0.913725);
|
|
9689
|
+
// const vec3 baseColor3 = vec3(0.062745, 0.078431, 0.600000);
|
|
9667
9690
|
const float innerRadius = 0.6;
|
|
9668
9691
|
const float noiseScale = 0.65;
|
|
9669
9692
|
|
|
@@ -9676,9 +9699,10 @@ function OrbBackground({
|
|
|
9676
9699
|
}
|
|
9677
9700
|
|
|
9678
9701
|
vec4 draw(vec2 uv) {
|
|
9679
|
-
|
|
9680
|
-
vec3
|
|
9681
|
-
vec3
|
|
9702
|
+
// THEME-AWARE: Use uniform colors instead of hardcoded consts
|
|
9703
|
+
vec3 color1 = adjustHue(orbColor1, hue);
|
|
9704
|
+
vec3 color2 = adjustHue(orbColor2, hue);
|
|
9705
|
+
vec3 color3 = adjustHue(orbColor3, hue);
|
|
9682
9706
|
|
|
9683
9707
|
float ang = atan(uv.y, uv.x);
|
|
9684
9708
|
float len = length(uv);
|
|
@@ -9747,6 +9771,14 @@ function OrbBackground({
|
|
|
9747
9771
|
useEffect12(() => {
|
|
9748
9772
|
const container = ctnDom.current;
|
|
9749
9773
|
if (!container) return;
|
|
9774
|
+
const bgColor = backgroundColor || getCSSVariable2("--color-background", "#000000");
|
|
9775
|
+
const color1 = orbColor1 || "#9c43fe";
|
|
9776
|
+
const color2 = orbColor2 || "#4cc2e9";
|
|
9777
|
+
const color3 = orbColor3 || "#101499";
|
|
9778
|
+
const bgRgb = hexToRgb4(bgColor);
|
|
9779
|
+
const color1Rgb = hexToRgb4(color1);
|
|
9780
|
+
const color2Rgb = hexToRgb4(color2);
|
|
9781
|
+
const color3Rgb = hexToRgb4(color3);
|
|
9750
9782
|
const renderer = new Renderer3({ alpha: true, premultipliedAlpha: false });
|
|
9751
9783
|
const gl = renderer.gl;
|
|
9752
9784
|
gl.clearColor(0, 0, 0, 0);
|
|
@@ -9764,7 +9796,11 @@ function OrbBackground({
|
|
|
9764
9796
|
hover: { value: 0 },
|
|
9765
9797
|
rot: { value: 0 },
|
|
9766
9798
|
hoverIntensity: { value: hoverIntensity },
|
|
9767
|
-
|
|
9799
|
+
// THEME-AWARE: Pass theme colors to shader
|
|
9800
|
+
backgroundColor: { value: new Vec3(...bgRgb) },
|
|
9801
|
+
orbColor1: { value: new Vec3(...color1Rgb) },
|
|
9802
|
+
orbColor2: { value: new Vec3(...color2Rgb) },
|
|
9803
|
+
orbColor3: { value: new Vec3(...color3Rgb) }
|
|
9768
9804
|
}
|
|
9769
9805
|
});
|
|
9770
9806
|
const mesh = new Mesh3(gl, { geometry, program });
|
|
@@ -9821,7 +9857,6 @@ function OrbBackground({
|
|
|
9821
9857
|
currentRot += dt * rotationSpeed;
|
|
9822
9858
|
}
|
|
9823
9859
|
program.uniforms.rot.value = currentRot;
|
|
9824
|
-
program.uniforms.backgroundColor.value = hexToVec3(backgroundColor);
|
|
9825
9860
|
renderer.render({ scene: mesh });
|
|
9826
9861
|
};
|
|
9827
9862
|
rafId = requestAnimationFrame(update);
|
|
@@ -9838,47 +9873,6 @@ function OrbBackground({
|
|
|
9838
9873
|
}, [hue, hoverIntensity, rotateOnHover, forceHoverState, backgroundColor]);
|
|
9839
9874
|
return /* @__PURE__ */ jsx85("div", { ref: ctnDom, className: cn("w-full h-full pointer-events-auto", className) });
|
|
9840
9875
|
}
|
|
9841
|
-
function hslToRgb(h, s, l) {
|
|
9842
|
-
let r, g, b;
|
|
9843
|
-
if (s === 0) {
|
|
9844
|
-
r = g = b = l;
|
|
9845
|
-
} else {
|
|
9846
|
-
const hue2rgb = (p2, q2, t) => {
|
|
9847
|
-
if (t < 0) t += 1;
|
|
9848
|
-
if (t > 1) t -= 1;
|
|
9849
|
-
if (t < 1 / 6) return p2 + (q2 - p2) * 6 * t;
|
|
9850
|
-
if (t < 1 / 2) return q2;
|
|
9851
|
-
if (t < 2 / 3) return p2 + (q2 - p2) * (2 / 3 - t) * 6;
|
|
9852
|
-
return p2;
|
|
9853
|
-
};
|
|
9854
|
-
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
9855
|
-
const p = 2 * l - q;
|
|
9856
|
-
r = hue2rgb(p, q, h + 1 / 3);
|
|
9857
|
-
g = hue2rgb(p, q, h);
|
|
9858
|
-
b = hue2rgb(p, q, h - 1 / 3);
|
|
9859
|
-
}
|
|
9860
|
-
return new Vec3(r, g, b);
|
|
9861
|
-
}
|
|
9862
|
-
function hexToVec3(color) {
|
|
9863
|
-
if (color.startsWith("#")) {
|
|
9864
|
-
const r = parseInt(color.slice(1, 3), 16) / 255;
|
|
9865
|
-
const g = parseInt(color.slice(3, 5), 16) / 255;
|
|
9866
|
-
const b = parseInt(color.slice(5, 7), 16) / 255;
|
|
9867
|
-
return new Vec3(r, g, b);
|
|
9868
|
-
}
|
|
9869
|
-
const rgbMatch = color.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
9870
|
-
if (rgbMatch) {
|
|
9871
|
-
return new Vec3(parseInt(rgbMatch[1]) / 255, parseInt(rgbMatch[2]) / 255, parseInt(rgbMatch[3]) / 255);
|
|
9872
|
-
}
|
|
9873
|
-
const hslMatch = color.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%/);
|
|
9874
|
-
if (hslMatch) {
|
|
9875
|
-
const h = parseInt(hslMatch[1]) / 360;
|
|
9876
|
-
const s = parseInt(hslMatch[2]) / 100;
|
|
9877
|
-
const l = parseInt(hslMatch[3]) / 100;
|
|
9878
|
-
return hslToRgb(h, s, l);
|
|
9879
|
-
}
|
|
9880
|
-
return new Vec3(0, 0, 0);
|
|
9881
|
-
}
|
|
9882
9876
|
|
|
9883
9877
|
// src/components/blocks/Hero.tsx
|
|
9884
9878
|
import { ArrowRight as ArrowRight2 } from "lucide-react";
|
|
@@ -11357,6 +11351,49 @@ function mergeCustomColorTokens(baseTokens2, customPalette) {
|
|
|
11357
11351
|
...customPalette.derivedTokens
|
|
11358
11352
|
};
|
|
11359
11353
|
}
|
|
11354
|
+
function validateThemeTokens(theme, mode) {
|
|
11355
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
|
|
11356
|
+
const root = document.documentElement;
|
|
11357
|
+
const style = getComputedStyle(root);
|
|
11358
|
+
const requiredTokens = [
|
|
11359
|
+
"--color-background",
|
|
11360
|
+
"--color-foreground",
|
|
11361
|
+
"--color-primary",
|
|
11362
|
+
"--color-primary-foreground",
|
|
11363
|
+
"--color-border",
|
|
11364
|
+
"--color-ring",
|
|
11365
|
+
"--font-heading",
|
|
11366
|
+
"--font-body",
|
|
11367
|
+
"--font-mono"
|
|
11368
|
+
];
|
|
11369
|
+
const missingTokens = [];
|
|
11370
|
+
const invalidTokens = [];
|
|
11371
|
+
requiredTokens.forEach((token) => {
|
|
11372
|
+
const value = style.getPropertyValue(token).trim();
|
|
11373
|
+
if (!value) {
|
|
11374
|
+
missingTokens.push(token);
|
|
11375
|
+
} else if (token.startsWith("--color-") && !value.match(/^(#|rgb|hsl|var\()/)) {
|
|
11376
|
+
invalidTokens.push(`${token} = "${value}"`);
|
|
11377
|
+
} else if (token.startsWith("--font-") && value === "") {
|
|
11378
|
+
invalidTokens.push(`${token} = empty`);
|
|
11379
|
+
}
|
|
11380
|
+
});
|
|
11381
|
+
if (missingTokens.length > 0) {
|
|
11382
|
+
console.warn(
|
|
11383
|
+
`[ThemeProvider] Missing CSS variables for theme "${theme}" (${mode} mode):`,
|
|
11384
|
+
missingTokens
|
|
11385
|
+
);
|
|
11386
|
+
}
|
|
11387
|
+
if (invalidTokens.length > 0) {
|
|
11388
|
+
console.warn(
|
|
11389
|
+
`[ThemeProvider] Invalid CSS variable values for theme "${theme}" (${mode} mode):`,
|
|
11390
|
+
invalidTokens
|
|
11391
|
+
);
|
|
11392
|
+
}
|
|
11393
|
+
if (missingTokens.length === 0 && invalidTokens.length === 0) {
|
|
11394
|
+
console.log(`[ThemeProvider] \u2713 Theme validation passed for "${theme}" (${mode} mode)`);
|
|
11395
|
+
}
|
|
11396
|
+
}
|
|
11360
11397
|
function ThemeProvider({ children }) {
|
|
11361
11398
|
const { theme, mode } = useThemeStore();
|
|
11362
11399
|
const customPalette = useCustomizer((state) => state.customColors?.[theme]?.[mode]);
|
|
@@ -11390,6 +11427,7 @@ function ThemeProvider({ children }) {
|
|
|
11390
11427
|
} else {
|
|
11391
11428
|
root.classList.remove("dark");
|
|
11392
11429
|
}
|
|
11430
|
+
validateThemeTokens(theme, mode);
|
|
11393
11431
|
const timeout = setTimeout(() => {
|
|
11394
11432
|
root.classList.remove("theme-transitioning");
|
|
11395
11433
|
setIsTransitioning(false);
|