@evinvest/uikit 0.2.0 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evinvest/uikit",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
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
@@ -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 {
@@ -123,3 +125,171 @@
123
125
  --page-px: 3rem;
124
126
  }
125
127
  }
128
+
129
+ /* ── Toast stacking (Sonner-style), shared by both ports via data-stack ──────
130
+ Both `ev::uikit` (Dioxus) and `@evinvest/uikit` (React) set data-stack on the
131
+ toaster and drive the same machine: toasts are absolutely stacked at the
132
+ pinned edge, pile up collapsed (front three peeking, each lifted + scaled by
133
+ --index and clamped to --front-height), and spread to --offset on hover /
134
+ keyboard focus (pure CSS — no JS state). Vars: the toaster sets --front-height
135
+ + --gap; each toast sets --index, --z-index, --offset, --initial-height. React
136
+ measures real heights; Dioxus can't (host-only), so it feeds a constant height
137
+ — collapse is exact, expansion is uniform. The enter is a keyframe (plays on
138
+ DOM insertion, so it works in both ports without a JS mount flip),
139
+ `data-state=closed` slides out, and the node is dropped on the transitionend. */
140
+
141
+ [data-slot="toaster"][data-stack] [data-slot="toast"] {
142
+ position: absolute;
143
+ --y: translateY(0);
144
+ opacity: 1;
145
+ z-index: var(--z-index, 1);
146
+ transform: var(--y) translateX(var(--swipe-x, 0px));
147
+ /* a plain easeOut (no overshoot) so a restack settles instead of bouncing
148
+ back past its slot */
149
+ transition:
150
+ transform 350ms cubic-bezier(0.21, 0.8, 0.4, 1),
151
+ opacity 350ms,
152
+ height 350ms;
153
+ /* the enter is a keyframe (plays on DOM insertion in both ports — no JS mount
154
+ flip, whose pre-paint timing the Dioxus effect couldn't drive). It animates
155
+ the independent `translate` property, NOT `transform`, so it *composes* with
156
+ the stack transform instead of overriding it: a toast pushed back mid-enter
157
+ keeps repositioning smoothly instead of fighting the keyframe (rapid-fire
158
+ lag). */
159
+ animation: ev-toast-enter 350ms cubic-bezier(0.21, 0.8, 0.4, 1) backwards;
160
+ }
161
+ @keyframes ev-toast-enter {
162
+ from {
163
+ opacity: 0;
164
+ translate: 0 var(--enter-y, 100%);
165
+ }
166
+ to {
167
+ opacity: 1;
168
+ translate: 0 0;
169
+ }
170
+ }
171
+
172
+ /* pin to the toaster's edge; set the lift sign + the off-screen enter offset */
173
+ [data-slot="toaster"][data-stack][data-y-position="bottom"] [data-slot="toast"] {
174
+ bottom: 0;
175
+ --lift: -1;
176
+ --enter-y: 100%;
177
+ }
178
+ [data-slot="toaster"][data-stack][data-y-position="top"] [data-slot="toast"] {
179
+ top: 0;
180
+ --lift: 1;
181
+ --enter-y: -100%;
182
+ }
183
+
184
+ /* closing: slide back off + fade out; the node is dropped on its transitionend */
185
+ [data-slot="toaster"][data-stack] [data-slot="toast"][data-state="closed"] {
186
+ --y: translateY(var(--enter-y));
187
+ opacity: 0;
188
+ }
189
+
190
+ /* collapsed: back toasts lift + shrink by depth, clamp to the front height */
191
+ [data-slot="toaster"][data-stack]
192
+ [data-slot="toast"][data-state="open"][data-front="false"] {
193
+ --y: translateY(calc(var(--lift) * var(--gap) * var(--index)))
194
+ scale(calc(1 - var(--index) * 0.05));
195
+ height: var(--front-height);
196
+ }
197
+ [data-slot="toaster"][data-stack] [data-slot="toast"][data-front="false"] > * {
198
+ opacity: 0;
199
+ transition: opacity 300ms;
200
+ }
201
+ /* only the front three show while collapsed */
202
+ [data-slot="toaster"][data-stack] [data-slot="toast"][data-visible="false"] {
203
+ opacity: 0;
204
+ pointer-events: none;
205
+ }
206
+
207
+ /* expanded (hover / keyboard focus): spread to the offset, real height, content
208
+ + overflow back */
209
+ [data-slot="toaster"][data-stack]:hover [data-slot="toast"][data-state="open"],
210
+ [data-slot="toaster"][data-stack]:focus-within
211
+ [data-slot="toast"][data-state="open"] {
212
+ --y: translateY(calc(var(--lift) * var(--offset)));
213
+ height: var(--initial-height);
214
+ }
215
+ [data-slot="toaster"][data-stack]:hover [data-slot="toast"] > *,
216
+ [data-slot="toaster"][data-stack]:focus-within [data-slot="toast"] > *,
217
+ [data-slot="toaster"][data-stack]:hover [data-slot="toast"][data-visible="false"],
218
+ [data-slot="toaster"][data-stack]:focus-within
219
+ [data-slot="toast"][data-visible="false"] {
220
+ opacity: 1;
221
+ pointer-events: auto;
222
+ }
223
+
224
+ /* a transparent strip over the gap so the hover area stays contiguous between
225
+ spread toasts (otherwise the pointer falls through the gap and it collapses) */
226
+ [data-slot="toaster"][data-stack] [data-slot="toast"]::after {
227
+ content: "";
228
+ position: absolute;
229
+ left: 0;
230
+ width: 100%;
231
+ height: calc(var(--gap) + 1px);
232
+ }
233
+ [data-slot="toaster"][data-stack][data-y-position="bottom"]
234
+ [data-slot="toast"]::after {
235
+ bottom: 100%;
236
+ }
237
+ [data-slot="toaster"][data-stack][data-y-position="top"]
238
+ [data-slot="toast"]::after {
239
+ top: 100%;
240
+ }
241
+
242
+ /* 1:1 finger tracking during a swipe — kill the transition */
243
+ [data-slot="toaster"][data-stack] [data-slot="toast"][data-swiping="true"] {
244
+ transition: none;
245
+ }
246
+
247
+ /* auto-dismiss without a host timer: a no-op "life" animation runs for --life,
248
+ then its `animationend` fires (the toast closes itself). Hovering/focusing the
249
+ stack pauses just that animation (animation-play-state's 2nd slot), so the
250
+ countdown holds — and resumes with the elapsed time preserved — while the
251
+ enter (1st slot) keeps running. Persistent toasts set data-autodismiss=false,
252
+ so they get no life animation. (The React port uses setTimeout instead.) */
253
+ @keyframes ev-toast-life {
254
+ from {
255
+ --ev-life: 0;
256
+ }
257
+ to {
258
+ --ev-life: 1;
259
+ }
260
+ }
261
+ [data-slot="toaster"][data-stack]
262
+ [data-slot="toast"][data-autodismiss="true"][data-state="open"] {
263
+ animation:
264
+ ev-toast-enter 350ms cubic-bezier(0.21, 0.8, 0.4, 1) backwards,
265
+ ev-toast-life var(--life) linear;
266
+ }
267
+ [data-slot="toaster"][data-stack]:hover
268
+ [data-slot="toast"][data-autodismiss="true"],
269
+ [data-slot="toaster"][data-stack]:focus-within
270
+ [data-slot="toast"][data-autodismiss="true"] {
271
+ animation-play-state: running, paused;
272
+ }
273
+
274
+ /* reduced motion: opacity-only enter + near-instant transform (still fires
275
+ transitionend, so exit removal works), no height animation */
276
+ @keyframes ev-toast-fade-in {
277
+ from {
278
+ opacity: 0;
279
+ }
280
+ }
281
+ @media (prefers-reduced-motion: reduce) {
282
+ [data-slot="toaster"][data-stack] [data-slot="toast"] {
283
+ transition:
284
+ transform 1ms linear,
285
+ opacity 200ms;
286
+ animation: ev-toast-fade-in 200ms;
287
+ }
288
+ /* keep the auto-dismiss life animation under reduced motion */
289
+ [data-slot="toaster"][data-stack]
290
+ [data-slot="toast"][data-autodismiss="true"][data-state="open"] {
291
+ animation:
292
+ ev-toast-fade-in 200ms,
293
+ ev-toast-life var(--life) linear;
294
+ }
295
+ }