@olwiba/cn 0.1.52 → 0.1.54

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
@@ -5218,18 +5218,24 @@ var Toaster = ({
5218
5218
  so setting the properties directly is both simpler and no longer
5219
5219
  dependent on variables whose declaration site we do not control. */
5220
5220
  left: unset;
5221
- right: 0.375rem;
5222
- top: 0.375rem;
5223
- height: 1.25rem;
5224
- width: 1.25rem;
5221
+ right: 0;
5222
+ top: 0;
5223
+ height: 1.5rem;
5224
+ width: 1.5rem;
5225
5225
  padding: 0;
5226
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. */
5231
- border-radius: var(--radius-sm);
5232
- border-top-right-radius: 0.375rem;
5227
+ /* Flush into the corner, with the top-right corner following the
5228
+ toast's own curve rather than approximating it.
5229
+
5230
+ An inset looked deliberate in isolation and wrong in place: the
5231
+ button read as floating in the padding instead of occupying the
5232
+ corner, and the gap was uneven because the toast's radius pulls the
5233
+ card edge away diagonally. Sitting at 0/0 with the same
5234
+ --border-radius sonner gives the card, the hover fill ends exactly
5235
+ where the card ends and the two curves are one line. The remaining
5236
+ corners stay square, since they meet content rather than an edge. */
5237
+ border-radius: 0;
5238
+ border-top-right-radius: var(--border-radius);
5233
5239
  background: transparent;
5234
5240
  /* Inherited rather than a fixed token: on a richColors toast the
5235
5241
  text is already the only colour guaranteed to read against that
@@ -5266,24 +5272,46 @@ var Toaster = ({
5266
5272
  line-height: 1.45;
5267
5273
  opacity: 0.75;
5268
5274
  }
5269
- /* Top-aligned rather than centred on the whole card.
5275
+ /* Grid rather than sonner's flex row.
5276
+ Three things have to hold at once: the icon keeps its own column to
5277
+ the left of the text, it sits at the top of that column rather than
5278
+ centred, and the action takes a second row beneath the text instead of
5279
+ running inline at the end of the first.
5280
+
5270
5281
  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. */
5282
+ steadily worse as it grows: with a title, a description and an action
5283
+ the icon drifts to the middle of a three-line block and stops reading
5284
+ as the marker for the line it belongs to. Toasts have no height limit,
5285
+ so that only gets worse the taller they are.
5286
+
5287
+ Flex could not express the third without disturbing the first.
5288
+ Forcing a wrap with flex-basis: 100% and then clamping the width back
5289
+ with max-content does nothing, because flex line-breaking measures the
5290
+ item *after* max-width is applied: the button stayed narrow and stayed
5291
+ inline. Stating the placement is shorter than coaxing it. */
5275
5292
  [data-sonner-toaster] [data-sonner-toast][data-styled='true'] {
5276
- align-items: flex-start;
5277
- flex-wrap: wrap;
5293
+ display: grid;
5294
+ grid-template-columns: auto minmax(0, 1fr);
5295
+ align-items: start;
5296
+ column-gap: 6px;
5297
+ row-gap: 0.5rem;
5278
5298
  }
5279
5299
  [data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-icon] {
5300
+ grid-column: 1;
5301
+ grid-row: 1;
5280
5302
  /* Optical centring against the title's first line, not its box. */
5281
5303
  margin-top: 0.0625rem;
5282
5304
  }
5283
5305
  [data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-content] {
5284
- flex: 1 1 auto;
5306
+ grid-column: 2;
5307
+ grid-row: 1;
5285
5308
  min-width: 0;
5286
5309
  }
5310
+ /* A toast with no icon has nothing in column one, which collapses to
5311
+ zero width, so the text still starts at the padding edge. */
5312
+ [data-sonner-toaster] [data-sonner-toast][data-styled='true']:not(:has([data-icon])) [data-content] {
5313
+ grid-column: 1 / -1;
5314
+ }
5287
5315
  /* Buttons inherit the toast's own colour rather than the global
5288
5316
  primary, so an action on a richColors error still reads against red
5289
5317
  instead of disappearing into it. */
@@ -5293,29 +5321,33 @@ var Toaster = ({
5293
5321
  font-size: 0.75rem;
5294
5322
  font-weight: 500;
5295
5323
  }
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. */
5324
+ /* Second row, under the text and sharing its left edge.
5325
+ justify-self: start keeps it at its label width instead of
5326
+ stretching across the column, which a grid item otherwise does. */
5303
5327
  [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;
5328
+ grid-column: 2;
5329
+ grid-row: 2;
5330
+ justify-self: start;
5331
+ margin: 0;
5308
5332
  }
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);
5333
+ [data-sonner-toaster] [data-sonner-toast][data-styled='true']:not(:has([data-icon])) [data-action] {
5334
+ grid-column: 1 / -1;
5314
5335
  }
5336
+ /* Inverted against the toast: its text colour becomes the fill.
5337
+ This used to read color-mix(in oklab, currentColor 90%, transparent)
5338
+ for the background while the same rule set color: var(--normal-bg).
5339
+ currentColor resolves to the element's own colour, so both ended up
5340
+ as the toast background: a dark button with dark text on a dark
5341
+ toast, invisible and impossible to aim at. Naming the token instead of
5342
+ reaching for currentColor keeps the contrast pair explicit, and still
5343
+ tracks a richColors toast, since sonner sets both variables per type. */
5315
5344
  [data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-action] {
5316
- background: color-mix(in oklab, currentColor 90%, transparent);
5345
+ background: var(--normal-text);
5317
5346
  color: var(--normal-bg);
5318
5347
  }
5348
+ [data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-action]:hover {
5349
+ background: color-mix(in oklab, var(--normal-text) 88%, var(--normal-bg));
5350
+ }
5319
5351
  [data-sonner-toaster] [data-sonner-toast][data-styled='true'] [data-cancel] {
5320
5352
  background: color-mix(in oklab, currentColor 10%, transparent);
5321
5353
  color: inherit;
@@ -5342,6 +5374,7 @@ var Toaster = ({
5342
5374
  {
5343
5375
  theme,
5344
5376
  duration,
5377
+ closeButton,
5345
5378
  className: cn("toaster group", mode && `toaster-${mode}`, className),
5346
5379
  style: { zIndex: 9999999, ...style },
5347
5380
  icons: {