@shipfox/react-ui 0.6.0 → 0.7.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/.storybook/main.ts +12 -5
- package/.turbo/turbo-build.log +5 -5
- package/.turbo/turbo-check.log +2 -2
- package/.turbo/turbo-type.log +1 -1
- package/CHANGELOG.md +6 -0
- package/dist/components/dot-grid/dot-grid.d.ts +18 -0
- package/dist/components/dot-grid/dot-grid.d.ts.map +1 -0
- package/dist/components/dot-grid/dot-grid.js +295 -0
- package/dist/components/dot-grid/dot-grid.js.map +1 -0
- package/dist/components/dot-grid/index.d.ts +2 -0
- package/dist/components/dot-grid/index.d.ts.map +1 -0
- package/dist/components/dot-grid/index.js +3 -0
- package/dist/components/dot-grid/index.js.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/onboarding/sign-in.stories.js +16 -8
- package/dist/onboarding/sign-in.stories.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +11 -10
- package/src/components/dot-grid/dot-grid.tsx +325 -0
- package/src/components/dot-grid/index.ts +1 -0
- package/src/components/index.ts +2 -0
- package/src/onboarding/sign-in.stories.tsx +20 -8
package/.storybook/main.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import {resolve} from 'node:path';
|
|
2
1
|
import type {StorybookConfig} from '@storybook/react-vite';
|
|
3
|
-
import tailwindcss from '@tailwindcss/vite';
|
|
4
|
-
import react from '@vitejs/plugin-react';
|
|
5
2
|
|
|
6
3
|
const config: StorybookConfig = {
|
|
7
4
|
framework: '@storybook/react-vite',
|
|
8
5
|
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
|
|
9
6
|
addons: ['storybook-addon-pseudo-states', '@storybook/addon-vitest'],
|
|
10
|
-
viteFinal: (config) => {
|
|
11
|
-
|
|
7
|
+
viteFinal: async (config) => {
|
|
8
|
+
const [{default: react}, {default: tailwindcss}, {fileURLToPath}, {dirname, resolve}] =
|
|
9
|
+
await Promise.all([
|
|
10
|
+
import('@vitejs/plugin-react'),
|
|
11
|
+
import('@tailwindcss/vite'),
|
|
12
|
+
import('node:url'),
|
|
13
|
+
import('node:path'),
|
|
14
|
+
]);
|
|
12
15
|
|
|
16
|
+
config.plugins = config.plugins ?? [];
|
|
13
17
|
config.plugins.push(react(), tailwindcss());
|
|
14
18
|
|
|
19
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
20
|
+
const __dirname = dirname(__filename);
|
|
21
|
+
|
|
15
22
|
config.resolve = config.resolve ?? {};
|
|
16
23
|
config.resolve.alias = {
|
|
17
24
|
...config.resolve.alias,
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
WARN Issue while reading "/runnertmp/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @shipfox/react-ui@0.
|
|
3
|
+
> @shipfox/react-ui@0.7.0 build /runnertmp/_work/tooling/tooling/libs/react/ui
|
|
4
4
|
> swc && pnpm run build:css
|
|
5
5
|
|
|
6
|
-
Successfully compiled:
|
|
6
|
+
Successfully compiled: 116 files with swc (406.75ms)
|
|
7
7
|
WARN Issue while reading "/runnertmp/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
|
|
8
8
|
|
|
9
|
-
> @shipfox/react-ui@0.
|
|
9
|
+
> @shipfox/react-ui@0.7.0 build:css /runnertmp/_work/tooling/tooling/libs/react/ui
|
|
10
10
|
> vite build --config vite.css.config.ts && rm -f dist/css-entry.js dist/css-entry.js.map
|
|
11
11
|
|
|
12
12
|
[36mvite v7.2.2 [32mbuilding client environment for production...[36m[39m
|
|
@@ -14,6 +14,6 @@ transforming...
|
|
|
14
14
|
[32m✓[39m 2 modules transformed.
|
|
15
15
|
rendering chunks...
|
|
16
16
|
computing gzip size...
|
|
17
|
-
[2mdist/[22m[35mstyles.css [39m[1m[2m84.
|
|
17
|
+
[2mdist/[22m[35mstyles.css [39m[1m[2m84.62 kB[22m[1m[22m[2m │ gzip: 13.44 kB[22m
|
|
18
18
|
[2mdist/[22m[36mcss-entry.js [39m[1m[2m 0.00 kB[22m[1m[22m[2m │ gzip: 0.02 kB[22m
|
|
19
|
-
[32m✓ built in
|
|
19
|
+
[32m✓ built in 745ms[39m
|
package/.turbo/turbo-check.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
WARN Issue while reading "/runnertmp/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @shipfox/react-ui@0.
|
|
3
|
+
> @shipfox/react-ui@0.7.0 check /runnertmp/_work/tooling/tooling/libs/react/ui
|
|
4
4
|
> biome-check --fix
|
|
5
5
|
|
|
6
|
-
Checked
|
|
6
|
+
Checked 135 files in 240ms. No fixes applied.
|
package/.turbo/turbo-type.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
WARN Issue while reading "/runnertmp/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @shipfox/react-ui@0.
|
|
3
|
+
> @shipfox/react-ui@0.7.0 type /runnertmp/_work/tooling/tooling/libs/react/ui
|
|
4
4
|
> tsc-emit
|
|
5
5
|
|
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface DotGridProps {
|
|
3
|
+
dotSize?: number;
|
|
4
|
+
gap?: number;
|
|
5
|
+
baseColor?: string;
|
|
6
|
+
activeColor?: string;
|
|
7
|
+
proximity?: number;
|
|
8
|
+
speedTrigger?: number;
|
|
9
|
+
shockRadius?: number;
|
|
10
|
+
shockStrength?: number;
|
|
11
|
+
maxSpeed?: number;
|
|
12
|
+
resistance?: number;
|
|
13
|
+
returnDuration?: number;
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
}
|
|
17
|
+
export declare function DotGrid({ dotSize, gap, baseColor, activeColor, proximity, speedTrigger, shockRadius, shockStrength, maxSpeed, resistance, returnDuration, className, style, }: DotGridProps): React.JSX.Element;
|
|
18
|
+
//# sourceMappingURL=dot-grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dot-grid.d.ts","sourceRoot":"","sources":["../../../src/components/dot-grid/dot-grid.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA2B/B,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAkBD,wBAAgB,OAAO,CAAC,EACtB,OAAY,EACZ,GAAQ,EACR,SAAqB,EACrB,WAAuB,EACvB,SAAe,EACf,YAAkB,EAClB,WAAiB,EACjB,aAAiB,EACjB,QAAe,EACf,UAAgB,EAChB,cAAoB,EACpB,SAAc,EACd,KAAK,GACN,EAAE,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAyPlC"}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { gsap } from 'gsap';
|
|
3
|
+
import { InertiaPlugin } from 'gsap/InertiaPlugin';
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
5
|
+
import { cn } from '../../utils/index.js';
|
|
6
|
+
gsap.registerPlugin(InertiaPlugin);
|
|
7
|
+
const HEX_COLOR_REGEX = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
|
|
8
|
+
const throttle = (func, limit)=>{
|
|
9
|
+
let lastCall = 0;
|
|
10
|
+
return (...args)=>{
|
|
11
|
+
const now = performance.now();
|
|
12
|
+
if (now - lastCall >= limit) {
|
|
13
|
+
lastCall = now;
|
|
14
|
+
func(...args);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
function hexToRgb(hex) {
|
|
19
|
+
const m = hex.match(HEX_COLOR_REGEX);
|
|
20
|
+
if (!m) return {
|
|
21
|
+
r: 0,
|
|
22
|
+
g: 0,
|
|
23
|
+
b: 0
|
|
24
|
+
};
|
|
25
|
+
return {
|
|
26
|
+
r: parseInt(m[1], 16),
|
|
27
|
+
g: parseInt(m[2], 16),
|
|
28
|
+
b: parseInt(m[3], 16)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function DotGrid({ dotSize = 16, gap = 32, baseColor = '#5227FF', activeColor = '#5227FF', proximity = 150, speedTrigger = 100, shockRadius = 250, shockStrength = 5, maxSpeed = 5000, resistance = 750, returnDuration = 1.5, className = '', style }) {
|
|
32
|
+
const wrapperRef = useRef(null);
|
|
33
|
+
const canvasRef = useRef(null);
|
|
34
|
+
const dotsRef = useRef([]);
|
|
35
|
+
const pointerRef = useRef({
|
|
36
|
+
x: 0,
|
|
37
|
+
y: 0,
|
|
38
|
+
vx: 0,
|
|
39
|
+
vy: 0,
|
|
40
|
+
speed: 0,
|
|
41
|
+
lastTime: 0,
|
|
42
|
+
lastX: 0,
|
|
43
|
+
lastY: 0
|
|
44
|
+
});
|
|
45
|
+
const baseRgb = useMemo(()=>hexToRgb(baseColor), [
|
|
46
|
+
baseColor
|
|
47
|
+
]);
|
|
48
|
+
const activeRgb = useMemo(()=>hexToRgb(activeColor), [
|
|
49
|
+
activeColor
|
|
50
|
+
]);
|
|
51
|
+
const colorGradient = useMemo(()=>{
|
|
52
|
+
const gradient = new Array(256);
|
|
53
|
+
for(let i = 0; i < 256; i++){
|
|
54
|
+
const normalizedSqDist = i / 255;
|
|
55
|
+
const normalizedDist = Math.sqrt(normalizedSqDist);
|
|
56
|
+
const t = 1 - normalizedDist;
|
|
57
|
+
const r = Math.round(baseRgb.r + (activeRgb.r - baseRgb.r) * t);
|
|
58
|
+
const g = Math.round(baseRgb.g + (activeRgb.g - baseRgb.g) * t);
|
|
59
|
+
const b = Math.round(baseRgb.b + (activeRgb.b - baseRgb.b) * t);
|
|
60
|
+
gradient[i] = `rgb(${r},${g},${b})`;
|
|
61
|
+
}
|
|
62
|
+
return gradient;
|
|
63
|
+
}, [
|
|
64
|
+
baseRgb,
|
|
65
|
+
activeRgb
|
|
66
|
+
]);
|
|
67
|
+
const circlePath = useMemo(()=>{
|
|
68
|
+
if (typeof window === 'undefined' || !window.Path2D) return null;
|
|
69
|
+
const p = new Path2D();
|
|
70
|
+
p.arc(0, 0, dotSize / 2, 0, Math.PI * 2);
|
|
71
|
+
return p;
|
|
72
|
+
}, [
|
|
73
|
+
dotSize
|
|
74
|
+
]);
|
|
75
|
+
const buildGrid = useCallback(()=>{
|
|
76
|
+
const wrap = wrapperRef.current;
|
|
77
|
+
const canvas = canvasRef.current;
|
|
78
|
+
if (!wrap || !canvas) return;
|
|
79
|
+
const { width, height } = wrap.getBoundingClientRect();
|
|
80
|
+
const dpr = window.devicePixelRatio || 1;
|
|
81
|
+
canvas.width = width * dpr;
|
|
82
|
+
canvas.height = height * dpr;
|
|
83
|
+
canvas.style.width = `${width}px`;
|
|
84
|
+
canvas.style.height = `${height}px`;
|
|
85
|
+
const ctx = canvas.getContext('2d');
|
|
86
|
+
if (ctx) ctx.scale(dpr, dpr);
|
|
87
|
+
const cols = Math.floor((width + gap) / (dotSize + gap));
|
|
88
|
+
const rows = Math.floor((height + gap) / (dotSize + gap));
|
|
89
|
+
const cell = dotSize + gap;
|
|
90
|
+
const gridW = cell * cols - gap;
|
|
91
|
+
const gridH = cell * rows - gap;
|
|
92
|
+
const extraX = width - gridW;
|
|
93
|
+
const extraY = height - gridH;
|
|
94
|
+
const startX = extraX / 2 + dotSize / 2;
|
|
95
|
+
const startY = extraY / 2 + dotSize / 2;
|
|
96
|
+
const dots = [];
|
|
97
|
+
for(let y = 0; y < rows; y++){
|
|
98
|
+
for(let x = 0; x < cols; x++){
|
|
99
|
+
const cx = startX + x * cell;
|
|
100
|
+
const cy = startY + y * cell;
|
|
101
|
+
dots.push({
|
|
102
|
+
cx,
|
|
103
|
+
cy,
|
|
104
|
+
xOffset: 0,
|
|
105
|
+
yOffset: 0,
|
|
106
|
+
_inertiaApplied: false
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
dotsRef.current = dots;
|
|
111
|
+
}, [
|
|
112
|
+
dotSize,
|
|
113
|
+
gap
|
|
114
|
+
]);
|
|
115
|
+
useEffect(()=>{
|
|
116
|
+
if (!circlePath) return;
|
|
117
|
+
let rafId;
|
|
118
|
+
const proxSq = proximity * proximity;
|
|
119
|
+
const draw = ()=>{
|
|
120
|
+
const canvas = canvasRef.current;
|
|
121
|
+
if (!canvas) return;
|
|
122
|
+
const ctx = canvas.getContext('2d');
|
|
123
|
+
if (!ctx) return;
|
|
124
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
125
|
+
const { x: px, y: py } = pointerRef.current;
|
|
126
|
+
for (const dot of dotsRef.current){
|
|
127
|
+
const ox = dot.cx + dot.xOffset;
|
|
128
|
+
const oy = dot.cy + dot.yOffset;
|
|
129
|
+
const dx = dot.cx - px;
|
|
130
|
+
const dy = dot.cy - py;
|
|
131
|
+
const dsq = dx * dx + dy * dy;
|
|
132
|
+
let fillColor = baseColor;
|
|
133
|
+
if (dsq <= proxSq) {
|
|
134
|
+
const normalizedSqDist = dsq / proxSq;
|
|
135
|
+
const index = Math.min(255, Math.max(0, Math.round(normalizedSqDist * 255)));
|
|
136
|
+
fillColor = colorGradient[index];
|
|
137
|
+
}
|
|
138
|
+
ctx.save();
|
|
139
|
+
ctx.translate(ox, oy);
|
|
140
|
+
ctx.fillStyle = fillColor;
|
|
141
|
+
ctx.fill(circlePath);
|
|
142
|
+
ctx.restore();
|
|
143
|
+
}
|
|
144
|
+
rafId = requestAnimationFrame(draw);
|
|
145
|
+
};
|
|
146
|
+
draw();
|
|
147
|
+
return ()=>cancelAnimationFrame(rafId);
|
|
148
|
+
}, [
|
|
149
|
+
proximity,
|
|
150
|
+
baseColor,
|
|
151
|
+
colorGradient,
|
|
152
|
+
circlePath
|
|
153
|
+
]);
|
|
154
|
+
useEffect(()=>{
|
|
155
|
+
buildGrid();
|
|
156
|
+
let ro = null;
|
|
157
|
+
if ('ResizeObserver' in window) {
|
|
158
|
+
ro = new ResizeObserver(buildGrid);
|
|
159
|
+
wrapperRef.current && ro.observe(wrapperRef.current);
|
|
160
|
+
} else {
|
|
161
|
+
window.addEventListener('resize', buildGrid);
|
|
162
|
+
}
|
|
163
|
+
return ()=>{
|
|
164
|
+
if (ro) ro.disconnect();
|
|
165
|
+
else window.removeEventListener('resize', buildGrid);
|
|
166
|
+
};
|
|
167
|
+
}, [
|
|
168
|
+
buildGrid
|
|
169
|
+
]);
|
|
170
|
+
useEffect(()=>{
|
|
171
|
+
const onMove = (e)=>{
|
|
172
|
+
const now = performance.now();
|
|
173
|
+
const pr = pointerRef.current;
|
|
174
|
+
const dt = pr.lastTime ? now - pr.lastTime : 16;
|
|
175
|
+
const dx = e.clientX - pr.lastX;
|
|
176
|
+
const dy = e.clientY - pr.lastY;
|
|
177
|
+
let vx = dx / dt * 1000;
|
|
178
|
+
let vy = dy / dt * 1000;
|
|
179
|
+
let speed = Math.hypot(vx, vy);
|
|
180
|
+
if (speed > maxSpeed) {
|
|
181
|
+
const scale = maxSpeed / speed;
|
|
182
|
+
vx *= scale;
|
|
183
|
+
vy *= scale;
|
|
184
|
+
speed = maxSpeed;
|
|
185
|
+
}
|
|
186
|
+
pr.lastTime = now;
|
|
187
|
+
pr.lastX = e.clientX;
|
|
188
|
+
pr.lastY = e.clientY;
|
|
189
|
+
pr.vx = vx;
|
|
190
|
+
pr.vy = vy;
|
|
191
|
+
pr.speed = speed;
|
|
192
|
+
const canvas = canvasRef.current;
|
|
193
|
+
if (!canvas) return;
|
|
194
|
+
const rect = canvas.getBoundingClientRect();
|
|
195
|
+
pr.x = e.clientX - rect.left;
|
|
196
|
+
pr.y = e.clientY - rect.top;
|
|
197
|
+
for (const dot of dotsRef.current){
|
|
198
|
+
const dist = Math.hypot(dot.cx - pr.x, dot.cy - pr.y);
|
|
199
|
+
if (speed > speedTrigger && dist < proximity && !dot._inertiaApplied) {
|
|
200
|
+
dot._inertiaApplied = true;
|
|
201
|
+
gsap.killTweensOf(dot);
|
|
202
|
+
const pushX = dot.cx - pr.x + vx * 0.005;
|
|
203
|
+
const pushY = dot.cy - pr.y + vy * 0.005;
|
|
204
|
+
gsap.to(dot, {
|
|
205
|
+
inertia: {
|
|
206
|
+
xOffset: pushX,
|
|
207
|
+
yOffset: pushY,
|
|
208
|
+
resistance
|
|
209
|
+
},
|
|
210
|
+
onComplete: ()=>{
|
|
211
|
+
gsap.to(dot, {
|
|
212
|
+
xOffset: 0,
|
|
213
|
+
yOffset: 0,
|
|
214
|
+
duration: returnDuration,
|
|
215
|
+
ease: 'elastic.out(1,0.75)'
|
|
216
|
+
});
|
|
217
|
+
dot._inertiaApplied = false;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const onClick = (e)=>{
|
|
224
|
+
const canvas = canvasRef.current;
|
|
225
|
+
if (!canvas) return;
|
|
226
|
+
const rect = canvas.getBoundingClientRect();
|
|
227
|
+
const cx = e.clientX - rect.left;
|
|
228
|
+
const cy = e.clientY - rect.top;
|
|
229
|
+
for (const dot of dotsRef.current){
|
|
230
|
+
const dist = Math.hypot(dot.cx - cx, dot.cy - cy);
|
|
231
|
+
if (dist < shockRadius && !dot._inertiaApplied) {
|
|
232
|
+
dot._inertiaApplied = true;
|
|
233
|
+
gsap.killTweensOf(dot);
|
|
234
|
+
const falloff = Math.max(0, 1 - dist / shockRadius);
|
|
235
|
+
const pushX = (dot.cx - cx) * shockStrength * falloff;
|
|
236
|
+
const pushY = (dot.cy - cy) * shockStrength * falloff;
|
|
237
|
+
gsap.to(dot, {
|
|
238
|
+
inertia: {
|
|
239
|
+
xOffset: pushX,
|
|
240
|
+
yOffset: pushY,
|
|
241
|
+
resistance
|
|
242
|
+
},
|
|
243
|
+
onComplete: ()=>{
|
|
244
|
+
gsap.to(dot, {
|
|
245
|
+
xOffset: 0,
|
|
246
|
+
yOffset: 0,
|
|
247
|
+
duration: returnDuration,
|
|
248
|
+
ease: 'elastic.out(1,0.75)'
|
|
249
|
+
});
|
|
250
|
+
dot._inertiaApplied = false;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
const throttledMove = throttle(onMove, 50);
|
|
257
|
+
const wrapper = wrapperRef.current;
|
|
258
|
+
if (wrapper) {
|
|
259
|
+
wrapper.addEventListener('mousemove', throttledMove, {
|
|
260
|
+
passive: true
|
|
261
|
+
});
|
|
262
|
+
wrapper.addEventListener('click', onClick);
|
|
263
|
+
}
|
|
264
|
+
return ()=>{
|
|
265
|
+
if (wrapper) {
|
|
266
|
+
wrapper.removeEventListener('mousemove', throttledMove);
|
|
267
|
+
wrapper.removeEventListener('click', onClick);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
}, [
|
|
271
|
+
maxSpeed,
|
|
272
|
+
speedTrigger,
|
|
273
|
+
proximity,
|
|
274
|
+
resistance,
|
|
275
|
+
returnDuration,
|
|
276
|
+
shockRadius,
|
|
277
|
+
shockStrength
|
|
278
|
+
]);
|
|
279
|
+
return /*#__PURE__*/ _jsx("section", {
|
|
280
|
+
className: cn('p-4 flex items-center justify-center h-full w-full relative', className),
|
|
281
|
+
style: style,
|
|
282
|
+
role: "presentation",
|
|
283
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
284
|
+
ref: wrapperRef,
|
|
285
|
+
className: "w-full h-full relative",
|
|
286
|
+
children: /*#__PURE__*/ _jsx("canvas", {
|
|
287
|
+
ref: canvasRef,
|
|
288
|
+
className: "absolute inset-0 w-full h-full pointer-events-none",
|
|
289
|
+
"aria-hidden": "true"
|
|
290
|
+
})
|
|
291
|
+
})
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
//# sourceMappingURL=dot-grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/dot-grid/dot-grid.tsx"],"sourcesContent":["import {gsap} from 'gsap';\nimport {InertiaPlugin} from 'gsap/InertiaPlugin';\nimport type React from 'react';\nimport {useCallback, useEffect, useMemo, useRef} from 'react';\nimport {cn} from 'utils';\n\ngsap.registerPlugin(InertiaPlugin);\n\nconst HEX_COLOR_REGEX = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i;\n\nconst throttle = <T extends (...args: never[]) => void>(func: T, limit: number): T => {\n let lastCall = 0;\n return ((...args: Parameters<T>) => {\n const now = performance.now();\n if (now - lastCall >= limit) {\n lastCall = now;\n func(...args);\n }\n }) as T;\n};\n\ninterface Dot {\n cx: number;\n cy: number;\n xOffset: number;\n yOffset: number;\n _inertiaApplied: boolean;\n}\n\nexport interface DotGridProps {\n dotSize?: number;\n gap?: number;\n baseColor?: string;\n activeColor?: string;\n proximity?: number;\n speedTrigger?: number;\n shockRadius?: number;\n shockStrength?: number;\n maxSpeed?: number;\n resistance?: number;\n returnDuration?: number;\n className?: string;\n style?: React.CSSProperties;\n}\n\ntype RgbColor = {\n r: number;\n g: number;\n b: number;\n};\n\nfunction hexToRgb(hex: string): RgbColor {\n const m = hex.match(HEX_COLOR_REGEX);\n if (!m) return {r: 0, g: 0, b: 0};\n return {\n r: parseInt(m[1], 16),\n g: parseInt(m[2], 16),\n b: parseInt(m[3], 16),\n };\n}\n\nexport function DotGrid({\n dotSize = 16,\n gap = 32,\n baseColor = '#5227FF',\n activeColor = '#5227FF',\n proximity = 150,\n speedTrigger = 100,\n shockRadius = 250,\n shockStrength = 5,\n maxSpeed = 5000,\n resistance = 750,\n returnDuration = 1.5,\n className = '',\n style,\n}: DotGridProps): React.JSX.Element {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n const dotsRef = useRef<Dot[]>([]);\n const pointerRef = useRef({\n x: 0,\n y: 0,\n vx: 0,\n vy: 0,\n speed: 0,\n lastTime: 0,\n lastX: 0,\n lastY: 0,\n });\n\n const baseRgb = useMemo(() => hexToRgb(baseColor), [baseColor]);\n const activeRgb = useMemo(() => hexToRgb(activeColor), [activeColor]);\n\n const colorGradient = useMemo(() => {\n const gradient: string[] = new Array(256);\n for (let i = 0; i < 256; i++) {\n const normalizedSqDist = i / 255;\n const normalizedDist = Math.sqrt(normalizedSqDist);\n const t = 1 - normalizedDist;\n const r = Math.round(baseRgb.r + (activeRgb.r - baseRgb.r) * t);\n const g = Math.round(baseRgb.g + (activeRgb.g - baseRgb.g) * t);\n const b = Math.round(baseRgb.b + (activeRgb.b - baseRgb.b) * t);\n gradient[i] = `rgb(${r},${g},${b})`;\n }\n return gradient;\n }, [baseRgb, activeRgb]);\n\n const circlePath = useMemo(() => {\n if (typeof window === 'undefined' || !window.Path2D) return null;\n\n const p = new Path2D();\n p.arc(0, 0, dotSize / 2, 0, Math.PI * 2);\n return p;\n }, [dotSize]);\n\n const buildGrid = useCallback(() => {\n const wrap = wrapperRef.current;\n const canvas = canvasRef.current;\n if (!wrap || !canvas) return;\n\n const {width, height} = wrap.getBoundingClientRect();\n const dpr = window.devicePixelRatio || 1;\n\n canvas.width = width * dpr;\n canvas.height = height * dpr;\n canvas.style.width = `${width}px`;\n canvas.style.height = `${height}px`;\n const ctx = canvas.getContext('2d');\n if (ctx) ctx.scale(dpr, dpr);\n\n const cols = Math.floor((width + gap) / (dotSize + gap));\n const rows = Math.floor((height + gap) / (dotSize + gap));\n const cell = dotSize + gap;\n\n const gridW = cell * cols - gap;\n const gridH = cell * rows - gap;\n\n const extraX = width - gridW;\n const extraY = height - gridH;\n\n const startX = extraX / 2 + dotSize / 2;\n const startY = extraY / 2 + dotSize / 2;\n\n const dots: Dot[] = [];\n for (let y = 0; y < rows; y++) {\n for (let x = 0; x < cols; x++) {\n const cx = startX + x * cell;\n const cy = startY + y * cell;\n dots.push({cx, cy, xOffset: 0, yOffset: 0, _inertiaApplied: false});\n }\n }\n dotsRef.current = dots;\n }, [dotSize, gap]);\n\n useEffect(() => {\n if (!circlePath) return;\n\n let rafId: number;\n const proxSq = proximity * proximity;\n\n const draw = () => {\n const canvas = canvasRef.current;\n if (!canvas) return;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n\n const {x: px, y: py} = pointerRef.current;\n\n for (const dot of dotsRef.current) {\n const ox = dot.cx + dot.xOffset;\n const oy = dot.cy + dot.yOffset;\n const dx = dot.cx - px;\n const dy = dot.cy - py;\n const dsq = dx * dx + dy * dy;\n\n let fillColor = baseColor;\n if (dsq <= proxSq) {\n const normalizedSqDist = dsq / proxSq;\n const index = Math.min(255, Math.max(0, Math.round(normalizedSqDist * 255)));\n fillColor = colorGradient[index];\n }\n\n ctx.save();\n ctx.translate(ox, oy);\n ctx.fillStyle = fillColor;\n ctx.fill(circlePath);\n ctx.restore();\n }\n\n rafId = requestAnimationFrame(draw);\n };\n\n draw();\n return () => cancelAnimationFrame(rafId);\n }, [proximity, baseColor, colorGradient, circlePath]);\n\n useEffect(() => {\n buildGrid();\n let ro: ResizeObserver | null = null;\n if ('ResizeObserver' in window) {\n ro = new ResizeObserver(buildGrid);\n wrapperRef.current && ro.observe(wrapperRef.current);\n } else {\n (window as Window).addEventListener('resize', buildGrid);\n }\n return () => {\n if (ro) ro.disconnect();\n else window.removeEventListener('resize', buildGrid);\n };\n }, [buildGrid]);\n\n useEffect(() => {\n const onMove = (e: MouseEvent) => {\n const now = performance.now();\n const pr = pointerRef.current;\n const dt = pr.lastTime ? now - pr.lastTime : 16;\n const dx = e.clientX - pr.lastX;\n const dy = e.clientY - pr.lastY;\n let vx = (dx / dt) * 1000;\n let vy = (dy / dt) * 1000;\n let speed = Math.hypot(vx, vy);\n if (speed > maxSpeed) {\n const scale = maxSpeed / speed;\n vx *= scale;\n vy *= scale;\n speed = maxSpeed;\n }\n pr.lastTime = now;\n pr.lastX = e.clientX;\n pr.lastY = e.clientY;\n pr.vx = vx;\n pr.vy = vy;\n pr.speed = speed;\n\n const canvas = canvasRef.current;\n if (!canvas) return;\n const rect = canvas.getBoundingClientRect();\n pr.x = e.clientX - rect.left;\n pr.y = e.clientY - rect.top;\n\n for (const dot of dotsRef.current) {\n const dist = Math.hypot(dot.cx - pr.x, dot.cy - pr.y);\n if (speed > speedTrigger && dist < proximity && !dot._inertiaApplied) {\n dot._inertiaApplied = true;\n gsap.killTweensOf(dot);\n const pushX = dot.cx - pr.x + vx * 0.005;\n const pushY = dot.cy - pr.y + vy * 0.005;\n gsap.to(dot, {\n inertia: {xOffset: pushX, yOffset: pushY, resistance},\n onComplete: () => {\n gsap.to(dot, {\n xOffset: 0,\n yOffset: 0,\n duration: returnDuration,\n ease: 'elastic.out(1,0.75)',\n });\n dot._inertiaApplied = false;\n },\n });\n }\n }\n };\n\n const onClick = (e: MouseEvent) => {\n const canvas = canvasRef.current;\n if (!canvas) return;\n const rect = canvas.getBoundingClientRect();\n const cx = e.clientX - rect.left;\n const cy = e.clientY - rect.top;\n for (const dot of dotsRef.current) {\n const dist = Math.hypot(dot.cx - cx, dot.cy - cy);\n if (dist < shockRadius && !dot._inertiaApplied) {\n dot._inertiaApplied = true;\n gsap.killTweensOf(dot);\n const falloff = Math.max(0, 1 - dist / shockRadius);\n const pushX = (dot.cx - cx) * shockStrength * falloff;\n const pushY = (dot.cy - cy) * shockStrength * falloff;\n gsap.to(dot, {\n inertia: {xOffset: pushX, yOffset: pushY, resistance},\n onComplete: () => {\n gsap.to(dot, {\n xOffset: 0,\n yOffset: 0,\n duration: returnDuration,\n ease: 'elastic.out(1,0.75)',\n });\n dot._inertiaApplied = false;\n },\n });\n }\n }\n };\n\n const throttledMove = throttle(onMove, 50) as (e: MouseEvent) => void;\n const wrapper = wrapperRef.current;\n if (wrapper) {\n wrapper.addEventListener('mousemove', throttledMove, {passive: true});\n wrapper.addEventListener('click', onClick);\n }\n return () => {\n if (wrapper) {\n wrapper.removeEventListener('mousemove', throttledMove);\n wrapper.removeEventListener('click', onClick);\n }\n };\n }, [maxSpeed, speedTrigger, proximity, resistance, returnDuration, shockRadius, shockStrength]);\n\n return (\n <section\n className={cn('p-4 flex items-center justify-center h-full w-full relative', className)}\n style={style}\n role=\"presentation\"\n >\n <div ref={wrapperRef} className=\"w-full h-full relative\">\n {/** biome-ignore lint/a11y/noAriaHiddenOnFocusable: <canvas is not focusable> */}\n <canvas\n ref={canvasRef}\n className=\"absolute inset-0 w-full h-full pointer-events-none\"\n aria-hidden=\"true\"\n />\n </div>\n </section>\n );\n}\n"],"names":["gsap","InertiaPlugin","useCallback","useEffect","useMemo","useRef","cn","registerPlugin","HEX_COLOR_REGEX","throttle","func","limit","lastCall","args","now","performance","hexToRgb","hex","m","match","r","g","b","parseInt","DotGrid","dotSize","gap","baseColor","activeColor","proximity","speedTrigger","shockRadius","shockStrength","maxSpeed","resistance","returnDuration","className","style","wrapperRef","canvasRef","dotsRef","pointerRef","x","y","vx","vy","speed","lastTime","lastX","lastY","baseRgb","activeRgb","colorGradient","gradient","Array","i","normalizedSqDist","normalizedDist","Math","sqrt","t","round","circlePath","window","Path2D","p","arc","PI","buildGrid","wrap","current","canvas","width","height","getBoundingClientRect","dpr","devicePixelRatio","ctx","getContext","scale","cols","floor","rows","cell","gridW","gridH","extraX","extraY","startX","startY","dots","cx","cy","push","xOffset","yOffset","_inertiaApplied","rafId","proxSq","draw","clearRect","px","py","dot","ox","oy","dx","dy","dsq","fillColor","index","min","max","save","translate","fillStyle","fill","restore","requestAnimationFrame","cancelAnimationFrame","ro","ResizeObserver","observe","addEventListener","disconnect","removeEventListener","onMove","e","pr","dt","clientX","clientY","hypot","rect","left","top","dist","killTweensOf","pushX","pushY","to","inertia","onComplete","duration","ease","onClick","falloff","throttledMove","wrapper","passive","section","role","div","ref","aria-hidden"],"mappings":";AAAA,SAAQA,IAAI,QAAO,OAAO;AAC1B,SAAQC,aAAa,QAAO,qBAAqB;AAEjD,SAAQC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAO,QAAQ;AAC9D,SAAQC,EAAE,QAAO,QAAQ;AAEzBN,KAAKO,cAAc,CAACN;AAEpB,MAAMO,kBAAkB;AAExB,MAAMC,WAAW,CAAuCC,MAASC;IAC/D,IAAIC,WAAW;IACf,OAAQ,CAAC,GAAGC;QACV,MAAMC,MAAMC,YAAYD,GAAG;QAC3B,IAAIA,MAAMF,YAAYD,OAAO;YAC3BC,WAAWE;YACXJ,QAAQG;QACV;IACF;AACF;AAgCA,SAASG,SAASC,GAAW;IAC3B,MAAMC,IAAID,IAAIE,KAAK,CAACX;IACpB,IAAI,CAACU,GAAG,OAAO;QAACE,GAAG;QAAGC,GAAG;QAAGC,GAAG;IAAC;IAChC,OAAO;QACLF,GAAGG,SAASL,CAAC,CAAC,EAAE,EAAE;QAClBG,GAAGE,SAASL,CAAC,CAAC,EAAE,EAAE;QAClBI,GAAGC,SAASL,CAAC,CAAC,EAAE,EAAE;IACpB;AACF;AAEA,OAAO,SAASM,QAAQ,EACtBC,UAAU,EA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eAAe;gBAACE,SAAS;YAAI;YACnED,QAAQzB,gBAAgB,CAAC,SAASsB;QACpC;QACA,OAAO;YACL,IAAIG,SAAS;gBACXA,QAAQvB,mBAAmB,CAAC,aAAasB;gBACzCC,QAAQvB,mBAAmB,CAAC,SAASoB;YACvC;QACF;IACF,GAAG;QAAChH;QAAUH;QAAcD;QAAWK;QAAYC;QAAgBJ;QAAaC;KAAc;IAE9F,qBACE,KAACsH;QACClH,WAAW9B,GAAG,+DAA+D8B;QAC7EC,OAAOA;QACPkH,MAAK;kBAEL,cAAA,KAACC;YAAIC,KAAKnH;YAAYF,WAAU;sBAE9B,cAAA,KAACmC;gBACCkF,KAAKlH;gBACLH,WAAU;gBACVsH,eAAY;;;;AAKtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dot-grid/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/dot-grid/index.ts"],"sourcesContent":["export * from './dot-grid';\n"],"names":[],"mappings":"AAAA,cAAc,aAAa"}
|
|
@@ -4,6 +4,7 @@ export * from './badge';
|
|
|
4
4
|
export * from './button';
|
|
5
5
|
export * from './checkbox';
|
|
6
6
|
export * from './code-block';
|
|
7
|
+
export * from './dot-grid';
|
|
7
8
|
export * from './dynamic-item';
|
|
8
9
|
export * from './icon';
|
|
9
10
|
export * from './inline-tips';
|
|
@@ -14,5 +15,6 @@ export * from './modal';
|
|
|
14
15
|
export * from './textarea';
|
|
15
16
|
export * from './theme';
|
|
16
17
|
export * from './toast';
|
|
18
|
+
export * from './tooltip';
|
|
17
19
|
export * from './typography';
|
|
18
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from './badge/index.js';
|
|
|
4
4
|
export * from './button/index.js';
|
|
5
5
|
export * from './checkbox/index.js';
|
|
6
6
|
export * from './code-block/index.js';
|
|
7
|
+
export * from './dot-grid/index.js';
|
|
7
8
|
export * from './dynamic-item/index.js';
|
|
8
9
|
export * from './icon/index.js';
|
|
9
10
|
export * from './inline-tips/index.js';
|
|
@@ -14,6 +15,7 @@ export * from './modal/index.js';
|
|
|
14
15
|
export * from './textarea/index.js';
|
|
15
16
|
export * from './theme/index.js';
|
|
16
17
|
export * from './toast/index.js';
|
|
18
|
+
export * from './tooltip/index.js';
|
|
17
19
|
export * from './typography/index.js';
|
|
18
20
|
|
|
19
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["export * from './alert';\nexport * from './avatar';\nexport * from './badge';\nexport * from './button';\nexport * from './checkbox';\nexport * from './code-block';\nexport * from './dynamic-item';\nexport * from './icon';\nexport * from './inline-tips';\nexport * from './input';\nexport * from './item';\nexport * from './label';\nexport * from './modal';\nexport * from './textarea';\nexport * from './theme';\nexport * from './toast';\nexport * from './typography';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,iBAAiB;AAC/B,cAAc,SAAS;AACvB,cAAc,gBAAgB;AAC9B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,eAAe"}
|
|
1
|
+
{"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["export * from './alert';\nexport * from './avatar';\nexport * from './badge';\nexport * from './button';\nexport * from './checkbox';\nexport * from './code-block';\nexport * from './dot-grid';\nexport * from './dynamic-item';\nexport * from './icon';\nexport * from './inline-tips';\nexport * from './input';\nexport * from './item';\nexport * from './label';\nexport * from './modal';\nexport * from './textarea';\nexport * from './theme';\nexport * from './toast';\nexport * from './tooltip';\nexport * from './typography';\n"],"names":[],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,UAAU;AACxB,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,aAAa;AAC3B,cAAc,iBAAiB;AAC/B,cAAc,SAAS;AACvB,cAAc,gBAAgB;AAC9B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,eAAe"}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { argosScreenshot } from '@argos-ci/storybook/vitest';
|
|
3
3
|
import { Avatar } from '../components/avatar/index.js';
|
|
4
4
|
import { Button } from '../components/button/index.js';
|
|
5
|
+
import { DotGrid } from '../components/dot-grid/index.js';
|
|
5
6
|
import { Header, Text } from '../components/typography/index.js';
|
|
6
7
|
const meta = {
|
|
7
8
|
title: 'Onboarding/Signin',
|
|
@@ -19,14 +20,21 @@ export const Default = {
|
|
|
19
20
|
className: "flex min-h-screen items-center justify-center bg-background-subtle-base",
|
|
20
21
|
children: [
|
|
21
22
|
/*#__PURE__*/ _jsx("div", {
|
|
22
|
-
className: "
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
className: "absolute w-[800px] max-w-[800px] h-[400px] top-0 left-1/2 -translate-x-1/2 translate-y-[-145px]",
|
|
24
|
+
style: {
|
|
25
|
+
maskImage: 'radial-gradient(ellipse 100% 125% at 50% 0%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 1) 30%, rgba(0, 0, 0, 0.5) 60%, rgba(0, 0, 0, 0) 100%)',
|
|
26
|
+
WebkitMaskImage: 'radial-gradient(ellipse 100% 125% at 50% 0%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 1) 30%, rgba(0, 0, 0, 0.5) 60%, rgba(0, 0, 0, 0) 100%)'
|
|
27
|
+
},
|
|
28
|
+
children: /*#__PURE__*/ _jsx(DotGrid, {
|
|
29
|
+
dotSize: 2,
|
|
30
|
+
gap: 20,
|
|
31
|
+
baseColor: "#e63e00",
|
|
32
|
+
activeColor: "#FF0076",
|
|
33
|
+
proximity: 100,
|
|
34
|
+
shockRadius: 8,
|
|
35
|
+
shockStrength: 100,
|
|
36
|
+
resistance: 500,
|
|
37
|
+
returnDuration: 1.5
|
|
30
38
|
})
|
|
31
39
|
}),
|
|
32
40
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/onboarding/sign-in.stories.tsx"],"sourcesContent":["import {argosScreenshot} from '@argos-ci/storybook/vitest';\nimport type {Meta, StoryObj} from '@storybook/react';\nimport {Avatar} from 'components/avatar';\nimport {Button} from 'components/button';\nimport {Header, Text} from 'components/typography';\n\nconst meta = {\n title: 'Onboarding/Signin',\n parameters: {\n layout: 'fullscreen',\n },\n} satisfies Meta;\n\nexport default meta;\ntype Story = StoryObj<typeof meta>;\n\nexport const Default: Story = {\n play: async (ctx) => {\n await argosScreenshot(ctx, 'example-screenshot');\n },\n render: () => {\n return (\n <div className=\"flex min-h-screen items-center justify-center bg-background-subtle-base\">\n {/* Background illustration - simplified decorative element */}\n <div
|
|
1
|
+
{"version":3,"sources":["../../src/onboarding/sign-in.stories.tsx"],"sourcesContent":["import {argosScreenshot} from '@argos-ci/storybook/vitest';\nimport type {Meta, StoryObj} from '@storybook/react';\nimport {Avatar} from 'components/avatar';\nimport {Button} from 'components/button';\nimport {DotGrid} from 'components/dot-grid';\nimport {Header, Text} from 'components/typography';\n\nconst meta = {\n title: 'Onboarding/Signin',\n parameters: {\n layout: 'fullscreen',\n },\n} satisfies Meta;\n\nexport default meta;\ntype Story = StoryObj<typeof meta>;\n\nexport const Default: Story = {\n play: async (ctx) => {\n await argosScreenshot(ctx, 'example-screenshot');\n },\n render: () => {\n return (\n <div className=\"flex min-h-screen items-center justify-center bg-background-subtle-base\">\n {/* Background illustration - simplified decorative element */}\n <div\n className=\"absolute w-[800px] max-w-[800px] h-[400px] top-0 left-1/2 -translate-x-1/2 translate-y-[-145px]\"\n style={{\n maskImage:\n 'radial-gradient(ellipse 100% 125% at 50% 0%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 1) 30%, rgba(0, 0, 0, 0.5) 60%, rgba(0, 0, 0, 0) 100%)',\n WebkitMaskImage:\n 'radial-gradient(ellipse 100% 125% at 50% 0%, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 1) 30%, rgba(0, 0, 0, 0.5) 60%, rgba(0, 0, 0, 0) 100%)',\n }}\n >\n <DotGrid\n dotSize={2}\n gap={20}\n baseColor=\"#e63e00\"\n activeColor=\"#FF0076\"\n proximity={100}\n shockRadius={8}\n shockStrength={100}\n resistance={500}\n returnDuration={1.5}\n />\n </div>\n\n {/* Main content */}\n <div className=\"relative flex w-full max-w-[384px] flex-col items-center gap-32 px-24 pb-80 pt-24\">\n {/* Logo and title section */}\n <div className=\"flex flex-col items-center gap-16\">\n <Avatar content=\"logo\" size=\"xl\" radius=\"rounded\" logoName=\"shipfox\" />\n <div className=\"flex min-w-[128px] flex-col items-center gap-4 text-center\">\n <Header\n variant=\"h1\"\n className=\"text-[28px] font-medium leading-[44px] text-foreground-neutral-base\"\n >\n Connect to Shipfox\n </Header>\n <Text\n size=\"sm\"\n className=\"text-sm font-normal leading-[24px] text-foreground-neutral-subtle\"\n >\n Log in to access Shipfox.\n </Text>\n </div>\n </div>\n\n {/* Action buttons */}\n <div className=\"flex w-full flex-col gap-20\">\n <Button variant=\"primary\" size=\"md\" iconLeft=\"google\" className=\"w-full\">\n Continue with Google\n </Button>\n <Button variant=\"primary\" size=\"md\" iconLeft=\"microsoft\" className=\"w-full\">\n Continue with Microsoft\n </Button>\n <Button variant=\"transparent\" size=\"md\" className=\"w-full\">\n Connect with Enterprise SSO\n </Button>\n </div>\n </div>\n </div>\n );\n },\n};\n"],"names":["argosScreenshot","Avatar","Button","DotGrid","Header","Text","meta","title","parameters","layout","Default","play","ctx","render","div","className","style","maskImage","WebkitMaskImage","dotSize","gap","baseColor","activeColor","proximity","shockRadius","shockStrength","resistance","returnDuration","content","size","radius","logoName","variant","iconLeft"],"mappings":";AAAA,SAAQA,eAAe,QAAO,6BAA6B;AAE3D,SAAQC,MAAM,QAAO,oBAAoB;AACzC,SAAQC,MAAM,QAAO,oBAAoB;AACzC,SAAQC,OAAO,QAAO,sBAAsB;AAC5C,SAAQC,MAAM,EAAEC,IAAI,QAAO,wBAAwB;AAEnD,MAAMC,OAAO;IACXC,OAAO;IACPC,YAAY;QACVC,QAAQ;IACV;AACF;AAEA,eAAeH,KAAK;AAGpB,OAAO,MAAMI,UAAiB;IAC5BC,MAAM,OAAOC;QACX,MAAMZ,gBAAgBY,KAAK;IAC7B;IACAC,QAAQ;QACN,qBACE,MAACC;YAAIC,WAAU;;8BAEb,KAACD;oBACCC,WAAU;oBACVC,OAAO;wBACLC,WACE;wBACFC,iBACE;oBACJ;8BAEA,cAAA,KAACf;wBACCgB,SAAS;wBACTC,KAAK;wBACLC,WAAU;wBACVC,aAAY;wBACZC,WAAW;wBACXC,aAAa;wBACbC,eAAe;wBACfC,YAAY;wBACZC,gBAAgB;;;8BAKpB,MAACb;oBAAIC,WAAU;;sCAEb,MAACD;4BAAIC,WAAU;;8CACb,KAACd;oCAAO2B,SAAQ;oCAAOC,MAAK;oCAAKC,QAAO;oCAAUC,UAAS;;8CAC3D,MAACjB;oCAAIC,WAAU;;sDACb,KAACX;4CACC4B,SAAQ;4CACRjB,WAAU;sDACX;;sDAGD,KAACV;4CACCwB,MAAK;4CACLd,WAAU;sDACX;;;;;;sCAOL,MAACD;4BAAIC,WAAU;;8CACb,KAACb;oCAAO8B,SAAQ;oCAAUH,MAAK;oCAAKI,UAAS;oCAASlB,WAAU;8CAAS;;8CAGzE,KAACb;oCAAO8B,SAAQ;oCAAUH,MAAK;oCAAKI,UAAS;oCAAYlB,WAAU;8CAAS;;8CAG5E,KAACb;oCAAO8B,SAAQ;oCAAcH,MAAK;oCAAKd,WAAU;8CAAS;;;;;;;;IAOrE;AACF,EAAE"}
|