@nous-research/ui 0.1.0
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 +49 -0
- package/dist/assets/filler-bg0.jpg +0 -0
- package/dist/fonts/Collapse-Bold.woff2 +0 -0
- package/dist/fonts/Collapse-BoldItalic.woff2 +0 -0
- package/dist/fonts/Collapse-Italic.woff2 +0 -0
- package/dist/fonts/Collapse-Light.woff2 +0 -0
- package/dist/fonts/Collapse-LightItalic.woff2 +0 -0
- package/dist/fonts/Collapse-Regular.woff2 +0 -0
- package/dist/fonts/Collapse-Thin.woff2 +0 -0
- package/dist/fonts/Collapse-ThinItalic.woff2 +0 -0
- package/dist/fonts/Mondwest-Regular.woff2 +0 -0
- package/dist/fonts/Neuebit-Bold.woff2 +0 -0
- package/dist/fonts/RulesCompressed-Medium.woff2 +0 -0
- package/dist/fonts/RulesCompressed-Regular.woff2 +0 -0
- package/dist/fonts/RulesExpanded-Bold.woff2 +0 -0
- package/dist/fonts/RulesExpanded-Regular.woff2 +0 -0
- package/dist/fonts.d.ts +6 -0
- package/dist/fonts.js +7 -0
- package/dist/fonts.js.map +1 -0
- package/dist/hooks/use-capped-frame.d.ts +2 -0
- package/dist/hooks/use-capped-frame.js +15 -0
- package/dist/hooks/use-capped-frame.js.map +1 -0
- package/dist/hooks/use-css-var-dims.d.ts +1 -0
- package/dist/hooks/use-css-var-dims.js +23 -0
- package/dist/hooks/use-css-var-dims.js.map +1 -0
- package/dist/hooks/use-gpu-tier.d.ts +10 -0
- package/dist/hooks/use-gpu-tier.js +92 -0
- package/dist/hooks/use-gpu-tier.js.map +1 -0
- package/dist/hooks/use-smooth-controls.d.ts +16 -0
- package/dist/hooks/use-smooth-controls.js +202 -0
- package/dist/hooks/use-smooth-controls.js.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/ui/basic-page.d.ts +7 -0
- package/dist/ui/basic-page.js +9 -0
- package/dist/ui/basic-page.js.map +1 -0
- package/dist/ui/components/animated-count.d.ts +10 -0
- package/dist/ui/components/animated-count.js +88 -0
- package/dist/ui/components/animated-count.js.map +1 -0
- package/dist/ui/components/ascii.d.ts +10 -0
- package/dist/ui/components/ascii.js +62 -0
- package/dist/ui/components/ascii.js.map +1 -0
- package/dist/ui/components/badge.d.ts +2 -0
- package/dist/ui/components/badge.js +5 -0
- package/dist/ui/components/badge.js.map +1 -0
- package/dist/ui/components/badges/nous-girl.d.ts +2 -0
- package/dist/ui/components/badges/nous-girl.js +5 -0
- package/dist/ui/components/badges/nous-girl.js.map +1 -0
- package/dist/ui/components/blend-mode.d.ts +28 -0
- package/dist/ui/components/blend-mode.js +76 -0
- package/dist/ui/components/blend-mode.js.map +1 -0
- package/dist/ui/components/blink.d.ts +6 -0
- package/dist/ui/components/blink.js +7 -0
- package/dist/ui/components/blink.js.map +1 -0
- package/dist/ui/components/button.d.ts +11 -0
- package/dist/ui/components/button.js +52 -0
- package/dist/ui/components/button.js.map +1 -0
- package/dist/ui/components/cursor.d.ts +3 -0
- package/dist/ui/components/cursor.js +57 -0
- package/dist/ui/components/cursor.js.map +1 -0
- package/dist/ui/components/dropdown-menu.d.ts +12 -0
- package/dist/ui/components/dropdown-menu.js +53 -0
- package/dist/ui/components/dropdown-menu.js.map +1 -0
- package/dist/ui/components/fit-text/fit-text.css +42 -0
- package/dist/ui/components/fit-text/index.d.ts +9 -0
- package/dist/ui/components/fit-text/index.js +16 -0
- package/dist/ui/components/fit-text/index.js.map +1 -0
- package/dist/ui/components/graphs/bar-chart.d.ts +12 -0
- package/dist/ui/components/graphs/bar-chart.js +75 -0
- package/dist/ui/components/graphs/bar-chart.js.map +1 -0
- package/dist/ui/components/graphs/index.d.ts +3 -0
- package/dist/ui/components/graphs/index.js +4 -0
- package/dist/ui/components/graphs/index.js.map +1 -0
- package/dist/ui/components/graphs/line-chart.d.ts +14 -0
- package/dist/ui/components/graphs/line-chart.js +117 -0
- package/dist/ui/components/graphs/line-chart.js.map +1 -0
- package/dist/ui/components/graphs/utils.d.ts +52 -0
- package/dist/ui/components/graphs/utils.js +128 -0
- package/dist/ui/components/graphs/utils.js.map +1 -0
- package/dist/ui/components/grid/grid.css +78 -0
- package/dist/ui/components/grid/index.d.ts +2 -0
- package/dist/ui/components/grid/index.js +13 -0
- package/dist/ui/components/grid/index.js.map +1 -0
- package/dist/ui/components/hover-bg.d.ts +1 -0
- package/dist/ui/components/hover-bg.js +8 -0
- package/dist/ui/components/hover-bg.js.map +1 -0
- package/dist/ui/components/icons/arrow.d.ts +6 -0
- package/dist/ui/components/icons/arrow.js +6 -0
- package/dist/ui/components/icons/arrow.js.map +1 -0
- package/dist/ui/components/icons/chevron.d.ts +6 -0
- package/dist/ui/components/icons/chevron.js +6 -0
- package/dist/ui/components/icons/chevron.js.map +1 -0
- package/dist/ui/components/icons/eye.d.ts +2 -0
- package/dist/ui/components/icons/eye.js +5 -0
- package/dist/ui/components/icons/eye.js.map +1 -0
- package/dist/ui/components/icons/gear.d.ts +6 -0
- package/dist/ui/components/icons/gear.js +15 -0
- package/dist/ui/components/icons/gear.js.map +1 -0
- package/dist/ui/components/icons/heart.d.ts +2 -0
- package/dist/ui/components/icons/heart.js +5 -0
- package/dist/ui/components/icons/heart.js.map +1 -0
- package/dist/ui/components/icons/index.d.ts +8 -0
- package/dist/ui/components/icons/index.js +9 -0
- package/dist/ui/components/icons/index.js.map +1 -0
- package/dist/ui/components/icons/link.d.ts +2 -0
- package/dist/ui/components/icons/link.js +5 -0
- package/dist/ui/components/icons/link.js.map +1 -0
- package/dist/ui/components/icons/minus.d.ts +2 -0
- package/dist/ui/components/icons/minus.js +5 -0
- package/dist/ui/components/icons/minus.js.map +1 -0
- package/dist/ui/components/icons/search.d.ts +2 -0
- package/dist/ui/components/icons/search.js +5 -0
- package/dist/ui/components/icons/search.js.map +1 -0
- package/dist/ui/components/leva-client.d.ts +1 -0
- package/dist/ui/components/leva-client.js +12 -0
- package/dist/ui/components/leva-client.js.map +1 -0
- package/dist/ui/components/modal/index.d.ts +8 -0
- package/dist/ui/components/modal/index.js +15 -0
- package/dist/ui/components/modal/index.js.map +1 -0
- package/dist/ui/components/modal/modal.css +36 -0
- package/dist/ui/components/overlays/glitch.d.ts +6 -0
- package/dist/ui/components/overlays/glitch.js +191 -0
- package/dist/ui/components/overlays/glitch.js.map +1 -0
- package/dist/ui/components/overlays/greys.d.ts +6 -0
- package/dist/ui/components/overlays/greys.js +300 -0
- package/dist/ui/components/overlays/greys.js.map +1 -0
- package/dist/ui/components/overlays/index.d.ts +44 -0
- package/dist/ui/components/overlays/index.js +125 -0
- package/dist/ui/components/overlays/index.js.map +1 -0
- package/dist/ui/components/overlays/noise.d.ts +6 -0
- package/dist/ui/components/overlays/noise.js +115 -0
- package/dist/ui/components/overlays/noise.js.map +1 -0
- package/dist/ui/components/overlays/vignette.d.ts +6 -0
- package/dist/ui/components/overlays/vignette.js +40 -0
- package/dist/ui/components/overlays/vignette.js.map +1 -0
- package/dist/ui/components/progress.d.ts +9 -0
- package/dist/ui/components/progress.js +12 -0
- package/dist/ui/components/progress.js.map +1 -0
- package/dist/ui/components/scene-canvas.d.ts +15 -0
- package/dist/ui/components/scene-canvas.js +117 -0
- package/dist/ui/components/scene-canvas.js.map +1 -0
- package/dist/ui/components/scramble.d.ts +9 -0
- package/dist/ui/components/scramble.js +61 -0
- package/dist/ui/components/scramble.js.map +1 -0
- package/dist/ui/components/selection-switcher.d.ts +1 -0
- package/dist/ui/components/selection-switcher.js +29 -0
- package/dist/ui/components/selection-switcher.js.map +1 -0
- package/dist/ui/components/shader.d.ts +7 -0
- package/dist/ui/components/shader.js +41 -0
- package/dist/ui/components/shader.js.map +1 -0
- package/dist/ui/components/stats.d.ts +9 -0
- package/dist/ui/components/stats.js +7 -0
- package/dist/ui/components/stats.js.map +1 -0
- package/dist/ui/components/tv.d.ts +3 -0
- package/dist/ui/components/tv.js +163 -0
- package/dist/ui/components/tv.js.map +1 -0
- package/dist/ui/components/typography/h1.d.ts +11 -0
- package/dist/ui/components/typography/h1.js +8 -0
- package/dist/ui/components/typography/h1.js.map +1 -0
- package/dist/ui/components/typography/h2.d.ts +11 -0
- package/dist/ui/components/typography/h2.js +8 -0
- package/dist/ui/components/typography/h2.js.map +1 -0
- package/dist/ui/components/typography/index.d.ts +15 -0
- package/dist/ui/components/typography/index.js +29 -0
- package/dist/ui/components/typography/index.js.map +1 -0
- package/dist/ui/components/typography/legend.d.ts +6 -0
- package/dist/ui/components/typography/legend.js +7 -0
- package/dist/ui/components/typography/legend.js.map +1 -0
- package/dist/ui/components/typography/small.d.ts +2 -0
- package/dist/ui/components/typography/small.js +7 -0
- package/dist/ui/components/typography/small.js.map +1 -0
- package/dist/ui/components/watchlist.d.ts +11 -0
- package/dist/ui/components/watchlist.js +27 -0
- package/dist/ui/components/watchlist.js.map +1 -0
- package/dist/ui/fonts.css +63 -0
- package/dist/ui/footer.d.ts +1 -0
- package/dist/ui/footer.js +19 -0
- package/dist/ui/footer.js.map +1 -0
- package/dist/ui/globals.css +340 -0
- package/dist/ui/header.d.ts +1 -0
- package/dist/ui/header.js +22 -0
- package/dist/ui/header.js.map +1 -0
- package/dist/ui/layout-wrapper.d.ts +1 -0
- package/dist/ui/layout-wrapper.js +5 -0
- package/dist/ui/layout-wrapper.js.map +1 -0
- package/dist/utils/color.d.ts +4 -0
- package/dist/utils/color.js +14 -0
- package/dist/utils/color.js.map +1 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.js +48 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/poly.d.ts +8 -0
- package/dist/utils/poly.js +3 -0
- package/dist/utils/poly.js.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { atom } from 'nanostores';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
import { setControlValue, useSmoothControls } from '../../../hooks/use-smooth-controls';
|
|
6
|
+
import { colorMix } from '../../../utils/color';
|
|
7
|
+
import fillerBg from '../../../assets/filler-bg0.jpg';
|
|
8
|
+
import { Glitch } from './glitch';
|
|
9
|
+
import { Greys } from './greys';
|
|
10
|
+
import { Noise } from './noise';
|
|
11
|
+
import { Vignette } from './vignette';
|
|
12
|
+
const LAYER = 'pointer-events-none fixed inset-0';
|
|
13
|
+
export const BLEND_MODES = [
|
|
14
|
+
'overlay',
|
|
15
|
+
'multiply',
|
|
16
|
+
'screen',
|
|
17
|
+
'difference',
|
|
18
|
+
'exclusion',
|
|
19
|
+
'color-dodge',
|
|
20
|
+
'color-burn',
|
|
21
|
+
'hard-light',
|
|
22
|
+
'soft-light',
|
|
23
|
+
'darken',
|
|
24
|
+
'lighten'
|
|
25
|
+
];
|
|
26
|
+
export const LENS_0 = {
|
|
27
|
+
Globe: { innerColor: '#170d02', innerOpacity: 0.1, outerColor: '#FFAC02' },
|
|
28
|
+
Lens: {
|
|
29
|
+
bgBlend: 'difference',
|
|
30
|
+
bgColor: '#041C1C',
|
|
31
|
+
bgOpacity: 1,
|
|
32
|
+
fgColor: '#FFFFFF',
|
|
33
|
+
fgOpacity: 0,
|
|
34
|
+
fillerOpacity: 0.033,
|
|
35
|
+
mgColor: '#ffe6cb',
|
|
36
|
+
mgOpacity: 1
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export const LENS_5I = {
|
|
40
|
+
Globe: { innerColor: '#170d02', innerOpacity: 0.3, outerColor: '#FFAC02' },
|
|
41
|
+
Lens: {
|
|
42
|
+
bgBlend: 'multiply',
|
|
43
|
+
bgColor: '#170d02',
|
|
44
|
+
bgOpacity: 1,
|
|
45
|
+
fgColor: '#FFFFFF',
|
|
46
|
+
fgOpacity: 1,
|
|
47
|
+
fillerOpacity: 0.06,
|
|
48
|
+
mgColor: '#FFAC02',
|
|
49
|
+
mgOpacity: 1
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export const lens0 = (l, g) => ({
|
|
53
|
+
Globe: { ...LENS_0.Globe, ...g },
|
|
54
|
+
Lens: { ...LENS_0.Lens, ...l }
|
|
55
|
+
});
|
|
56
|
+
export const LENSES = [
|
|
57
|
+
['0', LENS_0],
|
|
58
|
+
['1', lens0({ bgColor: '#041C1C', fgOpacity: 1 })],
|
|
59
|
+
['2', lens0({ bgColor: '#0E0313', fgOpacity: 1 })],
|
|
60
|
+
['3', lens0({ bgColor: '#003EB4', fgColor: '#001289', fgOpacity: 1 })],
|
|
61
|
+
['4', lens0({ bgColor: '#0E39AA', fgColor: '#001289', fgOpacity: 1 })],
|
|
62
|
+
['5', lens0({ bgColor: '#1540B1', bgOpacity: 0.7 })],
|
|
63
|
+
['5i', LENS_5I],
|
|
64
|
+
[
|
|
65
|
+
'6',
|
|
66
|
+
lens0({
|
|
67
|
+
bgColor: '#0e39aa',
|
|
68
|
+
fgColor: '#001289',
|
|
69
|
+
fgOpacity: 1,
|
|
70
|
+
mgColor: '#ffffff'
|
|
71
|
+
})
|
|
72
|
+
],
|
|
73
|
+
];
|
|
74
|
+
export const applyLens = (preset, animate = false) => Object.entries(preset).forEach(([g, v]) => Object.entries(v).forEach(([k, val]) => setControlValue(g, k, val, { animate })));
|
|
75
|
+
export const $lightMode = atom(true);
|
|
76
|
+
export const toggleLens = () => {
|
|
77
|
+
const isLight = $lightMode.get();
|
|
78
|
+
const next = isLight ? LENS_0 : LENS_5I;
|
|
79
|
+
$lightMode.set(!isLight);
|
|
80
|
+
applyLens(next, true);
|
|
81
|
+
};
|
|
82
|
+
export function Overlays({ dark }) {
|
|
83
|
+
const init = dark ? LENS_0.Lens : LENS_5I.Lens;
|
|
84
|
+
const lens = useSmoothControls('Lens', {
|
|
85
|
+
bgBlend: { options: BLEND_MODES, value: init.bgBlend },
|
|
86
|
+
bgColor: { value: init.bgColor },
|
|
87
|
+
bgOpacity: { max: 1, min: 0, step: 0.01, value: init.bgOpacity },
|
|
88
|
+
fgBlend: { options: BLEND_MODES, value: 'difference' },
|
|
89
|
+
fgColor: { value: init.fgColor },
|
|
90
|
+
fgOpacity: { max: 1, min: 0, step: 0.01, value: init.fgOpacity },
|
|
91
|
+
fillerBlend: { options: BLEND_MODES, value: 'difference' },
|
|
92
|
+
fillerOpacity: { max: 1, min: 0, step: 0.01, value: init.fillerOpacity },
|
|
93
|
+
mgColor: { value: init.mgColor },
|
|
94
|
+
mgOpacity: { max: 1, min: 0, step: 0.01, value: init.mgOpacity }
|
|
95
|
+
}, { collapsed: false });
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
$lightMode.set(!dark);
|
|
98
|
+
applyLens(dark ? LENS_0 : LENS_5I);
|
|
99
|
+
}, [dark]);
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
const s = document.documentElement.style;
|
|
102
|
+
for (const [name, color, alpha] of [
|
|
103
|
+
['foreground', lens.fgColor, lens.fgOpacity],
|
|
104
|
+
['midground', lens.mgColor, lens.mgOpacity],
|
|
105
|
+
['background', lens.bgColor, lens.bgOpacity]
|
|
106
|
+
]) {
|
|
107
|
+
s.setProperty(`--${name}`, colorMix(color, alpha));
|
|
108
|
+
s.setProperty(`--${name}-base`, color);
|
|
109
|
+
s.setProperty(`--${name}-alpha`, `${alpha}`);
|
|
110
|
+
}
|
|
111
|
+
}, [lens]);
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
const handle = (e) => e.key === 'x' && toggleLens();
|
|
114
|
+
window.addEventListener('keydown', handle);
|
|
115
|
+
return () => window.removeEventListener('keydown', handle);
|
|
116
|
+
}, []);
|
|
117
|
+
return (_jsxs(_Fragment, { children: [_jsx(Noise, { className: `${LAYER} z-101` }), _jsx("div", { className: `${LAYER} z-100`, style: {
|
|
118
|
+
backgroundColor: colorMix(lens.fgColor, lens.fgOpacity),
|
|
119
|
+
mixBlendMode: lens.fgBlend
|
|
120
|
+
} }), _jsx(Vignette, { className: `${LAYER} z-99` }), _jsx(Greys, { className: `${LAYER} z-200` }), _jsx(Glitch, { className: `${LAYER} z-201` }), _jsx("div", { className: `${LAYER} z-2`, style: { mixBlendMode: lens.fillerBlend, opacity: lens.fillerOpacity }, children: _jsx("img", { alt: "", className: "h-[150dvh] w-auto min-w-dvw object-cover object-top-left invert", fetchPriority: "low", src: fillerBg.src }) }), _jsx("div", { className: `${LAYER} z-1`, style: {
|
|
121
|
+
backgroundColor: colorMix(lens.bgColor, lens.bgOpacity),
|
|
122
|
+
mixBlendMode: lens.bgBlend
|
|
123
|
+
} })] }));
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/components/overlays/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,OAAO,EAEL,eAAe,EACf,iBAAiB,EAClB,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE/C,OAAO,QAAQ,MAAM,gCAAgC,CAAA;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,MAAM,KAAK,GAAG,mCAAmC,CAAA;AAEjD,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,SAAS;IACT,UAAU;IACV,QAAQ;IACR,YAAY;IACZ,WAAW;IACX,aAAa;IACb,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,QAAQ;IACR,SAAS;CAC0C,CAAA;AAErD,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,EAA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A;IAC5D,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,CACL,8BACE,KAAC,KAAK,IAAC,SAAS,EAAE,GAAG,KAAK,QAAQ,GAAI,EAEtC,cACE,SAAS,EAAE,GAAG,KAAK,QAAQ,EAC3B,KAAK,EAAE;oBACL,eAAe,EAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;oBACvD,YAAY,EAAE,IAAI,CAAC,OAAO;iBAC3B,GACD,EAEF,KAAC,QAAQ,IAAC,SAAS,EAAE,GAAG,KAAK,OAAO,GAAI,EACxC,KAAC,KAAK,IAAC,SAAS,EAAE,GAAG,KAAK,QAAQ,GAAI,EACtC,KAAC,MAAM,IAAC,SAAS,EAAE,GAAG,KAAK,QAAQ,GAAI,EAEvC,cACE,SAAS,EAAE,GAAG,KAAK,MAAM,EACzB,KAAK,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,YAGtE,cACE,GAAG,EAAC,EAAE,EACN,SAAS,EAAC,iEAAiE,EAC3E,aAAa,EAAC,KAAK,EACnB,GAAG,EAAE,QAAQ,CAAC,GAAG,GACjB,GACE,EAEN,cACE,SAAS,EAAE,GAAG,KAAK,MAAM,EACzB,KAAK,EAAE;oBACL,eAAe,EAAE,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;oBACvD,YAAY,EAAE,IAAI,CAAC,OAAO;iBAC3B,GACD,IACD,CACJ,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import * as THREE from 'three';
|
|
5
|
+
import { useGpuTier } from '../../../hooks/use-gpu-tier';
|
|
6
|
+
import { useSmoothControls } from '../../../hooks/use-smooth-controls';
|
|
7
|
+
import { cn, hexToVec3 } from '../../../utils';
|
|
8
|
+
import { BLEND_MODES } from '.';
|
|
9
|
+
const vert = /*glsl*/ `
|
|
10
|
+
varying vec2 vUv;
|
|
11
|
+
void main() {
|
|
12
|
+
vUv = uv;
|
|
13
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
const frag = /*glsl*/ `
|
|
17
|
+
uniform vec2 uRes;
|
|
18
|
+
uniform float uDpr, uSize, uDensity, uOpacity;
|
|
19
|
+
uniform vec3 uColor;
|
|
20
|
+
varying vec2 vUv;
|
|
21
|
+
|
|
22
|
+
float hash(vec2 p) {
|
|
23
|
+
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
|
|
24
|
+
p3 += dot(p3, p3.yzx + 33.33);
|
|
25
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void main() {
|
|
29
|
+
float n = hash(floor(vUv * uRes / (uSize * uDpr)));
|
|
30
|
+
gl_FragColor = vec4(uColor, step(1.0 - uDensity, n)) * uOpacity;
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
export function Noise({ className, style }) {
|
|
34
|
+
const gpuTier = useGpuTier();
|
|
35
|
+
const c = useSmoothControls('Effects/Noise', {
|
|
36
|
+
blend: { options: BLEND_MODES, value: 'color-dodge' },
|
|
37
|
+
color: { value: '#eaeaea' },
|
|
38
|
+
density: { max: 1, min: 0, step: 0.01, value: 0.11 },
|
|
39
|
+
enabled: { value: true },
|
|
40
|
+
opacity: { max: 1, min: 0, step: 0.01, value: 0.55 },
|
|
41
|
+
size: { max: 10, min: 0.1, step: 0.1, value: 1 }
|
|
42
|
+
}, { collapsed: true });
|
|
43
|
+
const canvasRef = useRef(null);
|
|
44
|
+
const cRef = useRef(c);
|
|
45
|
+
cRef.current = c;
|
|
46
|
+
const enabled = c.enabled && gpuTier > 0;
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!canvasRef.current || !enabled) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const renderer = new THREE.WebGLRenderer({
|
|
52
|
+
alpha: true,
|
|
53
|
+
canvas: canvasRef.current,
|
|
54
|
+
premultipliedAlpha: false
|
|
55
|
+
});
|
|
56
|
+
renderer.setClearColor(0x000000, 0);
|
|
57
|
+
const scene = new THREE.Scene();
|
|
58
|
+
const camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
|
59
|
+
const geo = new THREE.PlaneGeometry(2, 2);
|
|
60
|
+
const mat = new THREE.ShaderMaterial({
|
|
61
|
+
fragmentShader: frag,
|
|
62
|
+
transparent: true,
|
|
63
|
+
uniforms: {
|
|
64
|
+
uColor: { value: hexToVec3(c.color) },
|
|
65
|
+
uDensity: { value: c.density },
|
|
66
|
+
uDpr: { value: 1 },
|
|
67
|
+
uOpacity: { value: c.opacity },
|
|
68
|
+
uRes: { value: new THREE.Vector2() },
|
|
69
|
+
uSize: { value: c.size }
|
|
70
|
+
},
|
|
71
|
+
vertexShader: vert
|
|
72
|
+
});
|
|
73
|
+
scene.add(new THREE.Mesh(geo, mat));
|
|
74
|
+
const resize = () => {
|
|
75
|
+
renderer.setSize(innerWidth, innerHeight);
|
|
76
|
+
renderer.setPixelRatio(devicePixelRatio);
|
|
77
|
+
mat.uniforms.uRes.value.set(innerWidth * devicePixelRatio, innerHeight * devicePixelRatio);
|
|
78
|
+
mat.uniforms.uDpr.value = devicePixelRatio;
|
|
79
|
+
};
|
|
80
|
+
resize();
|
|
81
|
+
window.addEventListener('resize', resize);
|
|
82
|
+
let raf;
|
|
83
|
+
const interval = gpuTier === 1 ? 100 : 0;
|
|
84
|
+
const loop = () => {
|
|
85
|
+
raf = interval
|
|
86
|
+
? setTimeout(loop, interval)
|
|
87
|
+
: requestAnimationFrame(loop);
|
|
88
|
+
const v = cRef.current;
|
|
89
|
+
mat.uniforms.uSize.value = v.size;
|
|
90
|
+
mat.uniforms.uDensity.value = v.density;
|
|
91
|
+
mat.uniforms.uColor.value = hexToVec3(v.color);
|
|
92
|
+
mat.uniforms.uOpacity.value = v.opacity;
|
|
93
|
+
renderer.render(scene, camera);
|
|
94
|
+
};
|
|
95
|
+
loop();
|
|
96
|
+
return () => {
|
|
97
|
+
window.removeEventListener('resize', resize);
|
|
98
|
+
if (interval) {
|
|
99
|
+
clearTimeout(raf);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
cancelAnimationFrame(raf);
|
|
103
|
+
}
|
|
104
|
+
mat.dispose();
|
|
105
|
+
geo.dispose();
|
|
106
|
+
renderer.dispose();
|
|
107
|
+
};
|
|
108
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
109
|
+
}, [enabled, gpuTier]);
|
|
110
|
+
if (!enabled) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
return (_jsx("canvas", { className: cn('h-full w-full', className), ref: canvasRef, style: { mixBlendMode: c.blend, ...style } }));
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=noise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noise.js","sourceRoot":"","sources":["../../../../src/ui/components/overlays/noise.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AACtE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,CAAA;AAE/B,MAAM,IAAI,GAAG,QAAQ,CAAC;;;;;;CAMrB,CAAA;AAED,MAAM,IAAI,GAAG,QAAQ,CAAC;;;;;;;;;;;;;;;;CAgBrB,C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,CAAC,CAAA;YAC3B,CAAC;YAED,GAAG,CAAC,OAAO,EAAE,CAAA;YACb,GAAG,CAAC,OAAO,EAAE,CAAA;YACb,QAAQ,CAAC,OAAO,EAAE,CAAA;QACpB,CAAC,CAAA;QACD,uDAAuD;IACzD,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IAEtB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,CACL,iBACE,SAAS,EAAE,EAAE,CAAC,eAAe,EAAE,SAAS,CAAC,EACzC,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,EAAE,GAC1C,CACH,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useSmoothControls } from '../../../hooks/use-smooth-controls';
|
|
4
|
+
import { cn } from '../../../utils';
|
|
5
|
+
import { hexToRgb } from '../../../utils/color';
|
|
6
|
+
import { BLEND_MODES } from '.';
|
|
7
|
+
export function Vignette({ className, style }) {
|
|
8
|
+
const c = useSmoothControls('Effects/Vignette', {
|
|
9
|
+
blend: { options: BLEND_MODES, value: 'lighten' },
|
|
10
|
+
bottomLeft: { max: 1, min: 0, step: 0.01, value: 0 },
|
|
11
|
+
bottomRight: { max: 1, min: 0, step: 0.01, value: 0 },
|
|
12
|
+
color: { value: '#ffbd38' },
|
|
13
|
+
enabled: { value: true },
|
|
14
|
+
opacity: { max: 1, min: 0, step: 0.01, value: 0.22 },
|
|
15
|
+
size: { max: 1, min: 0, step: 0.01, value: 1 },
|
|
16
|
+
topLeft: { max: 1, min: 0, step: 0.01, value: 0.35 },
|
|
17
|
+
topRight: { max: 1, min: 0, step: 0.01, value: 0 }
|
|
18
|
+
}, { collapsed: true });
|
|
19
|
+
if (!c.enabled)
|
|
20
|
+
return null;
|
|
21
|
+
const rgb = hexToRgb(c.color);
|
|
22
|
+
const s = c.size * 60;
|
|
23
|
+
const grad = (x, y, i) => i > 0 &&
|
|
24
|
+
`radial-gradient(ellipse at ${x}% ${y}%, rgba(${rgb},0) ${s}%, rgba(${rgb},${i}) 100%)`;
|
|
25
|
+
const bg = [
|
|
26
|
+
grad(0, 0, c.topLeft),
|
|
27
|
+
grad(100, 0, c.topRight),
|
|
28
|
+
grad(0, 100, c.bottomLeft),
|
|
29
|
+
grad(100, 100, c.bottomRight)
|
|
30
|
+
].filter(Boolean);
|
|
31
|
+
if (!bg.length)
|
|
32
|
+
return null;
|
|
33
|
+
return (_jsx("div", { className: cn('h-full w-full', className), style: {
|
|
34
|
+
background: bg.join(', '),
|
|
35
|
+
mixBlendMode: c.blend,
|
|
36
|
+
opacity: c.opacity,
|
|
37
|
+
...style
|
|
38
|
+
} }));
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=vignette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vignette.js","sourceRoot":"","sources":["../../../../src/ui/components/overlays/vignette.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AACtE,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,CAAA;AAE/B,MAAM,UAAU,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAiB;IAC1D,MAAM,CAAC,GAAG,iBAAiB,CACzB,kBAAkB,EAClB;QACE,KAAK,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,SAAkB,EAAE;QAC1D,UAAU,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,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C,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC;QACxB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU,CAAC;QAC1B,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC;KAC9B,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAEjB,IAAI,CAAC,EAAE,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IAE3B,OAAO,CACL,cACE,SAAS,EAAE,EAAE,CAAC,eAAe,EAAE,SAAS,CAAC,EACzC,KAAK,EAAE;YACL,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;YACzB,YAAY,EAAE,CAAC,CAAC,KAAK;YACrB,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,GAAG,KAAK;SACT,GACD,CACH,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type TypographyProps } from './typography';
|
|
2
|
+
export declare const Progress: ({ animate, barProps, children, className, speed, value, ...props }: ProgressProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
interface ProgressProps extends React.ComponentProps<'div'> {
|
|
4
|
+
animate?: boolean;
|
|
5
|
+
barProps?: TypographyProps<'span'>;
|
|
6
|
+
speed?: number;
|
|
7
|
+
value: number;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../../utils';
|
|
3
|
+
import { Typography } from './typography';
|
|
4
|
+
export const Progress = ({ animate = true, barProps, children, className, speed = 0.4, value, ...props }) => (_jsxs("div", { className: cn('relative flex min-h-[2.3rem] min-w-0 flex-1 items-stretch overflow-hidden', className), ...props, children: [_jsx(Typography, { ...barProps, className: cn('shrink-0 translate-y-0.5 truncate py-2', 'bg-midground/20', children ? 'px-2' : 'px-0', barProps?.className), mono: true, style: {
|
|
5
|
+
...(animate && { transition: `width ${speed}s steps(10, end)` }),
|
|
6
|
+
width: `${value}%`,
|
|
7
|
+
...barProps?.style
|
|
8
|
+
}, children: children }), _jsx("div", { className: "flex-1", style: {
|
|
9
|
+
'--x': '.5rem',
|
|
10
|
+
backgroundImage: `repeating-linear-gradient(to right, transparent 0 var(--x), color-mix(in srgb, var(--color-midground) 17%, transparent) var(--x) calc(var(--x) + 1px))`
|
|
11
|
+
} })] }));
|
|
12
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../../src/ui/components/progress.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAE,UAAU,EAAwB,MAAM,cAAc,CAAA;AAE/D,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EACvB,OAAO,GAAG,IAAI,EACd,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,KAAK,GAAG,GAAG,EACX,KAAK,EACL,GAAG,KAAK,EACM,EAAE,EAAE,CAAC,CACnB,eACE,SAAS,EAAE,EAAE,CACX,2EAA2E,EAC3E,SAAS,CACV,KACG,KAAK,aAET,KAAC,UAAU,OACL,QAAQ,EACZ,SAAS,EAAE,EAAE,CACX,wCAAwC,EACxC,iBAAiB,EACjB,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAC1B,QAAQ,EAAE,SAAS,CACpB,EACD,IAAI,QACJ,KAAK,EAAE;gBACL,GAAG,CAAC,OAAO,IAAI,EAAE,UAAU,EAAE,SAAS,KAAK,kBAAkB,EAAE,CAAC;gBAChE,KAAK,EAAE,GAAG,KAAK,GAAG;gBAClB,GAAG,QAAQ,EAAE,KAAK;aACnB,YAEA,QAAQ,GACE,EAEb,cACE,SAAS,EAAC,QAAQ,EAClB,KAAK,EACH;gBACE,KAAK,EAAE,OAAO;gBACd,eAAe,EAAE,wJAAwJ;aACnJ,GAE1B,IACE,CACP,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function SceneCanvas({ camera, children, className, contained, noEvents, style }: SceneCanvasProps): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
interface SceneCanvasProps {
|
|
3
|
+
camera?: {
|
|
4
|
+
far?: number;
|
|
5
|
+
near?: number;
|
|
6
|
+
position?: [number, number, number];
|
|
7
|
+
zoom?: number;
|
|
8
|
+
};
|
|
9
|
+
children: () => React.ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
contained?: boolean;
|
|
12
|
+
noEvents?: boolean;
|
|
13
|
+
style?: React.CSSProperties;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Canvas, useFrame, useThree } from '@react-three/fiber';
|
|
4
|
+
import { Suspense, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
+
import * as THREE from 'three';
|
|
6
|
+
const GL = {
|
|
7
|
+
alpha: true,
|
|
8
|
+
antialias: true,
|
|
9
|
+
depth: true,
|
|
10
|
+
outputColorSpace: 'srgb',
|
|
11
|
+
powerPreference: 'high-performance',
|
|
12
|
+
stencil: false
|
|
13
|
+
};
|
|
14
|
+
const tmp = {
|
|
15
|
+
camDir: new THREE.Vector3(),
|
|
16
|
+
hit: new THREE.Vector3(),
|
|
17
|
+
ndc: new THREE.Vector2(),
|
|
18
|
+
origin: new THREE.Vector3(0, 0, 0),
|
|
19
|
+
plane: new THREE.Plane(),
|
|
20
|
+
ray: new THREE.Raycaster()
|
|
21
|
+
};
|
|
22
|
+
function useBounds(target) {
|
|
23
|
+
const bounds = useRef(null);
|
|
24
|
+
useLayoutEffect(() => {
|
|
25
|
+
if (!target) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const measure = () => {
|
|
29
|
+
const b = target.getBoundingClientRect();
|
|
30
|
+
bounds.current = {
|
|
31
|
+
height: b.height,
|
|
32
|
+
pageX: b.left + window.scrollX,
|
|
33
|
+
pageY: b.top + window.scrollY,
|
|
34
|
+
width: b.width
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
measure();
|
|
38
|
+
const ro = new ResizeObserver(measure);
|
|
39
|
+
ro.observe(target);
|
|
40
|
+
ro.observe(document.body);
|
|
41
|
+
window.addEventListener('resize', measure, { passive: true });
|
|
42
|
+
return () => {
|
|
43
|
+
ro.disconnect();
|
|
44
|
+
window.removeEventListener('resize', measure);
|
|
45
|
+
};
|
|
46
|
+
}, [target]);
|
|
47
|
+
return bounds;
|
|
48
|
+
}
|
|
49
|
+
function PositionedGroup({ baseZoom, bounds, children }) {
|
|
50
|
+
const ref = useRef(null);
|
|
51
|
+
const { camera, size, viewport } = useThree();
|
|
52
|
+
useFrame(() => {
|
|
53
|
+
const g = ref.current;
|
|
54
|
+
const b = bounds.current;
|
|
55
|
+
if (!g || !b) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const left = b.pageX - window.scrollX;
|
|
59
|
+
const top = b.pageY - window.scrollY;
|
|
60
|
+
tmp.ndc.set(((left + b.width / 2) / size.width) * 2 - 1, 1 - ((top + b.height / 2) / size.height) * 2);
|
|
61
|
+
camera.getWorldDirection(tmp.camDir);
|
|
62
|
+
tmp.plane.setFromNormalAndCoplanarPoint(tmp.camDir, tmp.origin);
|
|
63
|
+
tmp.ray.setFromCamera(tmp.ndc, camera);
|
|
64
|
+
const hit = tmp.ray.ray.intersectPlane(tmp.plane, tmp.hit);
|
|
65
|
+
if (hit) {
|
|
66
|
+
g.position.copy(hit);
|
|
67
|
+
}
|
|
68
|
+
const zoom = camera.zoom ?? 1;
|
|
69
|
+
g.scale.setScalar(Math.min((b.width / size.width) * viewport.width, (b.height / size.height) * viewport.height) * (baseZoom > 0 ? zoom / baseZoom : 1));
|
|
70
|
+
});
|
|
71
|
+
return _jsx("group", { ref: ref, children: children });
|
|
72
|
+
}
|
|
73
|
+
export function SceneCanvas({ camera, children, className, contained, noEvents, style }) {
|
|
74
|
+
const [container, setContainer] = useState(null);
|
|
75
|
+
const baseZoom = camera?.zoom ?? 150;
|
|
76
|
+
const bounds = useBounds(contained ? (container?.parentElement ?? null) : null);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const el = contained && !noEvents ? container : null;
|
|
79
|
+
if (!el) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const lock = () => (document.body.style.userSelect = 'none');
|
|
83
|
+
const unlock = () => (document.body.style.userSelect = '');
|
|
84
|
+
el.addEventListener('pointerdown', lock);
|
|
85
|
+
window.addEventListener('pointerup', unlock);
|
|
86
|
+
return () => {
|
|
87
|
+
el.removeEventListener('pointerdown', lock);
|
|
88
|
+
window.removeEventListener('pointerup', unlock);
|
|
89
|
+
};
|
|
90
|
+
}, [container, contained, noEvents]);
|
|
91
|
+
const cam = useMemo(() => ({
|
|
92
|
+
far: camera?.far ?? 100,
|
|
93
|
+
near: camera?.near ?? -100,
|
|
94
|
+
position: camera?.position ?? [0, 0, 10],
|
|
95
|
+
zoom: baseZoom * (contained ? 1 : 2)
|
|
96
|
+
}), [baseZoom, camera, contained]);
|
|
97
|
+
const canvas = (_jsx(Canvas, { camera: cam, className: className, dpr: [1, 2], eventPrefix: contained ? 'client' : 'offset', eventSource: contained ? (container ?? undefined) : undefined, gl: GL, orthographic: true, style: contained
|
|
98
|
+
? {
|
|
99
|
+
height: '100dvh',
|
|
100
|
+
inset: 0,
|
|
101
|
+
pointerEvents: 'none',
|
|
102
|
+
position: 'fixed',
|
|
103
|
+
width: '100dvw',
|
|
104
|
+
zIndex: 0,
|
|
105
|
+
...style
|
|
106
|
+
}
|
|
107
|
+
: { height: '100%', width: '100%', ...style }, children: contained ? (_jsx(PositionedGroup, { baseZoom: baseZoom, bounds: bounds, children: children() })) : (children()) }));
|
|
108
|
+
return contained ? (_jsxs(Suspense, { children: [_jsx("div", { ref: setContainer, style: {
|
|
109
|
+
height: '100%',
|
|
110
|
+
inset: 0,
|
|
111
|
+
pointerEvents: noEvents ? 'none' : 'auto',
|
|
112
|
+
position: 'absolute',
|
|
113
|
+
width: '100%',
|
|
114
|
+
zIndex: 1
|
|
115
|
+
} }), canvas] })) : (canvas);
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=scene-canvas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene-canvas.js","sourceRoot":"","sources":["../../../src/ui/components/scene-canvas.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EACL,QAAQ,EACR,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAA;AACd,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,MAAM,EAAE,GAAG;IACT,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,IAAI;IACf,KAAK,EAAE,IAAI;IACX,gBAAgB,EAAE,MAAM;IACxB,eAAe,EAAE,kBAAkB;IACnC,OAAO,EAAE,KAAK;CACN,CAAA;AAEV,MAAM,GAAG,GAAG;IACV,MAAM,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE;IAC3B,GAAG,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE;IACxB,GAAG,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE;IACxB,MAAM,EAAE,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAClC,KAAK,EAAE,IAAI,KAAK,CAAC,KAAK,EAAE;IACxB,GAAG,EAAE,IAAI,KAAK,CAAC,SAAS,EAAE;CAC3B,CAAA;AAID,SAAS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gBACjB,KAAK,EAAE,QAAQ;gBACf,MAAM,EAAE,CAAC;gBACT,GAAG,KAAK;aACT;YACH,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,YAGhD,SAAS,CAAC,CAAC,CAAC,CACX,KAAC,eAAe,IAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,YAChD,QAAQ,EAAE,GACK,CACnB,CAAC,CAAC,CAAC,CACF,QAAQ,EAAE,CACX,GACM,CACV,CAAA;IAED,OAAO,SAAS,CAAC,CAAC,CAAC,CACjB,MAAC,QAAQ,eACP,cACE,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE;oBACL,MAAM,EAAE,MAAM;oBACd,KAAK,EAAE,CAAC;oBACR,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;oBACzC,QAAQ,EAAE,UAAU;oBACpB,KAAK,EAAE,MAAM;oBACb,MAAM,EAAE,CAAC;iBACV,GACD,EACD,MAAM,IACE,CACZ,CAAC,CAAC,CAAC,CACF,MAAM,CACP,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
export declare function Scramble({ children, dur, spread, target }: ScrambleProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
interface ScrambleProps {
|
|
4
|
+
children: string;
|
|
5
|
+
dur?: number;
|
|
6
|
+
spread?: number;
|
|
7
|
+
target?: RefObject<HTMLElement | null>;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
const CHARS = '.,·-─~+:;=*π""┐┌┘┴┬╗╔╝╚╬╠╣╩╦║░▒▓█▄▀▌▐■!?&#$@0123456789*';
|
|
5
|
+
export function Scramble({ children, dur = 666, spread = 1, target }) {
|
|
6
|
+
const text = String(children);
|
|
7
|
+
const len = text.length;
|
|
8
|
+
const [display, setDisplay] = useState(text);
|
|
9
|
+
const frame = useRef(null);
|
|
10
|
+
const waves = useRef([]);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const el = target?.current;
|
|
13
|
+
if (!el) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const animate = () => {
|
|
17
|
+
const t = Date.now();
|
|
18
|
+
waves.current = waves.current.filter(w => t - w.time < dur);
|
|
19
|
+
if (!waves.current.length) {
|
|
20
|
+
setDisplay(text);
|
|
21
|
+
frame.current = null;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
setDisplay(text
|
|
25
|
+
.split('')
|
|
26
|
+
.map((c, i) => {
|
|
27
|
+
if (c === ' ') {
|
|
28
|
+
return c;
|
|
29
|
+
}
|
|
30
|
+
for (const w of waves.current) {
|
|
31
|
+
const age = t - w.time;
|
|
32
|
+
const rad = (Math.min(age / dur, 1) *
|
|
33
|
+
(Math.max(w.pos, len - w.pos - 1) + 5)) /
|
|
34
|
+
spread;
|
|
35
|
+
const dist = Math.abs(i - w.pos);
|
|
36
|
+
const int = rad - dist;
|
|
37
|
+
if (dist <= rad && int > 0 && int <= 3) {
|
|
38
|
+
return CHARS[(dist * 3 + ((age / 40) | 0)) % CHARS.length];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return c;
|
|
42
|
+
})
|
|
43
|
+
.join(''));
|
|
44
|
+
frame.current = requestAnimationFrame(animate);
|
|
45
|
+
};
|
|
46
|
+
const onEnter = () => {
|
|
47
|
+
waves.current.push({ pos: len >> 1, time: Date.now() });
|
|
48
|
+
frame.current ?? (frame.current = requestAnimationFrame(animate));
|
|
49
|
+
};
|
|
50
|
+
el.addEventListener('mouseenter', onEnter);
|
|
51
|
+
return () => {
|
|
52
|
+
el.removeEventListener('mouseenter', onEnter);
|
|
53
|
+
frame.current && cancelAnimationFrame(frame.current);
|
|
54
|
+
};
|
|
55
|
+
}, [target, text, len, dur, spread]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
setDisplay(text);
|
|
58
|
+
}, [text]);
|
|
59
|
+
return _jsx(_Fragment, { children: display });
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=scramble.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scramble.js","sourceRoot":"","sources":["../../../src/ui/components/scramble.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGnD,MAAM,KAAK,GAAG,yDAAyD,CAAA;AAEvE,MAAM,UAAU,QAAQ,CAAC,EACvB,QAAQ,EACR,GAAG,GAAG,GAAG,EACT,MAAM,GAAG,CAAC,EACV,MAAM,EACQ;IACd,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAA;IACvB,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC5C,MAAM,KAAK,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAA;IACzC,MAAM,KAAK,GAAG,MAAM,CAAkC,EAAE,CAAC,CAAA;IAEzD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,CAAA;QAE1B,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,OAAM;QACR,CAAC;QAED,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YACpB,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,GAA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A;YAED,KAAK,CAAC,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC,CAAA;QAChD,CAAC,CAAA;QAED,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;YACvD,KAAK,CAAC,OAAO,KAAb,KAAK,CAAC,OAAO,GAAK,qBAAqB,CAAC,OAAO,CAAC,EAAA;QAClD,CAAC,CAAA;QAED,EAAE,CAAC,gBAAgB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;QAE1C,OAAO,GAAG,EAAE;YACV,EAAE,CAAC,mBAAmB,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;YAC7C,KAAK,CAAC,OAAO,IAAI,oBAAoB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QACtD,CAAC,CAAA;IACH,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAA;IAEpC,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,IAAI,CAAC,CAAA;IAClB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;IAEV,OAAO,4BAAG,OAAO,GAAI,CAAA;AACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SelectionSwitcher(): null;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
const colors = [
|
|
4
|
+
'oklch(85% 0.12 330)',
|
|
5
|
+
'oklch(85% 0.12 300)',
|
|
6
|
+
'oklch(85% 0.12 270)',
|
|
7
|
+
'oklch(85% 0.12 230)',
|
|
8
|
+
'oklch(85% 0.12 180)',
|
|
9
|
+
'oklch(85% 0.12 150)',
|
|
10
|
+
'oklch(85% 0.12 120)',
|
|
11
|
+
'oklch(85% 0.12 90)',
|
|
12
|
+
'oklch(85% 0.12 60)',
|
|
13
|
+
'oklch(85% 0.12 30)',
|
|
14
|
+
'oklch(88% 0.10 80)'
|
|
15
|
+
];
|
|
16
|
+
export function SelectionSwitcher() {
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const ac = new AbortController();
|
|
19
|
+
const { signal } = ac;
|
|
20
|
+
let idx = 0;
|
|
21
|
+
const cycle = () => requestAnimationFrame(() => document.documentElement.style.setProperty('--selection-bg', colors[(idx = (idx + 1) % colors.length)]));
|
|
22
|
+
const onKey = (e) => e.key.toLowerCase() === 'a' && (e.metaKey || e.ctrlKey) && cycle();
|
|
23
|
+
document.addEventListener('selectstart', cycle, { signal });
|
|
24
|
+
document.addEventListener('keydown', onKey, { signal });
|
|
25
|
+
return () => ac.abort();
|
|
26
|
+
}, []);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=selection-switcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-switcher.js","sourceRoot":"","sources":["../../../src/ui/components/selection-switcher.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEjC,MAAM,MAAM,GAAG;IACb,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,qBAAqB;IACrB,oBAAoB;IACpB,oBAAoB;IACpB,oBAAoB;IACpB,oBAAoB;CACZ,CAAA;AAEV,MAAM,UAAU,iBAAiB;IAC/B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,EAAE,GAAG,IAAI,eAAe,EAAE,CAAA;QAChC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAA;QAErB,IAAI,GAAG,GAAG,CAAC,CAAA;QAEX,MAAM,KAAK,GAAG,GAAG,EAAE,CACjB,qBAAqB,CAAC,GAAG,EAAE,CACzB,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CACxC,gBAAgB,EAChB,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAC1C,CACF,CAAA;QAEH,MAAM,KAAK,GAAG,CAAC,CAAgB,EAAE,EAAE,CACjC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,EAAE,CAAA;QAEpE,QAAQ,CAAC,gBAAgB,CAAC,aAAa,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;QAC3D,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;QAEvD,OAAO,GAAG,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;IACzB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ThreeElements } from '@react-three/fiber';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
export declare function Shader({ children, defines, depthTest, fragmentShader, uniforms, vertexShader, ...props }: ShaderProps): string | number | bigint | boolean | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
|
|
4
|
+
interface ShaderProps extends Omit<ThreeElements['mesh'], 'children'>, Pick<ThreeElements['shaderMaterial'], 'defines' | 'depthTest' | 'fragmentShader' | 'uniforms' | 'vertexShader'> {
|
|
5
|
+
children?: ((material: ReactNode) => ReactNode) | ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export {};
|