@nous-research/ui 0.13.2 → 0.14.1
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 +16 -0
- package/dist/assets/filler-bg0.webp +0 -0
- package/dist/assets.d.ts +38 -0
- package/dist/fonts.d.ts +0 -1
- package/dist/fonts.js +5 -7
- package/dist/hooks/use-capped-frame.d.ts +0 -1
- package/dist/hooks/use-capped-frame.js +12 -13
- package/dist/hooks/use-css-var-dims.d.ts +0 -1
- package/dist/hooks/use-css-var-dims.js +26 -21
- package/dist/hooks/use-gpu-tier.d.ts +0 -1
- package/dist/hooks/use-gpu-tier.js +90 -110
- package/dist/hooks/use-render-loop.d.ts +0 -1
- package/dist/hooks/use-render-loop.js +58 -58
- package/dist/hooks/use-smooth-controls.d.ts +0 -1
- package/dist/hooks/use-smooth-controls.js +204 -206
- package/dist/index.d.ts +0 -1
- package/dist/index.js +84 -58
- package/dist/ui/basic-page.d.ts +1 -2
- package/dist/ui/basic-page.js +15 -7
- package/dist/ui/build.css +1 -0
- package/dist/ui/components/animated-count.d.ts +1 -2
- package/dist/ui/components/animated-count.js +109 -85
- package/dist/ui/components/ascii.d.ts +2 -3
- package/dist/ui/components/ascii.js +75 -59
- package/dist/ui/components/badge.d.ts +1 -2
- package/dist/ui/components/badge.js +35 -18
- package/dist/ui/components/badges/nous-girl.d.ts +1 -2
- package/dist/ui/components/badges/nous-girl.js +80 -3
- package/dist/ui/components/blend-mode.d.ts +1 -2
- package/dist/ui/components/blend-mode.js +55 -63
- package/dist/ui/components/blink.d.ts +1 -2
- package/dist/ui/components/blink.js +15 -6
- package/dist/ui/components/button.d.ts +2 -3
- package/dist/ui/components/button.js +139 -90
- package/dist/ui/components/command-block.d.ts +2 -3
- package/dist/ui/components/command-block.js +52 -24
- package/dist/ui/components/cursor.d.ts +1 -2
- package/dist/ui/components/cursor.js +93 -54
- package/dist/ui/components/dropdown-menu.d.ts +1 -2
- package/dist/ui/components/dropdown-menu.js +99 -51
- package/dist/ui/components/fit-text/index.d.ts +0 -1
- package/dist/ui/components/fit-text/index.js +21 -13
- package/dist/ui/components/graphs/bar-chart.d.ts +1 -2
- package/dist/ui/components/graphs/bar-chart.js +116 -63
- package/dist/ui/components/graphs/index.d.ts +0 -1
- package/dist/ui/components/graphs/index.js +3 -4
- package/dist/ui/components/graphs/line-chart.d.ts +1 -2
- package/dist/ui/components/graphs/line-chart.js +159 -102
- package/dist/ui/components/graphs/utils.d.ts +2 -3
- package/dist/ui/components/graphs/utils.js +147 -114
- package/dist/ui/components/grid/index.d.ts +0 -1
- package/dist/ui/components/grid/index.js +12 -9
- package/dist/ui/components/hover-bg.d.ts +0 -1
- package/dist/ui/components/hover-bg.js +11 -6
- package/dist/ui/components/icons/arrow.d.ts +1 -2
- package/dist/ui/components/icons/arrow.js +42 -5
- package/dist/ui/components/icons/chevron.d.ts +1 -2
- package/dist/ui/components/icons/chevron.js +49 -5
- package/dist/ui/components/icons/discord.d.ts +1 -2
- package/dist/ui/components/icons/discord.js +12 -4
- package/dist/ui/components/icons/eye.d.ts +1 -2
- package/dist/ui/components/icons/eye.js +5 -3
- package/dist/ui/components/icons/gear.d.ts +1 -2
- package/dist/ui/components/icons/gear.js +28 -14
- package/dist/ui/components/icons/github.d.ts +1 -2
- package/dist/ui/components/icons/github.js +12 -4
- package/dist/ui/components/icons/hamburger.d.ts +1 -2
- package/dist/ui/components/icons/hamburger.js +54 -5
- package/dist/ui/components/icons/heart.d.ts +1 -2
- package/dist/ui/components/icons/heart.js +8 -3
- package/dist/ui/components/icons/index.d.ts +0 -1
- package/dist/ui/components/icons/index.js +11 -12
- package/dist/ui/components/icons/link.d.ts +1 -2
- package/dist/ui/components/icons/link.js +10 -3
- package/dist/ui/components/icons/minus.d.ts +1 -2
- package/dist/ui/components/icons/minus.js +10 -3
- package/dist/ui/components/icons/search.d.ts +1 -2
- package/dist/ui/components/icons/search.js +30 -3
- package/dist/ui/components/image-distortion.d.ts +1 -2
- package/dist/ui/components/image-distortion.js +300 -265
- package/dist/ui/components/leva-client.d.ts +1 -2
- package/dist/ui/components/leva-client.js +9 -10
- package/dist/ui/components/list-item.d.ts +0 -1
- package/dist/ui/components/list-item.js +26 -10
- package/dist/ui/components/modal/index.d.ts +1 -2
- package/dist/ui/components/modal/index.js +33 -14
- package/dist/ui/components/overlays/blend-modes.d.ts +0 -1
- package/dist/ui/components/overlays/blend-modes.js +11 -12
- package/dist/ui/components/overlays/glitch.d.ts +1 -2
- package/dist/ui/components/overlays/glitch.js +115 -110
- package/dist/ui/components/overlays/greys.d.ts +1 -2
- package/dist/ui/components/overlays/greys.js +200 -179
- package/dist/ui/components/overlays/index.d.ts +1 -2
- package/dist/ui/components/overlays/index.js +31 -17
- package/dist/ui/components/overlays/lens-layers.d.ts +1 -2
- package/dist/ui/components/overlays/lens-layers.js +89 -65
- package/dist/ui/components/overlays/lens.d.ts +0 -1
- package/dist/ui/components/overlays/lens.js +46 -52
- package/dist/ui/components/overlays/noise.d.ts +1 -2
- package/dist/ui/components/overlays/noise.js +112 -113
- package/dist/ui/components/overlays/vignette.d.ts +1 -2
- package/dist/ui/components/overlays/vignette.js +44 -38
- package/dist/ui/components/poster.d.ts +1 -2
- package/dist/ui/components/poster.js +240 -87
- package/dist/ui/components/progress.d.ts +1 -2
- package/dist/ui/components/progress.js +52 -12
- package/dist/ui/components/scene-canvas.d.ts +1 -2
- package/dist/ui/components/scene-canvas.js +169 -119
- package/dist/ui/components/scramble.d.ts +1 -2
- package/dist/ui/components/scramble.js +60 -59
- package/dist/ui/components/segmented.d.ts +2 -3
- package/dist/ui/components/segmented.js +47 -12
- package/dist/ui/components/select.d.ts +1 -2
- package/dist/ui/components/select.js +207 -120
- package/dist/ui/components/selection-switcher.d.ts +0 -1
- package/dist/ui/components/selection-switcher.js +29 -25
- package/dist/ui/components/shader.d.ts +1 -2
- package/dist/ui/components/shader.js +56 -38
- package/dist/ui/components/socials.d.ts +1 -2
- package/dist/ui/components/socials.js +18 -7
- package/dist/ui/components/spinner.d.ts +1 -2
- package/dist/ui/components/spinner.js +36 -25
- package/dist/ui/components/stats.d.ts +1 -2
- package/dist/ui/components/stats.js +33 -9
- package/dist/ui/components/switch.d.ts +0 -1
- package/dist/ui/components/switch.js +35 -11
- package/dist/ui/components/tabs.d.ts +3 -4
- package/dist/ui/components/tabs.js +38 -12
- package/dist/ui/components/terminal-demo.d.ts +1 -2
- package/dist/ui/components/terminal-demo.js +119 -74
- package/dist/ui/components/theme-toggle.d.ts +1 -2
- package/dist/ui/components/theme-toggle.js +63 -8
- package/dist/ui/components/tier-card.d.ts +1 -2
- package/dist/ui/components/tier-card.js +144 -24
- package/dist/ui/components/tv.d.ts +1 -2
- package/dist/ui/components/tv.js +138 -90
- package/dist/ui/components/typography/h1.d.ts +0 -1
- package/dist/ui/components/typography/h1.js +17 -8
- package/dist/ui/components/typography/h2.d.ts +0 -1
- package/dist/ui/components/typography/h2.js +17 -8
- package/dist/ui/components/typography/index.d.ts +0 -1
- package/dist/ui/components/typography/index.js +35 -24
- package/dist/ui/components/typography/legend.d.ts +1 -2
- package/dist/ui/components/typography/legend.js +18 -6
- package/dist/ui/components/typography/small.d.ts +0 -1
- package/dist/ui/components/typography/small.js +8 -7
- package/dist/ui/components/watchlist.d.ts +1 -2
- package/dist/ui/components/watchlist.js +77 -25
- package/dist/ui/fonts.css +7 -7
- package/dist/ui/footer.d.ts +1 -2
- package/dist/ui/footer.js +61 -25
- package/dist/ui/globals.css +5 -1
- package/dist/ui/header.d.ts +1 -2
- package/dist/ui/header.js +255 -60
- package/dist/ui/layout-wrapper.d.ts +1 -2
- package/dist/ui/layout-wrapper.js +5 -4
- package/dist/utils/color.d.ts +0 -1
- package/dist/utils/color.js +8 -9
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +37 -38
- package/dist/utils/poly.d.ts +0 -1
- package/dist/utils/poly.js +1 -2
- package/package.json +42 -24
- package/dist/assets/filler-bg0.jpg +0 -0
- package/dist/fonts.d.ts.map +0 -1
- package/dist/fonts.js.map +0 -1
- package/dist/hooks/use-capped-frame.d.ts.map +0 -1
- package/dist/hooks/use-capped-frame.js.map +0 -1
- package/dist/hooks/use-css-var-dims.d.ts.map +0 -1
- package/dist/hooks/use-css-var-dims.js.map +0 -1
- package/dist/hooks/use-gpu-tier.d.ts.map +0 -1
- package/dist/hooks/use-gpu-tier.js.map +0 -1
- package/dist/hooks/use-render-loop.d.ts.map +0 -1
- package/dist/hooks/use-render-loop.js.map +0 -1
- package/dist/hooks/use-smooth-controls.d.ts.map +0 -1
- package/dist/hooks/use-smooth-controls.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/ui/basic-page.d.ts.map +0 -1
- package/dist/ui/basic-page.js.map +0 -1
- package/dist/ui/components/animated-count.d.ts.map +0 -1
- package/dist/ui/components/animated-count.js.map +0 -1
- package/dist/ui/components/ascii.d.ts.map +0 -1
- package/dist/ui/components/ascii.js.map +0 -1
- package/dist/ui/components/badge.d.ts.map +0 -1
- package/dist/ui/components/badge.js.map +0 -1
- package/dist/ui/components/badges/nous-girl.d.ts.map +0 -1
- package/dist/ui/components/badges/nous-girl.js.map +0 -1
- package/dist/ui/components/blend-mode.d.ts.map +0 -1
- package/dist/ui/components/blend-mode.js.map +0 -1
- package/dist/ui/components/blink.d.ts.map +0 -1
- package/dist/ui/components/blink.js.map +0 -1
- package/dist/ui/components/button.d.ts.map +0 -1
- package/dist/ui/components/button.js.map +0 -1
- package/dist/ui/components/command-block.d.ts.map +0 -1
- package/dist/ui/components/command-block.js.map +0 -1
- package/dist/ui/components/cursor.d.ts.map +0 -1
- package/dist/ui/components/cursor.js.map +0 -1
- package/dist/ui/components/dropdown-menu.d.ts.map +0 -1
- package/dist/ui/components/dropdown-menu.js.map +0 -1
- package/dist/ui/components/fit-text/index.d.ts.map +0 -1
- package/dist/ui/components/fit-text/index.js.map +0 -1
- package/dist/ui/components/graphs/bar-chart.d.ts.map +0 -1
- package/dist/ui/components/graphs/bar-chart.js.map +0 -1
- package/dist/ui/components/graphs/index.d.ts.map +0 -1
- package/dist/ui/components/graphs/index.js.map +0 -1
- package/dist/ui/components/graphs/line-chart.d.ts.map +0 -1
- package/dist/ui/components/graphs/line-chart.js.map +0 -1
- package/dist/ui/components/graphs/utils.d.ts.map +0 -1
- package/dist/ui/components/graphs/utils.js.map +0 -1
- package/dist/ui/components/grid/index.d.ts.map +0 -1
- package/dist/ui/components/grid/index.js.map +0 -1
- package/dist/ui/components/hover-bg.d.ts.map +0 -1
- package/dist/ui/components/hover-bg.js.map +0 -1
- package/dist/ui/components/icons/arrow.d.ts.map +0 -1
- package/dist/ui/components/icons/arrow.js.map +0 -1
- package/dist/ui/components/icons/chevron.d.ts.map +0 -1
- package/dist/ui/components/icons/chevron.js.map +0 -1
- package/dist/ui/components/icons/discord.d.ts.map +0 -1
- package/dist/ui/components/icons/discord.js.map +0 -1
- package/dist/ui/components/icons/eye.d.ts.map +0 -1
- package/dist/ui/components/icons/eye.js.map +0 -1
- package/dist/ui/components/icons/gear.d.ts.map +0 -1
- package/dist/ui/components/icons/gear.js.map +0 -1
- package/dist/ui/components/icons/github.d.ts.map +0 -1
- package/dist/ui/components/icons/github.js.map +0 -1
- package/dist/ui/components/icons/hamburger.d.ts.map +0 -1
- package/dist/ui/components/icons/hamburger.js.map +0 -1
- package/dist/ui/components/icons/heart.d.ts.map +0 -1
- package/dist/ui/components/icons/heart.js.map +0 -1
- package/dist/ui/components/icons/index.d.ts.map +0 -1
- package/dist/ui/components/icons/index.js.map +0 -1
- package/dist/ui/components/icons/link.d.ts.map +0 -1
- package/dist/ui/components/icons/link.js.map +0 -1
- package/dist/ui/components/icons/minus.d.ts.map +0 -1
- package/dist/ui/components/icons/minus.js.map +0 -1
- package/dist/ui/components/icons/search.d.ts.map +0 -1
- package/dist/ui/components/icons/search.js.map +0 -1
- package/dist/ui/components/image-distortion.d.ts.map +0 -1
- package/dist/ui/components/image-distortion.js.map +0 -1
- package/dist/ui/components/leva-client.d.ts.map +0 -1
- package/dist/ui/components/leva-client.js.map +0 -1
- package/dist/ui/components/list-item.d.ts.map +0 -1
- package/dist/ui/components/list-item.js.map +0 -1
- package/dist/ui/components/modal/index.d.ts.map +0 -1
- package/dist/ui/components/modal/index.js.map +0 -1
- package/dist/ui/components/overlays/blend-modes.d.ts.map +0 -1
- package/dist/ui/components/overlays/blend-modes.js.map +0 -1
- package/dist/ui/components/overlays/glitch.d.ts.map +0 -1
- package/dist/ui/components/overlays/glitch.js.map +0 -1
- package/dist/ui/components/overlays/greys.d.ts.map +0 -1
- package/dist/ui/components/overlays/greys.js.map +0 -1
- package/dist/ui/components/overlays/index.d.ts.map +0 -1
- package/dist/ui/components/overlays/index.js.map +0 -1
- package/dist/ui/components/overlays/lens-layers.d.ts.map +0 -1
- package/dist/ui/components/overlays/lens-layers.js.map +0 -1
- package/dist/ui/components/overlays/lens.d.ts.map +0 -1
- package/dist/ui/components/overlays/lens.js.map +0 -1
- package/dist/ui/components/overlays/noise.d.ts.map +0 -1
- package/dist/ui/components/overlays/noise.js.map +0 -1
- package/dist/ui/components/overlays/vignette.d.ts.map +0 -1
- package/dist/ui/components/overlays/vignette.js.map +0 -1
- package/dist/ui/components/poster.d.ts.map +0 -1
- package/dist/ui/components/poster.js.map +0 -1
- package/dist/ui/components/progress.d.ts.map +0 -1
- package/dist/ui/components/progress.js.map +0 -1
- package/dist/ui/components/scene-canvas.d.ts.map +0 -1
- package/dist/ui/components/scene-canvas.js.map +0 -1
- package/dist/ui/components/scramble.d.ts.map +0 -1
- package/dist/ui/components/scramble.js.map +0 -1
- package/dist/ui/components/segmented.d.ts.map +0 -1
- package/dist/ui/components/segmented.js.map +0 -1
- package/dist/ui/components/select.d.ts.map +0 -1
- package/dist/ui/components/select.js.map +0 -1
- package/dist/ui/components/selection-switcher.d.ts.map +0 -1
- package/dist/ui/components/selection-switcher.js.map +0 -1
- package/dist/ui/components/shader.d.ts.map +0 -1
- package/dist/ui/components/shader.js.map +0 -1
- package/dist/ui/components/socials.d.ts.map +0 -1
- package/dist/ui/components/socials.js.map +0 -1
- package/dist/ui/components/spinner.d.ts.map +0 -1
- package/dist/ui/components/spinner.js.map +0 -1
- package/dist/ui/components/stats.d.ts.map +0 -1
- package/dist/ui/components/stats.js.map +0 -1
- package/dist/ui/components/switch.d.ts.map +0 -1
- package/dist/ui/components/switch.js.map +0 -1
- package/dist/ui/components/tabs.d.ts.map +0 -1
- package/dist/ui/components/tabs.js.map +0 -1
- package/dist/ui/components/terminal-demo.d.ts.map +0 -1
- package/dist/ui/components/terminal-demo.js.map +0 -1
- package/dist/ui/components/theme-toggle.d.ts.map +0 -1
- package/dist/ui/components/theme-toggle.js.map +0 -1
- package/dist/ui/components/tier-card.d.ts.map +0 -1
- package/dist/ui/components/tier-card.js.map +0 -1
- package/dist/ui/components/tv.d.ts.map +0 -1
- package/dist/ui/components/tv.js.map +0 -1
- package/dist/ui/components/typography/h1.d.ts.map +0 -1
- package/dist/ui/components/typography/h1.js.map +0 -1
- package/dist/ui/components/typography/h2.d.ts.map +0 -1
- package/dist/ui/components/typography/h2.js.map +0 -1
- package/dist/ui/components/typography/index.d.ts.map +0 -1
- package/dist/ui/components/typography/index.js.map +0 -1
- package/dist/ui/components/typography/legend.d.ts.map +0 -1
- package/dist/ui/components/typography/legend.js.map +0 -1
- package/dist/ui/components/typography/small.d.ts.map +0 -1
- package/dist/ui/components/typography/small.js.map +0 -1
- package/dist/ui/components/watchlist.d.ts.map +0 -1
- package/dist/ui/components/watchlist.js.map +0 -1
- package/dist/ui/footer.d.ts.map +0 -1
- package/dist/ui/footer.js.map +0 -1
- package/dist/ui/header.d.ts.map +0 -1
- package/dist/ui/header.js.map +0 -1
- package/dist/ui/layout-wrapper.d.ts.map +0 -1
- package/dist/ui/layout-wrapper.js.map +0 -1
- package/dist/utils/color.d.ts.map +0 -1
- package/dist/utils/color.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/poly.d.ts.map +0 -1
- package/dist/utils/poly.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx
|
|
3
|
-
import { useEffect, useRef, useState } from
|
|
4
|
-
import { useGpuTier } from
|
|
5
|
-
import { cn, hexToRgb } from
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { useGpuTier } from "../../hooks/use-gpu-tier.js";
|
|
5
|
+
import { cn, hexToRgb } from "../../utils/index.js";
|
|
6
6
|
const NUM_BANDS = 12;
|
|
7
7
|
const VERT = `attribute vec2 a;varying vec2 vUv;void main(){vUv=vec2(a.x*.5+.5,.5-a.y*.5);gl_Position=vec4(a,0,1);}`;
|
|
8
8
|
const FRAG = `precision highp float;
|
|
@@ -93,269 +93,304 @@ void main(){
|
|
|
93
93
|
|
|
94
94
|
gl_FragColor=vec4(col,1.0);
|
|
95
95
|
}`;
|
|
96
|
-
/**
|
|
97
|
-
* Choreographed motion patterns used when `autoPlay` is set. Each pattern
|
|
98
|
-
* returns a synthetic pointer position in [0,1] and a hover intensity in
|
|
99
|
-
* [0,1] for the current time (seconds). They drive the shader without
|
|
100
|
-
* requiring a real pointer, which is what lets us record the distortion
|
|
101
|
-
* as a GIF / screenshot / poster.
|
|
102
|
-
*/
|
|
103
96
|
const AUTOPLAY_PATTERNS = {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return { hover: 0.5 + slash * 0.5 + micro * 0.35, mx, my };
|
|
132
|
-
}
|
|
97
|
+
aggressive: (t) => {
|
|
98
|
+
const cycle = 1.4;
|
|
99
|
+
const phase = t % cycle / cycle;
|
|
100
|
+
const stab = Math.exp(-((phase - 0.15) ** 2) * 260);
|
|
101
|
+
const angle = Math.floor(t / cycle) * 1.37;
|
|
102
|
+
const mx = 0.5 + Math.cos(angle) * 0.42 * (stab + 0.15);
|
|
103
|
+
const my = 0.5 + Math.sin(angle) * 0.38 * (stab + 0.15);
|
|
104
|
+
return { hover: 0.55 + stab * 0.45, mx, my };
|
|
105
|
+
},
|
|
106
|
+
gentle: (t) => ({
|
|
107
|
+
hover: 0.45 + Math.sin(t * 0.9) * 0.1,
|
|
108
|
+
mx: 0.5 + Math.sin(t * 0.5) * 0.28,
|
|
109
|
+
my: 0.5 + Math.cos(t * 0.37) * 0.22
|
|
110
|
+
}),
|
|
111
|
+
slash: (t) => {
|
|
112
|
+
const cycle = 3.6;
|
|
113
|
+
const phase = t % cycle / cycle;
|
|
114
|
+
const slash = Math.exp(-((phase - 0.28) ** 2) * 180);
|
|
115
|
+
const micro = Math.exp(-((phase - 0.7) ** 2) * 340);
|
|
116
|
+
const driftX = 0.5 + Math.sin(t * 0.7) * 0.16;
|
|
117
|
+
const driftY = 0.55 + Math.cos(t * 0.5) * 0.14;
|
|
118
|
+
const slashX = -0.15 + phase * 1.55;
|
|
119
|
+
const slashY = 0.95 - phase * 1.35;
|
|
120
|
+
const mx = driftX * (1 - slash) + slashX * slash;
|
|
121
|
+
const my = driftY * (1 - slash) + slashY * slash;
|
|
122
|
+
return { hover: 0.5 + slash * 0.5 + micro * 0.35, mx, my };
|
|
123
|
+
}
|
|
133
124
|
};
|
|
134
|
-
export function ImageDistortion({
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
125
|
+
export function ImageDistortion({
|
|
126
|
+
active = true,
|
|
127
|
+
autoPlay,
|
|
128
|
+
className,
|
|
129
|
+
fallbackClassName,
|
|
130
|
+
src,
|
|
131
|
+
style,
|
|
132
|
+
tint,
|
|
133
|
+
tintStrength
|
|
134
|
+
}) {
|
|
135
|
+
const canvasRef = useRef(null);
|
|
136
|
+
const tier = useGpuTier();
|
|
137
|
+
const [loaded, setLoaded] = useState(false);
|
|
138
|
+
const activeRef = useRef(active);
|
|
139
|
+
activeRef.current = active;
|
|
140
|
+
const tintStrengthRef = useRef(tintStrength);
|
|
141
|
+
tintStrengthRef.current = tintStrength;
|
|
142
|
+
const autoPlayRef = useRef(autoPlay);
|
|
143
|
+
autoPlayRef.current = autoPlay;
|
|
144
|
+
const state = useRef({
|
|
145
|
+
bandTargets: new Float32Array(NUM_BANDS),
|
|
146
|
+
bands: new Float32Array(NUM_BANDS),
|
|
147
|
+
hoverTarget: 0,
|
|
148
|
+
imgH: 1,
|
|
149
|
+
imgW: 1,
|
|
150
|
+
mx: 0.5,
|
|
151
|
+
my: 0.5,
|
|
152
|
+
prevMx: 0.5,
|
|
153
|
+
prevMy: 0.5,
|
|
154
|
+
vx: 0,
|
|
155
|
+
vy: 0
|
|
156
|
+
});
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
if (tier === 0) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const c = canvasRef.current;
|
|
162
|
+
if (!c) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const gl = c.getContext("webgl");
|
|
166
|
+
if (!gl) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const compile = (type, source) => {
|
|
170
|
+
const s = gl.createShader(type);
|
|
171
|
+
gl.shaderSource(s, source);
|
|
172
|
+
gl.compileShader(s);
|
|
173
|
+
return s;
|
|
174
|
+
};
|
|
175
|
+
const prog = gl.createProgram();
|
|
176
|
+
gl.attachShader(prog, compile(gl.VERTEX_SHADER, VERT));
|
|
177
|
+
gl.attachShader(prog, compile(gl.FRAGMENT_SHADER, FRAG));
|
|
178
|
+
gl.linkProgram(prog);
|
|
179
|
+
gl.useProgram(prog);
|
|
180
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
|
|
181
|
+
gl.bufferData(
|
|
182
|
+
gl.ARRAY_BUFFER,
|
|
183
|
+
new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]),
|
|
184
|
+
gl.STATIC_DRAW
|
|
185
|
+
);
|
|
186
|
+
const a = gl.getAttribLocation(prog, "a");
|
|
187
|
+
gl.enableVertexAttribArray(a);
|
|
188
|
+
gl.vertexAttribPointer(a, 2, gl.FLOAT, false, 0, 0);
|
|
189
|
+
const uT = gl.getUniformLocation(prog, "t");
|
|
190
|
+
const uR = gl.getUniformLocation(prog, "r");
|
|
191
|
+
const uImgSize = gl.getUniformLocation(prog, "imgSize");
|
|
192
|
+
const uVel = gl.getUniformLocation(prog, "vel");
|
|
193
|
+
const uTex = gl.getUniformLocation(prog, "tex");
|
|
194
|
+
const uTint = gl.getUniformLocation(prog, "tint");
|
|
195
|
+
const uTintStrength = gl.getUniformLocation(prog, "tintStrength");
|
|
196
|
+
const uBands = [];
|
|
197
|
+
for (let i = 0; i < NUM_BANDS; i++) {
|
|
198
|
+
uBands.push(gl.getUniformLocation(prog, `bands[${i}]`));
|
|
199
|
+
}
|
|
200
|
+
const texture = gl.createTexture();
|
|
201
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
202
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
203
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
204
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
205
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
206
|
+
gl.texImage2D(
|
|
207
|
+
gl.TEXTURE_2D,
|
|
208
|
+
0,
|
|
209
|
+
gl.RGBA,
|
|
210
|
+
1,
|
|
211
|
+
1,
|
|
212
|
+
0,
|
|
213
|
+
gl.RGBA,
|
|
214
|
+
gl.UNSIGNED_BYTE,
|
|
215
|
+
new Uint8Array([0, 0, 0, 255])
|
|
216
|
+
);
|
|
217
|
+
const img = new Image();
|
|
218
|
+
img.crossOrigin = "anonymous";
|
|
219
|
+
img.onload = () => {
|
|
220
|
+
state.current.imgW = img.naturalWidth;
|
|
221
|
+
state.current.imgH = img.naturalHeight;
|
|
222
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
223
|
+
gl.texImage2D(
|
|
224
|
+
gl.TEXTURE_2D,
|
|
225
|
+
0,
|
|
226
|
+
gl.RGBA,
|
|
227
|
+
gl.RGBA,
|
|
228
|
+
gl.UNSIGNED_BYTE,
|
|
229
|
+
img
|
|
230
|
+
);
|
|
231
|
+
setLoaded(true);
|
|
232
|
+
};
|
|
233
|
+
img.src = src;
|
|
234
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
235
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
236
|
+
gl.uniform1i(uTex, 0);
|
|
237
|
+
const resize = () => {
|
|
238
|
+
const rect = c.getBoundingClientRect();
|
|
239
|
+
const dpr = Math.min(devicePixelRatio, 2);
|
|
240
|
+
c.width = rect.width * dpr;
|
|
241
|
+
c.height = rect.height * dpr;
|
|
242
|
+
gl.viewport(0, 0, c.width, c.height);
|
|
243
|
+
};
|
|
244
|
+
resize();
|
|
245
|
+
const ro = new ResizeObserver(resize);
|
|
246
|
+
ro.observe(c);
|
|
247
|
+
const onMove = (e) => {
|
|
248
|
+
const rect = c.getBoundingClientRect();
|
|
249
|
+
state.current.mx = (e.clientX - rect.left) / rect.width;
|
|
250
|
+
state.current.my = (e.clientY - rect.top) / rect.height;
|
|
251
|
+
};
|
|
252
|
+
const onEnter = () => {
|
|
253
|
+
state.current.hoverTarget = 1;
|
|
254
|
+
};
|
|
255
|
+
const onLeave = () => {
|
|
256
|
+
state.current.hoverTarget = 0;
|
|
257
|
+
};
|
|
258
|
+
if (!autoPlayRef.current) {
|
|
259
|
+
c.addEventListener("pointermove", onMove);
|
|
260
|
+
c.addEventListener("pointerenter", onEnter);
|
|
261
|
+
c.addEventListener("pointerleave", onLeave);
|
|
262
|
+
}
|
|
263
|
+
const bandEaseRates = new Float32Array(NUM_BANDS);
|
|
264
|
+
for (let i = 0; i < NUM_BANDS; i++) {
|
|
265
|
+
bandEaseRates[i] = 0.02 + Math.random() * 0.06;
|
|
266
|
+
}
|
|
267
|
+
const tintVec = tint ? (() => {
|
|
268
|
+
const [tr, tg, tb] = hexToRgb(tint);
|
|
269
|
+
return [tr / 255, tg / 255, tb / 255];
|
|
270
|
+
})() : [1, 1, 1];
|
|
271
|
+
const t0 = performance.now();
|
|
272
|
+
let raf = 0;
|
|
273
|
+
let visible = !document.hidden;
|
|
274
|
+
let inView = true;
|
|
275
|
+
const loop = () => {
|
|
276
|
+
raf = requestAnimationFrame(loop);
|
|
277
|
+
const s = state.current;
|
|
278
|
+
const pattern = autoPlayRef.current ? AUTOPLAY_PATTERNS[autoPlayRef.current] : null;
|
|
279
|
+
if (pattern) {
|
|
280
|
+
const driven = pattern((performance.now() - t0) / 1e3);
|
|
281
|
+
s.mx = driven.mx;
|
|
282
|
+
s.my = driven.my;
|
|
283
|
+
s.hoverTarget = driven.hover;
|
|
284
|
+
}
|
|
285
|
+
const dvx = s.mx - s.prevMx;
|
|
286
|
+
const dvy = s.my - s.prevMy;
|
|
287
|
+
s.vx += (dvx * 8 - s.vx) * 0.1;
|
|
288
|
+
s.vy += (dvy * 8 - s.vy) * 0.1;
|
|
289
|
+
s.prevMx = s.mx;
|
|
290
|
+
s.prevMy = s.my;
|
|
291
|
+
const speed = Math.sqrt(s.vx * s.vx + s.vy * s.vy);
|
|
292
|
+
for (let i = 0; i < NUM_BANDS; i++) {
|
|
293
|
+
const bandCenter = (i + 0.5) / NUM_BANDS;
|
|
294
|
+
const dist = Math.abs(s.my - bandCenter);
|
|
295
|
+
const proximity = Math.max(0, 1 - dist / 0.3);
|
|
296
|
+
const activation = s.hoverTarget * proximity * (0.4 + Math.min(speed, 1) * 0.6);
|
|
297
|
+
s.bandTargets[i] = activation;
|
|
298
|
+
}
|
|
299
|
+
for (let i = 0; i < NUM_BANDS; i++) {
|
|
300
|
+
const rate = bandEaseRates[i];
|
|
301
|
+
const current = s.bands[i] ?? 0;
|
|
302
|
+
const target = s.bandTargets[i] ?? 0;
|
|
303
|
+
s.bands[i] = current + (target - current) * rate;
|
|
304
|
+
if (s.bands[i] < 1e-3) {
|
|
305
|
+
s.bands[i] = 0;
|
|
244
306
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
307
|
+
}
|
|
308
|
+
gl.uniform1f(uT, (performance.now() - t0) / 1e3);
|
|
309
|
+
gl.uniform2f(uR, c.width, c.height);
|
|
310
|
+
gl.uniform2f(uImgSize, s.imgW, s.imgH);
|
|
311
|
+
gl.uniform2f(uVel, s.vx, s.vy);
|
|
312
|
+
gl.uniform3f(uTint, tintVec[0], tintVec[1], tintVec[2]);
|
|
313
|
+
const ts = tintStrengthRef.current;
|
|
314
|
+
const defaultStrength = tint ? 0.35 : 0;
|
|
315
|
+
const defaultInactive = tint ? 0.15 : 0;
|
|
316
|
+
gl.uniform1f(
|
|
317
|
+
uTintStrength,
|
|
318
|
+
activeRef.current ? ts?.active ?? defaultStrength : ts?.inactive ?? defaultInactive
|
|
319
|
+
);
|
|
320
|
+
for (let i = 0; i < NUM_BANDS; i++) {
|
|
321
|
+
gl.uniform1f(uBands[i], s.bands[i]);
|
|
322
|
+
}
|
|
323
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
324
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
325
|
+
};
|
|
326
|
+
const start = () => {
|
|
327
|
+
if (visible && inView && !raf) {
|
|
328
|
+
raf = requestAnimationFrame(loop);
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
const stop = () => {
|
|
332
|
+
if (raf) {
|
|
333
|
+
cancelAnimationFrame(raf);
|
|
334
|
+
raf = 0;
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
const onVisibility = () => {
|
|
338
|
+
visible = !document.hidden;
|
|
339
|
+
visible ? start() : stop();
|
|
340
|
+
};
|
|
341
|
+
const io = new IntersectionObserver(
|
|
342
|
+
(entries) => {
|
|
343
|
+
inView = entries.some((e) => e.isIntersecting);
|
|
344
|
+
inView ? start() : stop();
|
|
345
|
+
},
|
|
346
|
+
{ threshold: 0 }
|
|
347
|
+
);
|
|
348
|
+
io.observe(c);
|
|
349
|
+
document.addEventListener("visibilitychange", onVisibility);
|
|
350
|
+
start();
|
|
351
|
+
return () => {
|
|
352
|
+
stop();
|
|
353
|
+
io.disconnect();
|
|
354
|
+
document.removeEventListener("visibilitychange", onVisibility);
|
|
355
|
+
ro.disconnect();
|
|
356
|
+
c.removeEventListener("pointermove", onMove);
|
|
357
|
+
c.removeEventListener("pointerenter", onEnter);
|
|
358
|
+
c.removeEventListener("pointerleave", onLeave);
|
|
359
|
+
gl.deleteTexture(texture);
|
|
360
|
+
gl.deleteProgram(prog);
|
|
361
|
+
setLoaded(false);
|
|
362
|
+
};
|
|
363
|
+
}, [src, tier, tint]);
|
|
364
|
+
if (tier === 0) {
|
|
365
|
+
return (
|
|
366
|
+
// eslint-disable-next-line @next/next/no-img-element
|
|
367
|
+
/* @__PURE__ */ jsx(
|
|
368
|
+
"img",
|
|
369
|
+
{
|
|
370
|
+
alt: "",
|
|
371
|
+
className: cn(
|
|
372
|
+
"absolute inset-0 h-full w-full object-cover",
|
|
373
|
+
fallbackClassName ?? className
|
|
374
|
+
),
|
|
375
|
+
src,
|
|
376
|
+
style: { mixBlendMode: "overlay", ...style }
|
|
248
377
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
if (pattern) {
|
|
266
|
-
const driven = pattern((performance.now() - t0) / 1e3);
|
|
267
|
-
s.mx = driven.mx;
|
|
268
|
-
s.my = driven.my;
|
|
269
|
-
s.hoverTarget = driven.hover;
|
|
270
|
-
}
|
|
271
|
-
const dvx = s.mx - s.prevMx;
|
|
272
|
-
const dvy = s.my - s.prevMy;
|
|
273
|
-
s.vx += (dvx * 8 - s.vx) * 0.1;
|
|
274
|
-
s.vy += (dvy * 8 - s.vy) * 0.1;
|
|
275
|
-
s.prevMx = s.mx;
|
|
276
|
-
s.prevMy = s.my;
|
|
277
|
-
const speed = Math.sqrt(s.vx * s.vx + s.vy * s.vy);
|
|
278
|
-
for (let i = 0; i < NUM_BANDS; i++) {
|
|
279
|
-
const bandCenter = (i + 0.5) / NUM_BANDS;
|
|
280
|
-
const dist = Math.abs(s.my - bandCenter);
|
|
281
|
-
const proximity = Math.max(0, 1 - dist / 0.3);
|
|
282
|
-
const activation = s.hoverTarget * proximity * (0.4 + Math.min(speed, 1) * 0.6);
|
|
283
|
-
s.bandTargets[i] = activation;
|
|
284
|
-
}
|
|
285
|
-
for (let i = 0; i < NUM_BANDS; i++) {
|
|
286
|
-
const rate = bandEaseRates[i];
|
|
287
|
-
const current = s.bands[i] ?? 0;
|
|
288
|
-
const target = s.bandTargets[i] ?? 0;
|
|
289
|
-
s.bands[i] = current + (target - current) * rate;
|
|
290
|
-
if (s.bands[i] < 0.001) {
|
|
291
|
-
s.bands[i] = 0;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
gl.uniform1f(uT, (performance.now() - t0) / 1e3);
|
|
295
|
-
gl.uniform2f(uR, c.width, c.height);
|
|
296
|
-
gl.uniform2f(uImgSize, s.imgW, s.imgH);
|
|
297
|
-
gl.uniform2f(uVel, s.vx, s.vy);
|
|
298
|
-
gl.uniform3f(uTint, tintVec[0], tintVec[1], tintVec[2]);
|
|
299
|
-
const ts = tintStrengthRef.current;
|
|
300
|
-
const defaultStrength = tint ? 0.35 : 0;
|
|
301
|
-
const defaultInactive = tint ? 0.15 : 0;
|
|
302
|
-
gl.uniform1f(uTintStrength, activeRef.current
|
|
303
|
-
? (ts?.active ?? defaultStrength)
|
|
304
|
-
: (ts?.inactive ?? defaultInactive));
|
|
305
|
-
for (let i = 0; i < NUM_BANDS; i++) {
|
|
306
|
-
gl.uniform1f(uBands[i], s.bands[i]);
|
|
307
|
-
}
|
|
308
|
-
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
309
|
-
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
310
|
-
};
|
|
311
|
-
const start = () => {
|
|
312
|
-
if (visible && inView && !raf) {
|
|
313
|
-
raf = requestAnimationFrame(loop);
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
const stop = () => {
|
|
317
|
-
if (raf) {
|
|
318
|
-
cancelAnimationFrame(raf);
|
|
319
|
-
raf = 0;
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
const onVisibility = () => {
|
|
323
|
-
visible = !document.hidden;
|
|
324
|
-
visible ? start() : stop();
|
|
325
|
-
};
|
|
326
|
-
const io = new IntersectionObserver(entries => {
|
|
327
|
-
inView = entries.some(e => e.isIntersecting);
|
|
328
|
-
inView ? start() : stop();
|
|
329
|
-
}, { threshold: 0 });
|
|
330
|
-
io.observe(c);
|
|
331
|
-
document.addEventListener('visibilitychange', onVisibility);
|
|
332
|
-
start();
|
|
333
|
-
return () => {
|
|
334
|
-
stop();
|
|
335
|
-
io.disconnect();
|
|
336
|
-
document.removeEventListener('visibilitychange', onVisibility);
|
|
337
|
-
ro.disconnect();
|
|
338
|
-
c.removeEventListener('pointermove', onMove);
|
|
339
|
-
c.removeEventListener('pointerenter', onEnter);
|
|
340
|
-
c.removeEventListener('pointerleave', onLeave);
|
|
341
|
-
gl.deleteTexture(texture);
|
|
342
|
-
gl.deleteProgram(prog);
|
|
343
|
-
setLoaded(false);
|
|
344
|
-
};
|
|
345
|
-
// autoPlay is intentionally omitted so toggling it at runtime doesn't
|
|
346
|
-
// tear down the shader pipeline. The ref-driven loop reads the live
|
|
347
|
-
// value each frame, so listener attach/detach is handled once on mount.
|
|
348
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
349
|
-
}, [src, tier, tint]);
|
|
350
|
-
if (tier === 0) {
|
|
351
|
-
return (
|
|
352
|
-
// eslint-disable-next-line @next/next/no-img-element
|
|
353
|
-
_jsx("img", { alt: "", className: cn('absolute inset-0 h-full w-full object-cover', fallbackClassName ?? className), src: src, style: { mixBlendMode: 'overlay', ...style } }));
|
|
378
|
+
)
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
return /* @__PURE__ */ jsx(
|
|
382
|
+
"canvas",
|
|
383
|
+
{
|
|
384
|
+
className: cn(
|
|
385
|
+
"absolute inset-0 h-full w-full transition-opacity duration-500",
|
|
386
|
+
className
|
|
387
|
+
),
|
|
388
|
+
ref: canvasRef,
|
|
389
|
+
style: {
|
|
390
|
+
mixBlendMode: "overlay",
|
|
391
|
+
opacity: loaded ? 1 : 0,
|
|
392
|
+
...style
|
|
393
|
+
}
|
|
354
394
|
}
|
|
355
|
-
|
|
356
|
-
mixBlendMode: 'overlay',
|
|
357
|
-
opacity: loaded ? 1 : 0,
|
|
358
|
-
...style
|
|
359
|
-
} }));
|
|
395
|
+
);
|
|
360
396
|
}
|
|
361
|
-
//# sourceMappingURL=image-distortion.js.map
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export declare function LevaClient(): import("react
|
|
2
|
-
//# sourceMappingURL=leva-client.d.ts.map
|
|
1
|
+
export declare function LevaClient(): import("react").JSX.Element;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx
|
|
3
|
-
import { Leva } from
|
|
4
|
-
import { useEffect, useState } from
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Leva } from "leva";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
5
|
export function LevaClient() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const [hidden, setHidden] = useState(true);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
setHidden(!new URLSearchParams(window.location.search).has("dev"));
|
|
9
|
+
}, []);
|
|
10
|
+
return /* @__PURE__ */ jsx(Leva, { ...{ hidden } });
|
|
11
11
|
}
|
|
12
|
-
//# sourceMappingURL=leva-client.js.map
|
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx
|
|
3
|
-
import { forwardRef } from
|
|
4
|
-
import { cn } from
|
|
5
|
-
export const ListItem = forwardRef(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { cn } from "../../utils/index.js";
|
|
5
|
+
export const ListItem = forwardRef(
|
|
6
|
+
function ListItem2({ active = false, children, className, type = "button", ...props }, ref) {
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
"button",
|
|
9
|
+
{
|
|
10
|
+
className: cn(
|
|
11
|
+
"group relative flex w-full items-center gap-2 px-3 py-2 text-left",
|
|
12
|
+
"font-courier text-sm transition-colors cursor-pointer",
|
|
13
|
+
"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-midground/30",
|
|
14
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
15
|
+
active ? "bg-midground/10 text-midground" : "text-midground/70 hover:text-midground hover:bg-midground/5",
|
|
16
|
+
className
|
|
17
|
+
),
|
|
18
|
+
"data-active": active || void 0,
|
|
19
|
+
ref,
|
|
20
|
+
type,
|
|
21
|
+
...props,
|
|
22
|
+
children
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
);
|