@evinvest/uikit 0.2.0 → 0.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evinvest/uikit",
3
- "version": "0.2.0",
3
+ "version": "0.3.2",
4
4
  "description": "Dep-light React UI kit: shadcn-semantics components with zero @radix-ui / cva, mirroring the ev::uikit Rust feature. Ships the shared design tokens.",
5
5
  "license": "BlueOak-1.0.0",
6
6
  "publishConfig": {
package/styles/tokens.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Shared design tokens — the theme contract for the `ev::uikit` (Rust) and
2
+ * Shared design tokens — the theme contract for the `ev_lib::uikit` (Rust) and
3
3
  * `@evinvest/uikit` (TypeScript) components. Import this file from any Tailwind v4
4
4
  * entrypoint. Kept byte-for-byte in parity with `@evinvest/uikit`'s
5
5
  * `styles/tokens.css`; change one, change the other.
@@ -8,6 +8,8 @@
8
8
  * @theme inline {} — wires values into Tailwind utilities (processed by
9
9
  * Tailwind v4; ignored as unknown at-rule by browsers)
10
10
  * :root {} — raw CSS custom properties; work everywhere
11
+ * @keyframes / rules — toast (sonner) enter/exit motion at the tail; shipped
12
+ * here so the lifecycle is self-contained (see below)
11
13
  */
12
14
 
13
15
  @theme inline {
@@ -16,9 +18,14 @@
16
18
  --radius-lg: var(--radius);
17
19
  --radius-xl: calc(var(--radius) + 4px);
18
20
 
19
- --font-sans: var(--font-inter), "Inter", ui-sans-serif, system-ui, sans-serif;
20
- --font-serif: var(--font-playfair), "Playfair Display", ui-serif, Georgia, serif;
21
- --font-mono: var(--font-inter), "Inter", ui-monospace, monospace;
21
+ /* The leading var() carries its own fallback: next/font (landing) sets
22
+ * `--font-inter` / `--font-playfair`; a Rust consumer renders `uikit::Fonts`,
23
+ * which `@font-face`s the same families. Without the in-var fallback an
24
+ * undefined leading var would invalidate the whole `font-family` and drop the
25
+ * browser to its default — so it must never resolve to guaranteed-invalid. */
26
+ --font-sans: var(--font-inter, "Inter"), ui-sans-serif, system-ui, sans-serif;
27
+ --font-serif: var(--font-playfair, "Playfair Display"), ui-serif, Georgia, serif;
28
+ --font-mono: var(--font-inter, "Inter"), ui-monospace, monospace;
22
29
 
23
30
  /* shadcn semantic utilities */
24
31
  --color-background: var(--background);
@@ -123,3 +130,171 @@
123
130
  --page-px: 3rem;
124
131
  }
125
132
  }
