sonner 1.7.3 → 2.0.0-beta.0

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