@walrosproject/ui 0.3.3 → 0.4.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 +43 -225
- package/dist/assets/walros-logo-3d.glb +0 -0
- package/dist/assets/walros-theme-glitch.mp3 +0 -0
- package/dist/index.d.ts +48 -8
- package/dist/index.js +632 -385
- 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 +10 -27
package/README.md
CHANGED
|
@@ -1,271 +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
|
-
##
|
|
19
|
-
|
|
20
|
-
```tsx
|
|
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
|
-
```
|
|
9
|
+
## Cambio de tema completo
|
|
54
10
|
|
|
55
|
-
|
|
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` une la entrada negra con la silueta de la morsa, el glitch visual y el sonido de walros.org. El portal acelera durante **900 ms** con la curva `power2.in`; 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 imagen del logo se precarga y la pantalla permanece negra mientras termina de cargar, como en la portada.
|
|
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` y conserva los
|
|
152
|
-
tiempos oficiales de WalrOS Forum: cambio a los 220 ms y final a los 720 ms.
|
|
153
|
-
|
|
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.
|
|
154
36
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
### `body`: comportamiento original de WalrOS Forum
|
|
158
|
-
|
|
159
|
-
Para páginas normales, sin escenas fijadas ni parallax complejo:
|
|
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.
|
|
160
38
|
|
|
161
39
|
```tsx
|
|
162
|
-
const {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
} = useWalrosTheme({
|
|
167
|
-
mode: "body",
|
|
40
|
+
const theme = useWalrosTheme({
|
|
41
|
+
mode: "viewport",
|
|
42
|
+
shakeTargets: [sceneRef],
|
|
43
|
+
onAfterUnlock: () => ScrollTrigger.update(),
|
|
168
44
|
});
|
|
169
45
|
```
|
|
170
46
|
|
|
171
|
-
|
|
172
|
-
producto sigue diseñando su propio botón.
|
|
47
|
+
`WalrosThemeGlitch` sigue disponible como componente individual para proyectos que solo necesiten ese efecto.
|
|
173
48
|
|
|
174
|
-
|
|
49
|
+
## Portal de entrada
|
|
175
50
|
|
|
176
|
-
|
|
177
|
-
GSAP esté transformando directamente; utiliza preferiblemente un wrapper.
|
|
51
|
+
El componente completo muestra el logo cromado bajo la máscara negra y calcula el punto de partida con sus proporciones visibles:
|
|
178
52
|
|
|
179
53
|
```tsx
|
|
180
|
-
|
|
181
|
-
import {
|
|
182
|
-
WalrosThemeGlitch,
|
|
183
|
-
useWalrosTheme,
|
|
184
|
-
} from "@walrosproject/ui";
|
|
185
|
-
|
|
186
|
-
export function Hero() {
|
|
187
|
-
const sceneRef = useRef<HTMLDivElement>(null);
|
|
188
|
-
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
189
|
-
|
|
190
|
-
const {
|
|
191
|
-
theme,
|
|
192
|
-
glitching,
|
|
193
|
-
toggleTheme,
|
|
194
|
-
} = useWalrosTheme({
|
|
195
|
-
mode: "viewport",
|
|
196
|
-
shakeTargets: [sceneRef, buttonRef],
|
|
197
|
-
onAfterUnlock: () => {
|
|
198
|
-
// Opcional: ScrollTrigger.update();
|
|
199
|
-
},
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
return (
|
|
203
|
-
<section className="relative overflow-hidden">
|
|
204
|
-
<div ref={sceneRef} className="absolute inset-0">
|
|
205
|
-
{/* escena visible */}
|
|
206
|
-
</div>
|
|
207
|
-
|
|
208
|
-
<button
|
|
209
|
-
ref={buttonRef}
|
|
210
|
-
type="button"
|
|
211
|
-
onClick={toggleTheme}
|
|
212
|
-
disabled={glitching}
|
|
213
|
-
>
|
|
214
|
-
Tema: {theme}
|
|
215
|
-
</button>
|
|
216
|
-
|
|
217
|
-
<WalrosThemeGlitch active={glitching} />
|
|
218
|
-
</section>
|
|
219
|
-
);
|
|
220
|
-
}
|
|
54
|
+
<WalrosPortalTransition storageMode="always" />
|
|
221
55
|
```
|
|
222
56
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
- guarda la posición actual del scroll;
|
|
226
|
-
- la mantiene estable con `requestAnimationFrame` y `window.scrollTo`;
|
|
227
|
-
- no usa `position: fixed` ni transforma el `body`;
|
|
228
|
-
- aplica el shake solamente a `shakeTargets`;
|
|
229
|
-
- restaura `overflow` y la posición al terminar;
|
|
230
|
-
- ejecuta `onAfterUnlock` para actualizar GSAP u otra librería.
|
|
231
|
-
|
|
232
|
-
Los tiempos predeterminados siguen siendo 220 ms para cambiar el tema y
|
|
233
|
-
720 ms para terminar la transición.
|
|
234
|
-
|
|
235
|
-
## Compatibilidad de `WalrosPortalTransition`
|
|
236
|
-
|
|
237
|
-
Desde la versión `0.3.1`, la silueta del portal se dibuja directamente dentro
|
|
238
|
-
del SVG del componente. La transición ya no depende de que Vite, Bun u otro
|
|
239
|
-
empaquetador resuelva un archivo SVG externo desde `node_modules`, evitando
|
|
240
|
-
portales deformados o sin la morsa al consumir el paquete desde otras apps.
|
|
241
|
-
|
|
242
|
-
## Portal con una sola silueta
|
|
243
|
-
|
|
244
|
-
Desde `0.3.2`, `WalrosPortalTransition` usa el SVG oficial exacto de WalrOS
|
|
245
|
-
como una URL de datos dentro de un único elemento SVG `<image>` dentro de la
|
|
246
|
-
máscara. Se ha eliminado la segunda copia azul desenfocada que podía hacer que
|
|
247
|
-
la morsa pareciera doble durante el acercamiento.
|
|
248
|
-
|
|
249
|
-
El resultado es una única silueta que crece y revela la aplicación. La duración
|
|
250
|
-
oficial por defecto es `900` ms.
|
|
57
|
+
`storageMode` acepta `always`, `session` y `once`. La duración predeterminada es **900 ms**. Para usar el modelo 3D real de walros.org como fondo, renderízalo en tu escena y pasa sus límites proyectados a `Walros3DPortalTransition`:
|
|
251
58
|
|
|
59
|
+
```tsx
|
|
60
|
+
<Walros3DPortalTransition
|
|
61
|
+
origin={{ centerX, centerY, width, height }}
|
|
62
|
+
onComplete={() => setIntroComplete(true)}
|
|
63
|
+
/>
|
|
64
|
+
```
|
|
252
65
|
|
|
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.
|
|
253
67
|
|
|
254
|
-
##
|
|
68
|
+
## Cursor
|
|
255
69
|
|
|
256
|
-
`
|
|
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.
|
|
257
71
|
|
|
258
72
|
```tsx
|
|
259
|
-
<
|
|
73
|
+
<DirectionalCursor />
|
|
260
74
|
```
|
|
261
75
|
|
|
262
|
-
|
|
76
|
+
## Otros recursos
|
|
263
77
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
|
269
87
|
```
|
|
270
88
|
|
|
271
|
-
|
|
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
|
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,42 @@ type WalrosPortalTransitionProps = {
|
|
|
10
10
|
storageKey?: string;
|
|
11
11
|
zIndex?: number;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
/** Exact walros.org black portal, including its chrome logo and 900 ms curve. */
|
|
14
|
+
declare function WalrosPortalTransition({ duration, onComplete, backgroundColor, enabled, storageMode, storageKey, zIndex, }: WalrosPortalTransitionProps): react.ReactPortal | null;
|
|
15
|
+
|
|
16
|
+
type PortalOrigin = {
|
|
17
|
+
centerX: number;
|
|
18
|
+
centerY: number;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
22
|
+
type Walros3DPortalTransitionProps = {
|
|
23
|
+
origin: PortalOrigin;
|
|
24
|
+
onComplete?: () => void;
|
|
25
|
+
duration?: number;
|
|
26
|
+
backgroundColor?: string;
|
|
27
|
+
zIndex?: number;
|
|
28
|
+
lockScroll?: boolean;
|
|
29
|
+
};
|
|
30
|
+
declare function Walros3DPortalTransition({ origin, onComplete, duration, backgroundColor, zIndex, lockScroll, }: Walros3DPortalTransitionProps): react.JSX.Element | null;
|
|
31
|
+
|
|
32
|
+
type WalrosThemeTransitionProps = {
|
|
33
|
+
/** Pass the `glitching` value returned by `useWalrosTheme`. */
|
|
34
|
+
active: boolean;
|
|
35
|
+
/** The walros.org portal takes 900 ms. */
|
|
36
|
+
portalDuration?: number;
|
|
37
|
+
/** The same chrome logo used under the portal on walros.org. */
|
|
38
|
+
logoUrl?: string;
|
|
39
|
+
zIndex?: number;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A ready-to-use walros.org theme transition. The portal runs for 900 ms,
|
|
43
|
+
* while the matching glitch and sound from useWalrosTheme run for 1,500 ms.
|
|
44
|
+
* Mount once near the app root and pass `active={glitching}`.
|
|
45
|
+
*/
|
|
46
|
+
declare function WalrosThemeTransition({ active, portalDuration, logoUrl, zIndex, }: WalrosThemeTransitionProps): react.ReactPortal | null;
|
|
47
|
+
|
|
48
|
+
declare function DirectionalCursor(): react.JSX.Element;
|
|
14
49
|
|
|
15
50
|
type WalrosLogoProps = Omit<ImgHTMLAttributes<HTMLImageElement>, "src">;
|
|
16
51
|
declare function WalrosLogo({ alt, draggable, ...props }: WalrosLogoProps): react.JSX.Element;
|
|
@@ -20,11 +55,6 @@ type WalrosWordmarkProps = Omit<ImgHTMLAttributes<HTMLImageElement>, "src"> & {
|
|
|
20
55
|
};
|
|
21
56
|
declare function WalrosWordmark({ variant, alt, draggable, ...props }: WalrosWordmarkProps): react.JSX.Element;
|
|
22
57
|
|
|
23
|
-
declare const walrosPortalSilhouetteUrl: string;
|
|
24
|
-
declare const walrosLogoChromeUrl: string;
|
|
25
|
-
declare const walrosWordmarkLightUrl: string;
|
|
26
|
-
declare const walrosWordmarkDarkUrl: string;
|
|
27
|
-
|
|
28
58
|
type WalrosThemeGlitchProps = {
|
|
29
59
|
active: boolean;
|
|
30
60
|
zIndex?: number;
|
|
@@ -42,6 +72,10 @@ type UseWalrosThemeOptions = {
|
|
|
42
72
|
useSystemPreference?: boolean;
|
|
43
73
|
swapDelay?: number;
|
|
44
74
|
totalDuration?: number;
|
|
75
|
+
/** Set to false to disable audio, or provide a custom sound URL. */
|
|
76
|
+
soundUrl?: string | false;
|
|
77
|
+
/** Playback volume from 0 to 1. Defaults to the WalrOS site mix. */
|
|
78
|
+
soundVolume?: number;
|
|
45
79
|
applyTheme?: (theme: WalrosTheme) => void;
|
|
46
80
|
/**
|
|
47
81
|
* `body` reproduce el comportamiento original de WalrOS Forum.
|
|
@@ -67,6 +101,12 @@ type UseWalrosThemeResult = {
|
|
|
67
101
|
toggleTheme: () => void;
|
|
68
102
|
setTheme: (theme: WalrosTheme) => void;
|
|
69
103
|
};
|
|
70
|
-
declare function useWalrosTheme({ storageKey, defaultTheme, useSystemPreference, swapDelay, totalDuration, applyTheme, mode, shakeTargets, lockScroll, onAfterUnlock, }?: UseWalrosThemeOptions): UseWalrosThemeResult;
|
|
104
|
+
declare function useWalrosTheme({ storageKey, defaultTheme, useSystemPreference, swapDelay, totalDuration, soundUrl, soundVolume, applyTheme, mode, shakeTargets, lockScroll, onAfterUnlock, }?: UseWalrosThemeOptions): UseWalrosThemeResult;
|
|
105
|
+
|
|
106
|
+
declare const walrosPortalSilhouetteUrl: string;
|
|
107
|
+
declare const walrosLogoChromeUrl: string;
|
|
108
|
+
declare const walrosWordmarkLightUrl: string;
|
|
109
|
+
declare const walrosWordmarkDarkUrl: string;
|
|
110
|
+
declare const walrosThemeGlitchSoundUrl: string;
|
|
71
111
|
|
|
72
|
-
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, walrosWordmarkDarkUrl, walrosWordmarkLightUrl };
|
|
112
|
+
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 };
|