133
+
134
+ /* ── Toast stacking (Sonner-style), shared by both ports via data-stack ──────
135
+ Both `ev::uikit` (Dioxus) and `@evinvest/uikit` (React) set data-stack on the
136
+ toaster and drive the same machine: toasts are absolutely stacked at the
137
+ pinned edge, pile up collapsed (front three peeking, each lifted + scaled by
138
+ --index and clamped to --front-height), and spread to --offset on hover /
139
+ keyboard focus (pure CSS — no JS state). Vars: the toaster sets --front-height
140
+ + --gap; each toast sets --index, --z-index, --offset, --initial-height. React
141
+ measures real heights; Dioxus can't (host-only), so it feeds a constant height
142
+ — collapse is exact, expansion is uniform. The enter is a keyframe (plays on
143
+ DOM insertion, so it works in both ports without a JS mount flip),
144
+ `data-state=closed` slides out, and the node is dropped on the transitionend. */
145
+
146
+ [data-slot="toaster"][data-stack] [data-slot="toast"] {
147
+ position: absolute;
148
+ --y: translateY(0);
149
+ opacity: 1;
150
+ z-index: var(--z-index, 1);
151
+ transform: var(--y) translateX(var(--swipe-x, 0px));
152
+ /* a plain easeOut (no overshoot) so a restack settles instead of bouncing
153
+ back past its slot */
154
+ transition:
155
+ transform 350ms cubic-bezier(0.21, 0.8, 0.4, 1),
156
+ opacity 350ms,
157
+ height 350ms;
158
+ /* the enter is a keyframe (plays on DOM insertion in both ports — no JS mount
159
+ flip, whose pre-paint timing the Dioxus effect couldn't drive). It animates
160
+ the independent `translate` property, NOT `transform`, so it *composes* with
161
+ the stack transform instead of overriding it: a toast pushed back mid-enter
162
+ keeps repositioning smoothly instead of fighting the keyframe (rapid-fire
163
+ lag). */
164
+ animation: ev-toast-enter 350ms cubic-bezier(0.21, 0.8, 0.4, 1) backwards;
165
+ }
166
+ @keyframes ev-toast-enter {
167
+ from {
168
+ opacity: 0;
169
+ translate: 0 var(--enter-y, 100%);
170
+ }
171
+ to {
172
+ opacity: 1;
173
+ translate: 0 0;
174
+ }
175
+ }
176
+
177
+ /* pin to the toaster's edge; set the lift sign + the off-screen enter offset */
178
+ [data-slot="toaster"][data-stack][data-y-position="bottom"] [data-slot="toast"] {
179
+ bottom: 0;
180
+ --lift: -1;
181
+ --enter-y: 100%;
182
+ }
183
+ [data-slot="toaster"][data-stack][data-y-position="top"] [data-slot="toast"] {
184
+ top: 0;
185
+ --lift: 1;
186
+ --enter-y: -100%;
187
+ }
188
+
189
+ /* closing: slide back off + fade out; the node is dropped on its transitionend */
190
+ [data-slot="toaster"][data-stack] [data-slot="toast"][data-state="closed"] {
191
+ --y: translateY(var(--enter-y));
192
+ opacity: 0;
193
+ }
194
+
195
+ /* collapsed: back toasts lift + shrink by depth, clamp to the front height */
196
+ [data-slot="toaster"][data-stack]
197
+ [data-slot="toast"][data-state="open"][data-front="false"] {
198
+ --y: translateY(calc(var(--lift) * var(--gap) * var(--index)))
199
+ scale(calc(1 - var(--index) * 0.05));
200
+ height: var(--front-height);
201
+ }
202
+ [data-slot="toaster"][data-stack] [data-slot="toast"][data-front="false"] > * {
203
+ opacity: 0;
204
+ transition: opacity 300ms;
205
+ }
206
+ /* only the front three show while collapsed */
207
+ [data-slot="toaster"][data-stack] [data-slot="toast"][data-visible="false"] {
208
+ opacity: 0;
209
+ pointer-events: none;
210
+ }
211
+
212
+ /* expanded (hover / keyboard focus): spread to the offset, real height, content
213
+ + overflow back */
214
+ [data-slot="toaster"][data-stack]:hover [data-slot="toast"][data-state="open"],
215
+ [data-slot="toaster"][data-stack]:focus-within
216
+ [data-slot="toast"][data-state="open"] {
217
+ --y: translateY(calc(var(--lift) * var(--offset)));
218
+ height: var(--initial-height);
219
+ }
220
+ [data-slot="toaster"][data-stack]:hover [data-slot="toast"] > *,
221
+ [data-slot="toaster"][data-stack]:focus-within [data-slot="toast"] > *,
222
+ [data-slot="toaster"][data-stack]:hover [data-slot="toast"][data-visible="false"],
223
+ [data-slot="toaster"][data-stack]:focus-within
224
+ [data-slot="toast"][data-visible="false"] {
225
+ opacity: 1;
226
+ pointer-events: auto;
227
+ }
228
+
229
+ /* a transparent strip over the gap so the hover area stays contiguous between
230
+ spread toasts (otherwise the pointer falls through the gap and it collapses) */
231
+ [data-slot="toaster"][data-stack] [data-slot="toast"]::after {
232
+ content: "";
233
+ position: absolute;
234
+ left: 0;
235
+ width: 100%;
236
+ height: calc(var(--gap) + 1px);
237
+ }
238
+ [data-slot="toaster"][data-stack][data-y-position="bottom"]
239
+ [data-slot="toast"]::after {
240
+ bottom: 100%;
241
+ }
242
+ [data-slot="toaster"][data-stack][data-y-position="top"]
243
+ [data-slot="toast"]::after {
244
+ top: 100%;
245
+ }
246
+
247
+ /* 1:1 finger tracking during a swipe — kill the transition */
248
+ [data-slot="toaster"][data-stack] [data-slot="toast"][data-swiping="true"] {
249
+ transition: none;
250
+ }
251
+
252
+ /* auto-dismiss without a host timer: a no-op "life" animation runs for --life,
253
+ then its `animationend` fires (the toast closes itself). Hovering/focusing the
254
+ stack pauses just that animation (animation-play-state's 2nd slot), so the
255
+ countdown holds — and resumes with the elapsed time preserved — while the
256
+ enter (1st slot) keeps running. Persistent toasts set data-autodismiss=false,
257
+ so they get no life animation. (The React port uses setTimeout instead.) */
258
+ @keyframes ev-toast-life {
259
+ from {
260
+ --ev-life: 0;
261
+ }
262
+ to {
263
+ --ev-life: 1;
264
+ }
265
+ }
266
+ [data-slot="toaster"][data-stack]
267
+ [data-slot="toast"][data-autodismiss="true"][data-state="open"] {
268
+ animation:
269
+ ev-toast-enter 350ms cubic-bezier(0.21, 0.8, 0.4, 1) backwards,
270
+ ev-toast-life var(--life) linear;
271
+ }
272
+ [data-slot="toaster"][data-stack]:hover
273
+ [data-slot="toast"][data-autodismiss="true"],
274
+ [data-slot="toaster"][data-stack]:focus-within
275
+ [data-slot="toast"][data-autodismiss="true"] {
276
+ animation-play-state: running, paused;
277
+ }
278
+
279
+ /* reduced motion: opacity-only enter + near-instant transform (still fires
280
+ transitionend, so exit removal works), no height animation */
281
+ @keyframes ev-toast-fade-in {
282
+ from {
283
+ opacity: 0;
284
+ }
285
+ }
286
+ @media (prefers-reduced-motion: reduce) {
287
+ [data-slot="toaster"][data-stack] [data-slot="toast"] {
288
+ transition:
289
+ transform 1ms linear,
290
+ opacity 200ms;
291
+ animation: ev-toast-fade-in 200ms;
292
+ }
293
+ /* keep the auto-dismiss life animation under reduced motion */
294
+ [data-slot="toaster"][data-stack]
295
+ [data-slot="toast"][data-autodismiss="true"][data-state="open"] {
296
+ animation:
297
+ ev-toast-fade-in 200ms,
298
+ ev-toast-life var(--life) linear;
299
+ }
300
+ }