@olwiba/cn 0.1.52 → 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.js CHANGED
@@ -5266,24 +5266,46 @@ var Toaster = ({
5266
5266
  line-height: 1.45;
5267
5267
  opacity: 0.75;
5268
5268
  }
5269
- /* Top-aligned rather than centred on the whole card.
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
+
5270
5275
  sonner centres every child, which is right for a one-line toast and
5271
- steadily worse as it grows: with a title, a description and an
5272
- action, the icon drifts to the middle of a three-line block and
5273
- stops reading as the marker for the line it belongs to. Toasts have
5274
- no height limit, so this only gets worse the taller they are. */
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. */
5275
5286
  [data-sonner-toaster] [data-sonner-toast][data-styled='true'] {
5276
- align-items: flex-start;
5277
- flex-wrap: wrap;
5287
+ display: grid;
5288
+ grid-template-columns: auto minmax(0, 1fr);
5289
+ align-items: start;
5290
+ column-gap: 6px;
5291
+ row-gap: 0.5rem;
5278
5292
  }
5279
5293
  [data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-icon] {
5294
+ grid-column: 1;
5295
+ grid-row: 1;
5280
5296
  /* Optical centring against the title's first line, not its box. */
5281
5297
  margin-top: 0.0625rem;
5282
5298
  }
5283
5299
  [data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-content] {
5284
- flex: 1 1 auto;
5300
+ grid-column: 2;
5301
+ grid-row: 1;
5285
5302
  min-width: 0;
5286
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
+ }
5287
5309
  /* Buttons inherit the toast's own colour rather than the global
5288
5310
  primary, so an action on a richColors error still reads against red
5289
5311
  instead of disappearing into it. */
@@ -5293,29 +5315,33 @@ var Toaster = ({
5293
5315
  font-size: 0.75rem;
5294
5316
  font-weight: 500;
5295
5317
  }
5296
- /* The action gets its own row under the text.
5297
- sonner puts it inline at the end of the flex row, which on a toast
5298
- with a description squeezes it against the right edge next to the
5299
- close button and leaves it competing with the cross for the same
5300
- corner. A flex-basis of 100% forces the wrap; max-width: max-content
5301
- then pulls it back to its label width so it does not become a
5302
- full-width bar. */
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. */
5303
5321
  [data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-action] {
5304
- flex: 0 0 100%;
5305
- max-width: max-content;
5306
- margin-left: 0;
5307
- margin-top: 0.5rem;
5322
+ grid-column: 2;
5323
+ grid-row: 2;
5324
+ justify-self: start;
5325
+ margin: 0;
5308
5326
  }
5309
- /* Line the action up with the title rather than the icon. The offset is
5310
- the icon's own box plus the toast's column gap, so the three left
5311
- edges of title, description and action agree. */
5312
- [data-sonner-toaster] [data-sonner-toast][data-styled='true']:has([data-icon]) [data-action] {
5313
- margin-left: calc(1rem + var(--toast-icon-margin-start) + var(--toast-icon-margin-end) + 6px);
5327
+ [data-sonner-toaster] [data-sonner-toast][data-styled='true']:not(:has([data-icon])) [data-action] {
5328
+ grid-column: 1 / -1;
5314
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. */
5315
5338
  [data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-action] {
5316
- background: color-mix(in oklab, currentColor 90%, transparent);
5339
+ background: var(--normal-text);
5317
5340
  color: var(--normal-bg);
5318
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
+ }
5319
5345
  [data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-cancel] {
5320
5346
  background: color-mix(in oklab, currentColor 10%, transparent);
5321
5347
  color: inherit;
@@ -5342,6 +5368,7 @@ var Toaster = ({
5342
5368
  {
5343
5369
  theme,
5344
5370
  duration,
5371
+ closeButton,
5345
5372
  className: cn("toaster group", mode && `toaster-${mode}`, className),
5346
5373
  style: { zIndex: 9999999, ...style },
5347
5374
  icons: {