@olwiba/cn 0.1.51 → 0.1.53
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.d.ts +1 -1
- package/dist/index.js +78 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1000,7 +1000,7 @@ declare const Slider: React$1.ForwardRefExoticComponent<SliderProps & React$1.Re
|
|
|
1000
1000
|
|
|
1001
1001
|
type ToasterProps = React$1.ComponentProps<typeof Toaster$1>;
|
|
1002
1002
|
type ToasterMode = "playful" | "smooth";
|
|
1003
|
-
declare const Toaster: ({ mode: modeProp, className, style, duration, ...props }: ToasterProps & {
|
|
1003
|
+
declare const Toaster: ({ mode: modeProp, className, style, duration, closeButton, ...props }: ToasterProps & {
|
|
1004
1004
|
mode?: ToasterMode;
|
|
1005
1005
|
}) => React$1.JSX.Element;
|
|
1006
1006
|
|
package/dist/index.js
CHANGED
|
@@ -5188,6 +5188,12 @@ var Toaster = ({
|
|
|
5188
5188
|
className,
|
|
5189
5189
|
style,
|
|
5190
5190
|
duration = DEFAULT_TOAST_DURATION,
|
|
5191
|
+
// On by default, because the alternative was every consumer deciding
|
|
5192
|
+
// separately: the apps passed `closeButton`, the docs site did not, and the
|
|
5193
|
+
// same component then looked like two different components depending on where
|
|
5194
|
+
// you met it. A toast carrying an action is also one you may want to dismiss
|
|
5195
|
+
// without taking it, and waiting out the timer is not a dismissal.
|
|
5196
|
+
closeButton = true,
|
|
5191
5197
|
...props
|
|
5192
5198
|
}) => {
|
|
5193
5199
|
const theme = useDocumentTheme();
|
|
@@ -5212,13 +5218,18 @@ var Toaster = ({
|
|
|
5212
5218
|
so setting the properties directly is both simpler and no longer
|
|
5213
5219
|
dependent on variables whose declaration site we do not control. */
|
|
5214
5220
|
left: unset;
|
|
5215
|
-
right: 0.
|
|
5216
|
-
top: 0.
|
|
5221
|
+
right: 0.375rem;
|
|
5222
|
+
top: 0.375rem;
|
|
5217
5223
|
height: 1.25rem;
|
|
5218
5224
|
width: 1.25rem;
|
|
5219
5225
|
padding: 0;
|
|
5220
5226
|
border: none;
|
|
5227
|
+
/* The top-right corner is rounded harder than the other three so the
|
|
5228
|
+
hover fill nests inside the toast's own curve. Tucked this close to
|
|
5229
|
+
the corner, a uniformly square-ish button reads as overhanging the
|
|
5230
|
+
card the moment it gains a background. */
|
|
5221
5231
|
border-radius: var(--radius-sm);
|
|
5232
|
+
border-top-right-radius: 0.375rem;
|
|
5222
5233
|
background: transparent;
|
|
5223
5234
|
/* Inherited rather than a fixed token: on a richColors toast the
|
|
5224
5235
|
text is already the only colour guaranteed to read against that
|
|
@@ -5255,6 +5266,46 @@ var Toaster = ({
|
|
|
5255
5266
|
line-height: 1.45;
|
|
5256
5267
|
opacity: 0.75;
|
|
5257
5268
|
}
|
|
5269
|
+
/* Grid rather than sonner's flex row.
|
|
5270
|
+
Three things have to hold at once: the icon keeps its own column to
|
|
5271
|
+
the left of the text, it sits at the top of that column rather than
|
|
5272
|
+
centred, and the action takes a second row beneath the text instead of
|
|
5273
|
+
running inline at the end of the first.
|
|
5274
|
+
|
|
5275
|
+
sonner centres every child, which is right for a one-line toast and
|
|
5276
|
+
steadily worse as it grows: with a title, a description and an action
|
|
5277
|
+
the icon drifts to the middle of a three-line block and stops reading
|
|
5278
|
+
as the marker for the line it belongs to. Toasts have no height limit,
|
|
5279
|
+
so that only gets worse the taller they are.
|
|
5280
|
+
|
|
5281
|
+
Flex could not express the third without disturbing the first.
|
|
5282
|
+
Forcing a wrap with flex-basis: 100% and then clamping the width back
|
|
5283
|
+
with max-content does nothing, because flex line-breaking measures the
|
|
5284
|
+
item *after* max-width is applied: the button stayed narrow and stayed
|
|
5285
|
+
inline. Stating the placement is shorter than coaxing it. */
|
|
5286
|
+
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] {
|
|
5287
|
+
display: grid;
|
|
5288
|
+
grid-template-columns: auto minmax(0, 1fr);
|
|
5289
|
+
align-items: start;
|
|
5290
|
+
column-gap: 6px;
|
|
5291
|
+
row-gap: 0.5rem;
|
|
5292
|
+
}
|
|
5293
|
+
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-icon] {
|
|
5294
|
+
grid-column: 1;
|
|
5295
|
+
grid-row: 1;
|
|
5296
|
+
/* Optical centring against the title's first line, not its box. */
|
|
5297
|
+
margin-top: 0.0625rem;
|
|
5298
|
+
}
|
|
5299
|
+
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-content] {
|
|
5300
|
+
grid-column: 2;
|
|
5301
|
+
grid-row: 1;
|
|
5302
|
+
min-width: 0;
|
|
5303
|
+
}
|
|
5304
|
+
/* A toast with no icon has nothing in column one, which collapses to
|
|
5305
|
+
zero width, so the text still starts at the padding edge. */
|
|
5306
|
+
[data-sonner-toaster] [data-sonner-toast][data-styled='true']:not(:has([data-icon])) [data-content] {
|
|
5307
|
+
grid-column: 1 / -1;
|
|
5308
|
+
}
|
|
5258
5309
|
/* Buttons inherit the toast's own colour rather than the global
|
|
5259
5310
|
primary, so an action on a richColors error still reads against red
|
|
5260
5311
|
instead of disappearing into it. */
|
|
@@ -5264,10 +5315,33 @@ var Toaster = ({
|
|
|
5264
5315
|
font-size: 0.75rem;
|
|
5265
5316
|
font-weight: 500;
|
|
5266
5317
|
}
|
|
5318
|
+
/* Second row, under the text and sharing its left edge.
|
|
5319
|
+
justify-self: start keeps it at its label width instead of
|
|
5320
|
+
stretching across the column, which a grid item otherwise does. */
|
|
5267
5321
|
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-action] {
|
|
5268
|
-
|
|
5322
|
+
grid-column: 2;
|
|
5323
|
+
grid-row: 2;
|
|
5324
|
+
justify-self: start;
|
|
5325
|
+
margin: 0;
|
|
5326
|
+
}
|
|
5327
|
+
[data-sonner-toaster] [data-sonner-toast][data-styled='true']:not(:has([data-icon])) [data-action] {
|
|
5328
|
+
grid-column: 1 / -1;
|
|
5329
|
+
}
|
|
5330
|
+
/* Inverted against the toast: its text colour becomes the fill.
|
|
5331
|
+
This used to read color-mix(in oklab, currentColor 90%, transparent)
|
|
5332
|
+
for the background while the same rule set color: var(--normal-bg).
|
|
5333
|
+
currentColor resolves to the element's own colour, so both ended up
|
|
5334
|
+
as the toast background: a dark button with dark text on a dark
|
|
5335
|
+
toast, invisible and impossible to aim at. Naming the token instead of
|
|
5336
|
+
reaching for currentColor keeps the contrast pair explicit, and still
|
|
5337
|
+
tracks a richColors toast, since sonner sets both variables per type. */
|
|
5338
|
+
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-action] {
|
|
5339
|
+
background: var(--normal-text);
|
|
5269
5340
|
color: var(--normal-bg);
|
|
5270
5341
|
}
|
|
5342
|
+
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-action]:hover {
|
|
5343
|
+
background: color-mix(in oklab, var(--normal-text) 88%, var(--normal-bg));
|
|
5344
|
+
}
|
|
5271
5345
|
[data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-cancel] {
|
|
5272
5346
|
background: color-mix(in oklab, currentColor 10%, transparent);
|
|
5273
5347
|
color: inherit;
|
|
@@ -5294,6 +5368,7 @@ var Toaster = ({
|
|
|
5294
5368
|
{
|
|
5295
5369
|
theme,
|
|
5296
5370
|
duration,
|
|
5371
|
+
closeButton,
|
|
5297
5372
|
className: cn("toaster group", mode && `toaster-${mode}`, className),
|
|
5298
5373
|
style: { zIndex: 9999999, ...style },
|
|
5299
5374
|
icons: {
|