@walrosproject/ui 0.3.4 → 0.4.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 +42 -233
- package/dist/assets/walros-logo-3d.glb +0 -0
- package/dist/index.d.ts +39 -2
- package/dist/index.js +456 -344
- package/dist/index.js.map +1 -1
- package/dist/model.d.ts +4 -0
- package/dist/model.js +6 -0
- package/dist/model.js.map +1 -0
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -1,280 +1,89 @@
|
|
|
1
1
|
# @walrosproject/ui
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Contenido inicial
|
|
6
|
-
|
|
7
|
-
- `WalrosPortalTransition`
|
|
8
|
-
- `WalrosLogo`
|
|
9
|
-
- `WalrosWordmark`
|
|
10
|
-
- URLs exportadas de los assets oficiales
|
|
11
|
-
|
|
12
|
-
## Instalación
|
|
3
|
+
Transición, cambio de tema y cursor oficiales de WalrOS para proyectos React.
|
|
13
4
|
|
|
14
5
|
```bash
|
|
15
6
|
npm install @walrosproject/ui
|
|
16
7
|
```
|
|
17
8
|
|
|
18
|
-
##
|
|
9
|
+
## Cambio de tema completo
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
import { WalrosPortalTransition } from "@walrosproject/ui";
|
|
22
|
-
|
|
23
|
-
export default function App() {
|
|
24
|
-
return (
|
|
25
|
-
<>
|
|
26
|
-
<WalrosPortalTransition storageMode="always" />
|
|
27
|
-
<main>Contenido de la aplicación</main>
|
|
28
|
-
</>
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Modos disponibles:
|
|
34
|
-
|
|
35
|
-
```tsx
|
|
36
|
-
<WalrosPortalTransition storageMode="always" />
|
|
37
|
-
<WalrosPortalTransition storageMode="session" />
|
|
38
|
-
<WalrosPortalTransition storageMode="once" />
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
- `always`: se reproduce en cada carga completa.
|
|
42
|
-
- `session`: una vez por pestaña o sesión.
|
|
43
|
-
- `once`: una sola vez mediante `localStorage`.
|
|
44
|
-
|
|
45
|
-
## Logo
|
|
46
|
-
|
|
47
|
-
```tsx
|
|
48
|
-
import { WalrosLogo } from "@walrosproject/ui";
|
|
49
|
-
|
|
50
|
-
<WalrosLogo
|
|
51
|
-
style={{ width: 120, height: "auto" }}
|
|
52
|
-
/>
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Wordmark
|
|
56
|
-
|
|
57
|
-
```tsx
|
|
58
|
-
import { WalrosWordmark } from "@walrosproject/ui";
|
|
59
|
-
|
|
60
|
-
<WalrosWordmark
|
|
61
|
-
variant="light"
|
|
62
|
-
style={{ width: 320, height: "auto" }}
|
|
63
|
-
/>
|
|
64
|
-
|
|
65
|
-
<WalrosWordmark
|
|
66
|
-
variant="dark"
|
|
67
|
-
style={{ width: 320, height: "auto" }}
|
|
68
|
-
/>
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Desarrollo
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
npm install
|
|
75
|
-
npm run check
|
|
76
|
-
npm run build
|
|
77
|
-
npm run pack:check
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Primera publicación
|
|
81
|
-
|
|
82
|
-
Activa 2FA en npm y ejecuta:
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
npm login
|
|
86
|
-
npm publish --access public
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
El script `prepublishOnly` valida TypeScript y genera `dist` automáticamente.
|
|
90
|
-
|
|
91
|
-
## Publicaciones posteriores
|
|
92
|
-
|
|
93
|
-
Actualiza la versión antes de publicar:
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
npm version patch
|
|
97
|
-
npm publish
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Usa `minor` para nuevas funciones compatibles y `major` para cambios incompatibles.
|
|
101
|
-
|
|
102
|
-
## Marca y licencia
|
|
103
|
-
|
|
104
|
-
El código y los recursos se distribuyen bajo los términos indicados en `LICENSE`.
|
|
105
|
-
WalrOS, su nombre y sus recursos gráficos siguen siendo propiedad de Alexander Calle.
|
|
106
|
-
|
|
107
|
-
## Transición oficial de tema
|
|
108
|
-
|
|
109
|
-
Cada producto diseña su propio botón, pero todos disparan la misma animación:
|
|
11
|
+
`WalrosThemeTransition` muestra exclusivamente el glitch visual de walros.org: bandas, destellos y sacudida de la página, sin silueta ni logo. El glitch dura **1.500 ms**; el tema cambia a los **610 ms** y el audio se detiene al concluir los **1.500 ms**. La entrada de la página es un componente independiente.
|
|
110
12
|
|
|
111
13
|
```tsx
|
|
112
14
|
import {
|
|
113
|
-
|
|
15
|
+
WalrosThemeTransition,
|
|
16
|
+
DirectionalCursor,
|
|
114
17
|
useWalrosTheme,
|
|
115
18
|
} from "@walrosproject/ui";
|
|
116
19
|
|
|
117
|
-
export
|
|
118
|
-
const {
|
|
119
|
-
theme,
|
|
120
|
-
isDark,
|
|
121
|
-
mounted,
|
|
122
|
-
glitching,
|
|
123
|
-
toggleTheme,
|
|
124
|
-
} = useWalrosTheme();
|
|
125
|
-
|
|
126
|
-
if (!mounted) return null;
|
|
20
|
+
export function App() {
|
|
21
|
+
const { theme, glitching, toggleTheme } = useWalrosTheme();
|
|
127
22
|
|
|
128
23
|
return (
|
|
129
24
|
<>
|
|
130
|
-
<button
|
|
131
|
-
|
|
132
|
-
onClick={toggleTheme}
|
|
133
|
-
disabled={glitching}
|
|
134
|
-
style={{
|
|
135
|
-
background: isDark ? "#1d4ed8" : "#06b6d4",
|
|
136
|
-
color: "#fff",
|
|
137
|
-
}}
|
|
138
|
-
>
|
|
139
|
-
Cambiar tema
|
|
25
|
+
<button type="button" onClick={toggleTheme} disabled={glitching}>
|
|
26
|
+
Tema: {theme}
|
|
140
27
|
</button>
|
|
141
|
-
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
<main>Tema actual: {theme}</main>
|
|
28
|
+
<WalrosThemeTransition active={glitching} />
|
|
29
|
+
<DirectionalCursor />
|
|
145
30
|
</>
|
|
146
31
|
);
|
|
147
32
|
}
|
|
148
33
|
```
|
|
149
34
|
|
|
150
|
-
El hook
|
|
151
|
-
guarda el valor en `localStorage` con la clave `walros-theme`. El cambio visual
|
|
152
|
-
se ejecuta con la transición de 1,5 s de WalrOS; el tema cambia a los 610 ms y
|
|
153
|
-
el sonido oficial se reproduce al activar `toggleTheme()` desde una interacción
|
|
154
|
-
del usuario. El volumen predeterminado es 0,52.
|
|
35
|
+
El hook guarda `walros-theme` en `localStorage` y aplica la clase `dark` al elemento raíz. Usa `applyTheme` si tu proyecto utiliza otra convención. El sonido oficial está incluido, a volumen `0.52`. Puedes desactivarlo o sustituirlo con `soundUrl: false` o una URL propia. La reproducción debe iniciarse con `toggleTheme()` desde una interacción del usuario para respetar las restricciones de audio de los navegadores.
|
|
155
36
|
|
|
156
|
-
|
|
37
|
+
Para escenas parallax o GSAP, utiliza `mode: "viewport"` y pasa un wrapper estable en `shakeTargets`. `onAfterUnlock` permite actualizar ScrollTrigger después de restaurar el scroll. En páginas convencionales, el modo predeterminado `body` reproduce el movimiento de WalrOS.
|
|
157
38
|
|
|
158
39
|
```tsx
|
|
159
|
-
useWalrosTheme({
|
|
160
|
-
|
|
40
|
+
const theme = useWalrosTheme({
|
|
41
|
+
mode: "viewport",
|
|
42
|
+
shakeTargets: [sceneRef],
|
|
43
|
+
onAfterUnlock: () => ScrollTrigger.update(),
|
|
44
|
+
});
|
|
161
45
|
```
|
|
162
46
|
|
|
47
|
+
`WalrosThemeGlitch` sigue disponible como componente individual para proyectos que solo necesiten ese efecto.
|
|
163
48
|
|
|
164
|
-
##
|
|
165
|
-
|
|
166
|
-
### `body`: comportamiento original de WalrOS Forum
|
|
49
|
+
## Portal de entrada
|
|
167
50
|
|
|
168
|
-
|
|
51
|
+
`WalrosPortalTransition` muestra la morsa cromada **debajo** de la máscara negra y la acerca al centro mientras se abre el portal. Dura **900 ms** y no espera a que se descargue la imagen para iniciar; el logo desaparece antes de que se revele la página.
|
|
169
52
|
|
|
170
53
|
```tsx
|
|
171
|
-
|
|
172
|
-
theme,
|
|
173
|
-
glitching,
|
|
174
|
-
toggleTheme,
|
|
175
|
-
} = useWalrosTheme({
|
|
176
|
-
mode: "body",
|
|
177
|
-
});
|
|
54
|
+
<WalrosPortalTransition storageMode="always" />
|
|
178
55
|
```
|
|
179
56
|
|
|
180
|
-
|
|
181
|
-
producto sigue diseñando su propio botón.
|
|
182
|
-
|
|
183
|
-
### `viewport`: páginas con parallax, sticky o GSAP ScrollTrigger
|
|
184
|
-
|
|
185
|
-
Usa una capa estable que cubra la escena visible. No apuntes a un elemento que
|
|
186
|
-
GSAP esté transformando directamente; utiliza preferiblemente un wrapper.
|
|
57
|
+
`storageMode` acepta `always`, `session` y `once`. Para usar el modelo 3D real de walros.org como fondo, renderízalo en tu escena y pasa sus límites proyectados a `Walros3DPortalTransition`:
|
|
187
58
|
|
|
188
59
|
```tsx
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
} from "@walrosproject/ui";
|
|
194
|
-
|
|
195
|
-
export function Hero() {
|
|
196
|
-
const sceneRef = useRef<HTMLDivElement>(null);
|
|
197
|
-
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
198
|
-
|
|
199
|
-
const {
|
|
200
|
-
theme,
|
|
201
|
-
glitching,
|
|
202
|
-
toggleTheme,
|
|
203
|
-
} = useWalrosTheme({
|
|
204
|
-
mode: "viewport",
|
|
205
|
-
shakeTargets: [sceneRef, buttonRef],
|
|
206
|
-
onAfterUnlock: () => {
|
|
207
|
-
// Opcional: ScrollTrigger.update();
|
|
208
|
-
},
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
return (
|
|
212
|
-
<section className="relative overflow-hidden">
|
|
213
|
-
<div ref={sceneRef} className="absolute inset-0">
|
|
214
|
-
{/* escena visible */}
|
|
215
|
-
</div>
|
|
216
|
-
|
|
217
|
-
<button
|
|
218
|
-
ref={buttonRef}
|
|
219
|
-
type="button"
|
|
220
|
-
onClick={toggleTheme}
|
|
221
|
-
disabled={glitching}
|
|
222
|
-
>
|
|
223
|
-
Tema: {theme}
|
|
224
|
-
</button>
|
|
225
|
-
|
|
226
|
-
<WalrosThemeGlitch active={glitching} />
|
|
227
|
-
</section>
|
|
228
|
-
);
|
|
229
|
-
}
|
|
60
|
+
<Walros3DPortalTransition
|
|
61
|
+
origin={{ centerX, centerY, width, height }}
|
|
62
|
+
onComplete={() => setIntroComplete(true)}
|
|
63
|
+
/>
|
|
230
64
|
```
|
|
231
65
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
- guarda la posición actual del scroll;
|
|
235
|
-
- la mantiene estable con `requestAnimationFrame` y `window.scrollTo`;
|
|
236
|
-
- no usa `position: fixed` ni transforma el `body`;
|
|
237
|
-
- aplica el shake solamente a `shakeTargets`;
|
|
238
|
-
- restaura `overflow` y la posición al terminar;
|
|
239
|
-
- ejecuta `onAfterUnlock` para actualizar GSAP u otra librería.
|
|
240
|
-
|
|
241
|
-
La transición dura 1.500 ms por defecto y cambia el tema en el punto de 610 ms,
|
|
242
|
-
sin alterar las opciones de bloqueo de scroll ni las de `ScrollTrigger`.
|
|
243
|
-
|
|
244
|
-
## Compatibilidad de `WalrosPortalTransition`
|
|
245
|
-
|
|
246
|
-
Desde la versión `0.3.1`, la silueta del portal se dibuja directamente dentro
|
|
247
|
-
del SVG del componente. La transición ya no depende de que Vite, Bun u otro
|
|
248
|
-
empaquetador resuelva un archivo SVG externo desde `node_modules`, evitando
|
|
249
|
-
portales deformados o sin la morsa al consumir el paquete desde otras apps.
|
|
250
|
-
|
|
251
|
-
## Portal con una sola silueta
|
|
252
|
-
|
|
253
|
-
Desde `0.3.2`, `WalrosPortalTransition` usa el SVG oficial exacto de WalrOS
|
|
254
|
-
como una URL de datos dentro de un único elemento SVG `<image>` dentro de la
|
|
255
|
-
máscara. Se ha eliminado la segunda copia azul desenfocada que podía hacer que
|
|
256
|
-
la morsa pareciera doble durante el acercamiento.
|
|
66
|
+
`walrosLogo3DUrl` se importa desde `@walrosproject/ui/model` y exporta el GLB oficial solo cuando un proyecto necesita cargarlo; `walrosPortalSilhouetteUrl` exporta la silueta. El componente ya incluye las tres rutas de la máscara, sin descargar ni analizar un SVG en tiempo de ejecución.
|
|
257
67
|
|
|
258
|
-
|
|
259
|
-
oficial por defecto es `900` ms.
|
|
68
|
+
## Cursor
|
|
260
69
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
## Valores predeterminados del portal desde 0.3.3
|
|
264
|
-
|
|
265
|
-
`WalrosPortalTransition` usa ahora estos valores cuando no se indican props:
|
|
70
|
+
`DirectionalCursor` copia el cursor ajustado de walros.org: 20 × 22 px, seguimiento suave, orientación según la dirección del ratón y estabilización al detenerse. Solo sustituye el cursor nativo con puntero preciso, hover, pantalla de al menos 1024 px y movimiento permitido. En controles y campos de texto conserva el cursor adecuado.
|
|
266
71
|
|
|
267
72
|
```tsx
|
|
268
|
-
<
|
|
73
|
+
<DirectionalCursor />
|
|
269
74
|
```
|
|
270
75
|
|
|
271
|
-
|
|
76
|
+
## Otros recursos
|
|
272
77
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
78
|
+
El paquete conserva `WalrosLogo`, `WalrosWordmark` y sus URLs de imagen. Todos los componentes funcionan con React 18 y 19. El portal y el glitch respetan `prefers-reduced-motion`.
|
|
79
|
+
|
|
80
|
+
## Desarrollo y publicación
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm install
|
|
84
|
+
npm run check
|
|
85
|
+
npm run build
|
|
86
|
+
npm run pack:check
|
|
278
87
|
```
|
|
279
88
|
|
|
280
|
-
|
|
89
|
+
El código y los recursos se distribuyen bajo los términos de `LICENSE`. WalrOS y sus elementos visuales pertenecen a Alexander Calle.
|
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ImgHTMLAttributes, CSSProperties, RefObject } from 'react';
|
|
3
3
|
|
|
4
|
+
type PortalOrigin = {
|
|
5
|
+
centerX: number;
|
|
6
|
+
centerY: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
type Walros3DPortalTransitionProps = {
|
|
11
|
+
origin: PortalOrigin;
|
|
12
|
+
onComplete?: () => void;
|
|
13
|
+
duration?: number;
|
|
14
|
+
backgroundColor?: string;
|
|
15
|
+
zIndex?: number;
|
|
16
|
+
lockScroll?: boolean;
|
|
17
|
+
/** An optional image that follows the portal exactly and fades before reveal. */
|
|
18
|
+
logoUrl?: string | false;
|
|
19
|
+
};
|
|
20
|
+
declare function Walros3DPortalTransition({ origin, onComplete, duration, backgroundColor, zIndex, lockScroll, logoUrl, }: Walros3DPortalTransitionProps): react.JSX.Element | null;
|
|
21
|
+
|
|
4
22
|
type WalrosPortalTransitionProps = {
|
|
5
23
|
duration?: number;
|
|
6
24
|
onComplete?: () => void;
|
|
@@ -9,8 +27,27 @@ type WalrosPortalTransitionProps = {
|
|
|
9
27
|
storageMode?: "always" | "session" | "once";
|
|
10
28
|
storageKey?: string;
|
|
11
29
|
zIndex?: number;
|
|
30
|
+
/** Projected bounds of an existing 3D logo, as on walros.org. */
|
|
31
|
+
origin?: PortalOrigin;
|
|
32
|
+
/** Intro logo shown beneath the black mask; set false when using an existing 3D logo. */
|
|
33
|
+
logoUrl?: string | false;
|
|
34
|
+
};
|
|
35
|
+
/** 900 ms walros.org entrance, with the logo confined below its black mask. */
|
|
36
|
+
declare function WalrosPortalTransition({ duration, onComplete, backgroundColor, enabled, storageMode, storageKey, zIndex, origin, logoUrl, }: WalrosPortalTransitionProps): react.ReactPortal | null;
|
|
37
|
+
|
|
38
|
+
type WalrosThemeTransitionProps = {
|
|
39
|
+
/** Pass the `glitching` value returned by `useWalrosTheme`. */
|
|
40
|
+
active: boolean;
|
|
41
|
+
/** @deprecated The theme change has no portal; retained for source compatibility. */
|
|
42
|
+
portalDuration?: number;
|
|
43
|
+
/** @deprecated The theme change has no logo; retained for source compatibility. */
|
|
44
|
+
logoUrl?: string;
|
|
45
|
+
zIndex?: number;
|
|
12
46
|
};
|
|
13
|
-
|
|
47
|
+
/** The walros.org theme effect is a shake and glitch, without an intro logo. */
|
|
48
|
+
declare function WalrosThemeTransition({ active, zIndex, }: WalrosThemeTransitionProps): react.ReactPortal | null;
|
|
49
|
+
|
|
50
|
+
declare function DirectionalCursor(): react.JSX.Element;
|
|
14
51
|
|
|
15
52
|
type WalrosLogoProps = Omit<ImgHTMLAttributes<HTMLImageElement>, "src">;
|
|
16
53
|
declare function WalrosLogo({ alt, draggable, ...props }: WalrosLogoProps): react.JSX.Element;
|
|
@@ -74,4 +111,4 @@ declare const walrosWordmarkLightUrl: string;
|
|
|
74
111
|
declare const walrosWordmarkDarkUrl: string;
|
|
75
112
|
declare const walrosThemeGlitchSoundUrl: string;
|
|
76
113
|
|
|
77
|
-
export { type UseWalrosThemeOptions, type UseWalrosThemeResult, WalrosLogo, type WalrosLogoProps, WalrosPortalTransition, type WalrosPortalTransitionProps, type WalrosTheme, WalrosThemeGlitch, type WalrosThemeGlitchProps, type WalrosThemeMode, type WalrosThemeShakeTarget, WalrosWordmark, type WalrosWordmarkProps, useWalrosTheme, walrosLogoChromeUrl, walrosPortalSilhouetteUrl, walrosThemeGlitchSoundUrl, walrosWordmarkDarkUrl, walrosWordmarkLightUrl };
|
|
114
|
+
export { DirectionalCursor, type PortalOrigin, type UseWalrosThemeOptions, type UseWalrosThemeResult, Walros3DPortalTransition, type Walros3DPortalTransitionProps, WalrosLogo, type WalrosLogoProps, WalrosPortalTransition, type WalrosPortalTransitionProps, type WalrosTheme, WalrosThemeGlitch, type WalrosThemeGlitchProps, type WalrosThemeMode, type WalrosThemeShakeTarget, WalrosThemeTransition, type WalrosThemeTransitionProps, WalrosWordmark, type WalrosWordmarkProps, useWalrosTheme, walrosLogoChromeUrl, walrosPortalSilhouetteUrl, walrosThemeGlitchSoundUrl, walrosWordmarkDarkUrl, walrosWordmarkLightUrl };
|