@olwiba/cn 0.1.54 → 0.1.55
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/dist/index.js +108 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5220,6 +5220,15 @@ var Toaster = ({
|
|
|
5220
5220
|
left: unset;
|
|
5221
5221
|
right: 0;
|
|
5222
5222
|
top: 0;
|
|
5223
|
+
/* sonner's own transform: var(--toast-close-button-transform) is
|
|
5224
|
+
still in play here, and on ltr it resolves to
|
|
5225
|
+
translate(-35%, -35%) \u2014 the offset that makes *its* button straddle
|
|
5226
|
+
the top-left edge. Setting left/right/top moved the box; the
|
|
5227
|
+
transform then dragged it back out by ~8px up and left, which is
|
|
5228
|
+
why the button read as floating above and outside the corner even
|
|
5229
|
+
though the coordinates said 0/0. The offset has to be cancelled,
|
|
5230
|
+
not just overridden at the other end. */
|
|
5231
|
+
transform: none;
|
|
5223
5232
|
height: 1.5rem;
|
|
5224
5233
|
width: 1.5rem;
|
|
5225
5234
|
padding: 0;
|
|
@@ -5235,7 +5244,15 @@ var Toaster = ({
|
|
|
5235
5244
|
where the card ends and the two curves are one line. The remaining
|
|
5236
5245
|
corners stay square, since they meet content rather than an edge. */
|
|
5237
5246
|
border-radius: 0;
|
|
5238
|
-
border
|
|
5247
|
+
/* Minus the border, because the two curves are measured from
|
|
5248
|
+
different edges. The toast's --border-radius describes its *outer*
|
|
5249
|
+
edge, but this button is absolutely positioned, so top/right: 0
|
|
5250
|
+
puts it on the padding box \u2014 the *inner* edge of that 1px border,
|
|
5251
|
+
where the curve is one pixel tighter. Drawing the outer radius here
|
|
5252
|
+
made the button fall away from the corner faster than the card
|
|
5253
|
+
does, which is the hairline gap that showed up in the curve and
|
|
5254
|
+
nowhere along the straight edges. */
|
|
5255
|
+
border-top-right-radius: calc(var(--border-radius) - 1px);
|
|
5239
5256
|
background: transparent;
|
|
5240
5257
|
/* Inherited rather than a fixed token: on a richColors toast the
|
|
5241
5258
|
text is already the only colour guaranteed to read against that
|
|
@@ -5358,8 +5375,97 @@ var Toaster = ({
|
|
|
5358
5375
|
color: inherit;
|
|
5359
5376
|
opacity: 1;
|
|
5360
5377
|
}
|
|
5378
|
+
/* Success and error carry a colour; everything else stays neutral.
|
|
5379
|
+
|
|
5380
|
+
Expressed by overriding sonner's own --normal-bg/-border/-text
|
|
5381
|
+
rather than painting background and border directly, because those
|
|
5382
|
+
three variables are what the rest of this stylesheet already reads:
|
|
5383
|
+
the action button inverts --normal-text against --normal-bg, the
|
|
5384
|
+
close button inherits the text colour. Retinting the variables moves
|
|
5385
|
+
all of it at once, and a tinted toast keeps a legible action button
|
|
5386
|
+
without a rule per type.
|
|
5387
|
+
|
|
5388
|
+
The tint is deliberately weak. The accent carries the icon at full
|
|
5389
|
+
strength and the border at a third, while the card stays within a
|
|
5390
|
+
few percent of the page background and the text stays --foreground.
|
|
5391
|
+
That is enough to read as green or red at a glance and not enough to
|
|
5392
|
+
turn a toast into a banner, which is what sonner's own richColors
|
|
5393
|
+
does. Anyone who wants that can still pass richColors: these rules
|
|
5394
|
+
bow out of a toast that has it, despite outranking it, because
|
|
5395
|
+
opting in to richColors should not land you in a third thing that is
|
|
5396
|
+
neither. */
|
|
5397
|
+
[data-sonner-toaster] [data-sonner-toast][data-styled='true'][data-type='success']:not([data-rich-colors='true']) {
|
|
5398
|
+
/* Falls back to a green of our own: --destructive is part of the
|
|
5399
|
+
shadcn token set and can be relied on, but there is no --success
|
|
5400
|
+
counterpart, and a registry item cannot require the consumer to go
|
|
5401
|
+
and add one. Named through var() anyway, so a project that does
|
|
5402
|
+
have the token gets its own green rather than ours. */
|
|
5403
|
+
--toast-accent: var(--success, oklch(0.55 0.14 152));
|
|
5404
|
+
}
|
|
5405
|
+
[data-sonner-toaster][data-sonner-theme='dark'] [data-sonner-toast][data-styled='true'][data-type='success']:not([data-rich-colors='true']) {
|
|
5406
|
+
/* Lightened for dark mode by hand. --destructive gets this for free
|
|
5407
|
+
from the theme; a literal cannot, and the light-mode green goes
|
|
5408
|
+
muddy against a dark card. */
|
|
5409
|
+
--toast-accent: var(--success, oklch(0.76 0.15 155));
|
|
5410
|
+
}
|
|
5411
|
+
[data-sonner-toaster] [data-sonner-toast][data-styled='true'][data-type='error']:not([data-rich-colors='true']) {
|
|
5412
|
+
--toast-accent: var(--destructive);
|
|
5413
|
+
}
|
|
5414
|
+
[data-sonner-toaster] [data-sonner-toast][data-styled='true']:is([data-type='success'], [data-type='error']):not([data-rich-colors='true']) {
|
|
5415
|
+
--normal-bg: color-mix(in oklab, var(--toast-accent) 7%, var(--background));
|
|
5416
|
+
--normal-border: color-mix(in oklab, var(--toast-accent) 30%, var(--border));
|
|
5417
|
+
--normal-text: var(--foreground);
|
|
5418
|
+
/* Restated as concrete properties, not left to sonner's base rule to
|
|
5419
|
+
pick up from the variables. The toastOptions classNames below set
|
|
5420
|
+
bg-background/text-foreground/border-border as utilities, which tie
|
|
5421
|
+
with sonner's own rule on specificity and win on order, so the
|
|
5422
|
+
variables alone would change nothing visible. */
|
|
5423
|
+
background: var(--normal-bg);
|
|
5424
|
+
border-color: var(--normal-border);
|
|
5425
|
+
color: var(--normal-text);
|
|
5426
|
+
}
|
|
5427
|
+
[data-sonner-toaster][data-sonner-theme='dark'] [data-sonner-toast][data-styled='true']:is([data-type='success'], [data-type='error']):not([data-rich-colors='true']) {
|
|
5428
|
+
/* A dark card needs more of the accent to shift by the same visible
|
|
5429
|
+
amount, since the mix is against near-black rather than near-white. */
|
|
5430
|
+
--normal-bg: color-mix(in oklab, var(--toast-accent) 14%, var(--background));
|
|
5431
|
+
}
|
|
5432
|
+
[data-sonner-toaster] [data-sonner-toast][data-styled='true']:is([data-type='success'], [data-type='error']):not([data-rich-colors='true']) [data-icon] {
|
|
5433
|
+
color: var(--toast-accent);
|
|
5434
|
+
}
|
|
5361
5435
|
` }),
|
|
5362
|
-
mode === "smooth" && /* @__PURE__ */ jsx("style", { children: `
|
|
5436
|
+
mode === "smooth" && /* @__PURE__ */ jsx("style", { children: `
|
|
5437
|
+
[data-sonner-toaster].toaster-smooth { --border-radius: 1.5rem; }
|
|
5438
|
+
/* The corner-hugging close button is a default-mode idea and does not
|
|
5439
|
+
survive the move to a 1.5rem radius. At 8px the button's own curve
|
|
5440
|
+
is a small correction to a mostly square corner; at 24px the corner
|
|
5441
|
+
is deeper than the button is wide, so the shape degenerates into a
|
|
5442
|
+
bare quarter-circle whose two straight edges cut across the card's
|
|
5443
|
+
curve. Rounder cards want the opposite treatment: pull the button
|
|
5444
|
+
off the edge and let it be a circle.
|
|
5445
|
+
|
|
5446
|
+
The inset is derived rather than chosen. A rounded corner is an arc
|
|
5447
|
+
whose centre sits --border-radius in from both edges, so putting the
|
|
5448
|
+
button's centre on that same point makes the two concentric, and
|
|
5449
|
+
the gap between button and card edge stays equal the whole way
|
|
5450
|
+
around the curve instead of pinching at the diagonal. That centre
|
|
5451
|
+
is --border-radius from the card's outer edge, the button reaches
|
|
5452
|
+
half its own width back toward it, and top/right are measured from
|
|
5453
|
+
the padding box, one border inside. Hence the 1px.
|
|
5454
|
+
|
|
5455
|
+
It follows --border-radius, so this stays true if the smooth radius
|
|
5456
|
+
is ever retuned. */
|
|
5457
|
+
[data-sonner-toaster].toaster-smooth [data-sonner-toast][data-styled='true'] [data-close-button] {
|
|
5458
|
+
top: calc(var(--border-radius) - 0.75rem - 1px);
|
|
5459
|
+
right: calc(var(--border-radius) - 0.75rem - 1px);
|
|
5460
|
+
border-radius: 50%;
|
|
5461
|
+
}
|
|
5462
|
+
/* Reserving the corner again, now that the button has moved inward:
|
|
5463
|
+
its far edge is the inset plus its own width, and the content stops
|
|
5464
|
+
short of that. */
|
|
5465
|
+
[data-sonner-toaster].toaster-smooth [data-sonner-toast][data-styled='true']:has([data-close-button]) {
|
|
5466
|
+
padding-right: calc(var(--border-radius) + 1.25rem);
|
|
5467
|
+
}
|
|
5468
|
+
` }),
|
|
5363
5469
|
mode === "playful" && /* @__PURE__ */ jsx("style", { children: `
|
|
5364
5470
|
[data-sonner-toaster].toaster-playful [data-sonner-toast][data-mounted=true] {
|
|
5365
5471
|
transform: var(--y) rotate(0.3deg);
|