sonner 1.7.4 → 2.0.0-beta.1

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/styles.css CHANGED
@@ -1,5 +1,5 @@
1
- :where(html[dir='ltr']),
2
- :where([data-sonner-toaster][dir='ltr']) {
1
+ html[dir='ltr'],
2
+ [data-sonner-toaster][dir='ltr'] {
3
3
  --toast-icon-margin-start: -3px;
4
4
  --toast-icon-margin-end: 4px;
5
5
  --toast-svg-margin-start: -1px;
@@ -11,8 +11,8 @@
11
11
  --toast-close-button-transform: translate(-35%, -35%);
12
12
  }
13
13
 
14
- :where(html[dir='rtl']),
15
- :where([data-sonner-toaster][dir='rtl']) {
14
+ html[dir='rtl'],
15
+ [data-sonner-toaster][dir='rtl'] {
16
16
  --toast-icon-margin-start: 4px;
17
17
  --toast-icon-margin-end: -3px;
18
18
  --toast-svg-margin-start: 0px;
@@ -24,7 +24,7 @@
24
24
  --toast-close-button-transform: translate(35%, -35%);
25
25
  }
26
26
 
27
- :where([data-sonner-toaster]) {
27
+ [data-sonner-toaster] {
28
28
  position: fixed;
29
29
  width: var(--width);
30
30
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial,
@@ -51,38 +51,28 @@
51
51
  transition: transform 400ms ease;
52
52
  }
53
53
 
54
- :where([data-sonner-toaster][data-lifted='true']) {
55
- transform: translateY(-10px);
56
- }
57
-
58
- @media (hover: none) and (pointer: coarse) {
59
- :where([data-sonner-toaster][data-lifted='true']) {
60
- transform: none;
61
- }
62
- }
63
-
64
- :where([data-sonner-toaster][data-x-position='right']) {
54
+ [data-sonner-toaster][data-x-position='right'] {
65
55
  right: var(--offset-right);
66
56
  }
67
57
 
68
- :where([data-sonner-toaster][data-x-position='left']) {
58
+ [data-sonner-toaster][data-x-position='left'] {
69
59
  left: var(--offset-left);
70
60
  }
71
61
 
72
- :where([data-sonner-toaster][data-x-position='center']) {
62
+ [data-sonner-toaster][data-x-position='center'] {
73
63
  left: 50%;
74
64
  transform: translateX(-50%);
75
65
  }
76
66
 
77
- :where([data-sonner-toaster][data-y-position='top']) {
67
+ [data-sonner-toaster][data-y-position='top'] {
78
68
  top: var(--offset-top);
79
69
  }
80
70
 
81
- :where([data-sonner-toaster][data-y-position='bottom']) {
71
+ [data-sonner-toaster][data-y-position='bottom'] {
82
72
  bottom: var(--offset-bottom);
83
73
  }
84
74
 
85
- :where([data-sonner-toast]) {
75
+ [data-sonner-toast] {
86
76
  --y: translateY(100%);
87
77
  --lift-amount: calc(var(--lift) * var(--gap));
88
78
  z-index: var(--z-index);
@@ -90,7 +80,6 @@
90
80
  opacity: 0;
91
81
  transform: var(--y);
92
82
  filter: blur(0);
93
- /* https://stackoverflow.com/questions/48124372/pointermove-event-not-working-with-touch-why-not */
94
83
  touch-action: none;
95
84
  transition: transform 400ms, opacity 400ms, height 400ms, box-shadow 200ms;
96
85
  box-sizing: border-box;
@@ -98,7 +87,7 @@
98
87
  overflow-wrap: anywhere;
99
88
  }
100
89
 
101
- :where([data-sonner-toast][data-styled='true']) {
90
+ [data-sonner-toast][data-styled='true'] {
102
91
  padding: 16px;
103
92
  background: var(--normal-bg);
104
93
  border: 1px solid var(--normal-border);
@@ -112,37 +101,41 @@
112
101
  gap: 6px;
113
102
  }
114
103
 
115
- :where([data-sonner-toast]:focus-visible) {
104
+ [data-sonner-toast]:focus-visible {
116
105
  box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1), 0 0 0 2px rgba(0, 0, 0, 0.2);
117
106
  }
118
107
 
119
- :where([data-sonner-toast][data-y-position='top']) {
108
+ [data-sonner-toast][data-y-position='top'] {
120
109
  top: 0;
121
110
  --y: translateY(-100%);
122
111
  --lift: 1;
123
112
  --lift-amount: calc(1 * var(--gap));
124
113
  }
125
114
 
126
- :where([data-sonner-toast][data-y-position='bottom']) {
115
+ [data-sonner-toast][data-y-position='bottom'] {
127
116
  bottom: 0;
128
117
  --y: translateY(100%);
129
118
  --lift: -1;
130
119
  --lift-amount: calc(var(--lift) * var(--gap));
131
120
  }
132
121
 
133
- :where([data-sonner-toast]) :where([data-description]) {
122
+ [data-sonner-toast] [data-description] {
134
123
  font-weight: 400;
135
124
  line-height: 1.4;
136
- color: inherit;
125
+ color: #3f3f3f;
137
126
  }
138
127
 
139
- :where([data-sonner-toast]) :where([data-title]) {
128
+ [data-sonner-toaster][data-sonner-theme='dark'] [data-description] {
129
+ color: hsl(0, 0%, 91%);
130
+ }
131
+
132
+ [data-sonner-toast] [data-title] {
140
133
  font-weight: 500;
141
134
  line-height: 1.5;
142
135
  color: inherit;
143
136
  }
144
137
 
145
- :where([data-sonner-toast]) :where([data-icon]) {
138
+ [data-sonner-toast] [data-icon] {
146
139
  display: flex;
147
140
  height: 16px;
148
141
  width: 16px;
@@ -154,23 +147,23 @@
154
147
  margin-right: var(--toast-icon-margin-end);
155
148
  }
156
149
 
157
- :where([data-sonner-toast][data-promise='true']) :where([data-icon]) > svg {
150
+ [data-sonner-toast][data-promise='true'] [data-icon] > svg {
158
151
  opacity: 0;
159
152
  transform: scale(0.8);
160
153
  transform-origin: center;
161
154
  animation: sonner-fade-in 300ms ease forwards;
162
155
  }
163
156
 
164
- :where([data-sonner-toast]) :where([data-icon]) > * {
157
+ [data-sonner-toast] [data-icon] > * {
165
158
  flex-shrink: 0;
166
159
  }
167
160
 
168
- :where([data-sonner-toast]) :where([data-icon]) svg {
161
+ [data-sonner-toast] [data-icon] svg {
169
162
  margin-left: var(--toast-svg-margin-start);
170
163
  margin-right: var(--toast-svg-margin-end);
171
164
  }
172
165
 
173
- :where([data-sonner-toast]) :where([data-content]) {
166
+ [data-sonner-toast] [data-content] {
174
167
  display: flex;
175
168
  flex-direction: column;
176
169
  gap: 2px;
@@ -187,6 +180,7 @@
187
180
  margin-left: var(--toast-button-margin-start);
188
181
  margin-right: var(--toast-button-margin-end);
189
182
  border: none;
183
+ font-weight: 500;
190
184
  cursor: pointer;
191
185
  outline: none;
192
186
  display: flex;
@@ -195,25 +189,25 @@
195
189
  transition: opacity 400ms, box-shadow 200ms;
196
190
  }
197
191
 
198
- :where([data-sonner-toast]) :where([data-button]):focus-visible {
192
+ [data-sonner-toast] [data-button]:focus-visible {
199
193
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4);
200
194
  }
201
195
 
202
- :where([data-sonner-toast]) :where([data-button]):first-of-type {
196
+ [data-sonner-toast] [data-button]:first-of-type {
203
197
  margin-left: var(--toast-button-margin-start);
204
198
  margin-right: var(--toast-button-margin-end);
205
199
  }
206
200
 
207
- :where([data-sonner-toast]) :where([data-cancel]) {
201
+ [data-sonner-toast] [data-cancel] {
208
202
  color: var(--normal-text);
209
203
  background: rgba(0, 0, 0, 0.08);
210
204
  }
211
205
 
212
- :where([data-sonner-toast][data-theme='dark']) :where([data-cancel]) {
206
+ [data-sonner-toaster][data-sonner-theme='dark'] [data-cancel] {
213
207
  background: rgba(255, 255, 255, 0.3);
214
208
  }
215
209
 
216
- :where([data-sonner-toast]) :where([data-close-button]) {
210
+ [data-sonner-toast] [data-close-button] {
217
211
  position: absolute;
218
212
  left: var(--toast-close-button-start);
219
213
  right: var(--toast-close-button-end);
@@ -233,55 +227,46 @@
233
227
  transition: opacity 100ms, background 200ms, border-color 200ms;
234
228
  }
235
229
 
236
- [data-sonner-toast] [data-close-button] {
237
- background: var(--gray1);
238
- }
239
-
240
- :where([data-sonner-toast]) :where([data-close-button]):focus-visible {
230
+ [data-sonner-toast] [data-close-button]:focus-visible {
241
231
  box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1), 0 0 0 2px rgba(0, 0, 0, 0.2);
242
232
  }
243
233
 
244
- :where([data-sonner-toast]) :where([data-disabled='true']) {
234
+ [data-sonner-toast] [data-disabled='true'] {
245
235
  cursor: not-allowed;
246
236
  }
247
237
 
248
- :where([data-sonner-toast]):hover :where([data-close-button]):hover {
238
+ [data-sonner-toast]:hover [data-close-button]:hover {
249
239
  background: var(--gray2);
250
240
  border-color: var(--gray5);
251
241
  }
252
242
 
253
- /* Leave a ghost div to avoid setting hover to false when swiping out */
254
- :where([data-sonner-toast][data-swiping='true'])::before {
243
+ [data-sonner-toast][data-swiping='true']::before {
255
244
  content: '';
256
245
  position: absolute;
257
- left: -50%;
258
- right: -50%;
246
+ left: -100%;
247
+ right: -100%;
259
248
  height: 100%;
260
249
  z-index: -1;
261
250
  }
262
251
 
263
- :where([data-sonner-toast][data-y-position='top'][data-swiping='true'])::before {
264
- /* y 50% needed to distribute height additional height evenly */
252
+ [data-sonner-toast][data-y-position='top'][data-swiping='true']::before {
265
253
  bottom: 50%;
266
254
  transform: scaleY(3) translateY(50%);
267
255
  }
268
256
 
269
- :where([data-sonner-toast][data-y-position='bottom'][data-swiping='true'])::before {
270
- /* y -50% needed to distribute height additional height evenly */
257
+ [data-sonner-toast][data-y-position='bottom'][data-swiping='true']::before {
271
258
  top: 50%;
272
259
  transform: scaleY(3) translateY(-50%);
273
260
  }
274
261
 
275
- /* Leave a ghost div to avoid setting hover to false when transitioning out */
276
- :where([data-sonner-toast][data-swiping='false'][data-removed='true'])::before {
262
+ [data-sonner-toast][data-swiping='false'][data-removed='true']::before {
277
263
  content: '';
278
264
  position: absolute;
279
265
  inset: 0;
280
266
  transform: scaleY(2);
281
267
  }
282
268
 
283
- /* Needed to avoid setting hover to false when inbetween toasts */
284
- :where([data-sonner-toast])::after {
269
+ [data-sonner-toast]::after {
285
270
  content: '';
286
271
  position: absolute;
287
272
  left: 0;
@@ -290,53 +275,60 @@
290
275
  width: 100%;
291
276
  }
292
277
 
293
- :where([data-sonner-toast][data-mounted='true']) {
278
+ [data-sonner-toast][data-mounted='true'] {
294
279
  --y: translateY(0);
295
280
  opacity: 1;
296
281
  }
297
282
 
298
- :where([data-sonner-toast][data-expanded='false'][data-front='false']) {
283
+ [data-sonner-toast][data-expanded='false'][data-front='false'] {
299
284
  --scale: var(--toasts-before) * 0.05 + 1;
300
285
  --y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));
301
286
  height: var(--front-toast-height);
302
287
  }
303
288
 
304
- :where([data-sonner-toast]) > * {
289
+ [data-sonner-toast] > * {
305
290
  transition: opacity 400ms;
306
291
  }
307
292
 
308
- :where([data-sonner-toast][data-expanded='false'][data-front='false'][data-styled='true']) > * {
293
+ [data-sonner-toast][data-x-position='right'] {
294
+ right: 0;
295
+ }
296
+
297
+ [data-sonner-toast][data-x-position='left'] {
298
+ left: 0;
299
+ }
300
+
301
+ [data-sonner-toast][data-expanded='false'][data-front='false'][data-styled='true'] > * {
309
302
  opacity: 0;
310
303
  }
311
304
 
312
- :where([data-sonner-toast][data-visible='false']) {
305
+ [data-sonner-toast][data-visible='false'] {
313
306
  opacity: 0;
314
307
  pointer-events: none;
315
308
  }
316
309
 
317
- :where([data-sonner-toast][data-mounted='true'][data-expanded='true']) {
310
+ [data-sonner-toast][data-mounted='true'][data-expanded='true'] {
318
311
  --y: translateY(calc(var(--lift) * var(--offset)));
319
312
  height: var(--initial-height);
320
313
  }
321
314
 
322
- :where([data-sonner-toast][data-removed='true'][data-front='true'][data-swipe-out='false']) {
315
+ [data-sonner-toast][data-removed='true'][data-front='true'][data-swipe-out='false'] {
323
316
  --y: translateY(calc(var(--lift) * -100%));
324
317
  opacity: 0;
325
318
  }
326
319
 
327
- :where([data-sonner-toast][data-removed='true'][data-front='false'][data-swipe-out='false'][data-expanded='true']) {
320
+ [data-sonner-toast][data-removed='true'][data-front='false'][data-swipe-out='false'][data-expanded='true'] {
328
321
  --y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));
329
322
  opacity: 0;
330
323
  }
331
324
 
332
- :where([data-sonner-toast][data-removed='true'][data-front='false'][data-swipe-out='false'][data-expanded='false']) {
325
+ [data-sonner-toast][data-removed='true'][data-front='false'][data-swipe-out='false'][data-expanded='false'] {
333
326
  --y: translateY(40%);
334
327
  opacity: 0;
335
328
  transition: transform 500ms, opacity 200ms;
336
329
  }
337
330
 
338
- /* Bump up the height to make sure hover state doesn't get set to false */
339
- :where([data-sonner-toast][data-removed='true'][data-front='false'])::before {
331
+ [data-sonner-toast][data-removed='true'][data-front='false']::before {
340
332
  height: calc(var(--initial-height) + 20%);
341
333
  }
342
334
 
@@ -457,21 +449,21 @@
457
449
  }
458
450
  }
459
451
 
460
- [data-sonner-toaster][data-theme='light'] {
452
+ [data-sonner-toaster][data-sonner-theme='light'] {
461
453
  --normal-bg: #fff;
462
454
  --normal-border: var(--gray4);
463
455
  --normal-text: var(--gray12);
464
456
 
465
457
  --success-bg: hsl(143, 85%, 96%);
466
- --success-border: hsl(145, 92%, 91%);
458
+ --success-border: hsl(145, 92%, 87%);
467
459
  --success-text: hsl(140, 100%, 27%);
468
460
 
469
461
  --info-bg: hsl(208, 100%, 97%);
470
- --info-border: hsl(221, 91%, 91%);
462
+ --info-border: hsl(221, 91%, 93%);
471
463
  --info-text: hsl(210, 92%, 45%);
472
464
 
473
465
  --warning-bg: hsl(49, 100%, 97%);
474
- --warning-border: hsl(49, 91%, 91%);
466
+ --warning-border: hsl(49, 91%, 84%);
475
467
  --warning-text: hsl(31, 92%, 45%);
476
468
 
477
469
  --error-bg: hsl(359, 100%, 97%);
@@ -479,19 +471,19 @@
479
471
  --error-text: hsl(360, 100%, 45%);
480
472
  }
481
473
 
482
- [data-sonner-toaster][data-theme='light'] [data-sonner-toast][data-invert='true'] {
474
+ [data-sonner-toaster][data-sonner-theme='light'] [data-sonner-toast][data-invert='true'] {
483
475
  --normal-bg: #000;
484
476
  --normal-border: hsl(0, 0%, 20%);
485
477
  --normal-text: var(--gray1);
486
478
  }
487
479
 
488
- [data-sonner-toaster][data-theme='dark'] [data-sonner-toast][data-invert='true'] {
480
+ [data-sonner-toaster][data-sonner-theme='dark'] [data-sonner-toast][data-invert='true'] {
489
481
  --normal-bg: #fff;
490
482
  --normal-border: var(--gray3);
491
483
  --normal-text: var(--gray12);
492
484
  }
493
485
 
494
- [data-sonner-toaster][data-theme='dark'] {
486
+ [data-sonner-toaster][data-sonner-theme='dark'] {
495
487
  --normal-bg: #000;
496
488
  --normal-bg-hover: hsl(0, 0%, 12%);
497
489
  --normal-border: hsl(0, 0%, 20%);
@@ -503,11 +495,11 @@
503
495
  --success-text: hsl(150, 86%, 65%);
504
496
 
505
497
  --info-bg: hsl(215, 100%, 6%);
506
- --info-border: hsl(223, 100%, 12%);
498
+ --info-border: hsl(223, 43%, 17%);
507
499
  --info-text: hsl(216, 87%, 65%);
508
500
 
509
501
  --warning-bg: hsl(64, 100%, 6%);
510
- --warning-border: hsl(60, 100%, 12%);
502
+ --warning-border: hsl(60, 100%, 9%);
511
503
  --warning-text: hsl(46, 87%, 65%);
512
504
 
513
505
  --error-bg: hsl(358, 76%, 10%);
@@ -515,13 +507,13 @@
515
507
  --error-text: hsl(358, 100%, 81%);
516
508
  }
517
509
 
518
- [data-sonner-toaster][data-theme='dark'] [data-sonner-toast] [data-close-button] {
510
+ [data-sonner-toaster][data-sonner-theme='dark'] [data-sonner-toast] [data-close-button] {
519
511
  background: var(--normal-bg);
520
512
  border-color: var(--normal-border);
521
513
  color: var(--normal-text);
522
514
  }
523
515
 
524
- [data-sonner-toaster][data-theme='dark'] [data-sonner-toast] [data-close-button]:hover {
516
+ [data-sonner-toaster][data-sonner-theme='dark'] [data-sonner-toast] [data-close-button]:hover {
525
517
  background: var(--normal-bg-hover);
526
518
  border-color: var(--normal-border-hover);
527
519
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sonner",
3
- "version": "1.7.4",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "An opinionated toast component for React.",
5
5
  "exports": {
6
6
  ".": {