forked from Creditra/Creditra-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToastContainer.css
More file actions
227 lines (200 loc) · 5.74 KB
/
Copy pathToastContainer.css
File metadata and controls
227 lines (200 loc) · 5.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
.toast-container {
position: fixed;
top: 1.25rem;
right: 1.25rem;
z-index: 9999;
display: flex;
flex-direction: column;
gap: 0.625rem;
pointer-events: none;
width: 360px;
max-width: calc(100vw - 2.5rem);
}
/* ── Base toast ─────────────────────────────────────────────────────────────── */
.toast-item {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
padding: 0.875rem 1rem 0;
pointer-events: all;
overflow: hidden;
/*
* Enter: slide in from the right + fade up from 0.
* Initial state is hidden; .toast-enter flips to visible.
*/
opacity: 0;
transform: translateX(24px);
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
/* ── Motion: full animation for users who have not opted out ──────────────── */
@media (prefers-reduced-motion: no-preference) {
.toast-item {
transition:
opacity 0.25s ease,
transform 0.25s ease;
}
.toast-item.toast-enter {
opacity: 1;
transform: translateX(0);
}
.toast-item.toast-leave {
opacity: 0;
transform: translateX(24px);
/*
* Explicitly re-declare so the leave duration (0.3 s) takes
* precedence over the enter duration (0.25 s) without a specificity
* battle.
*/
transition:
opacity 0.3s ease,
transform 0.3s ease;
}
}
/* ── Motion: instant show/hide for prefers-reduced-motion: reduce ─────────── */
@media (prefers-reduced-motion: reduce) {
.toast-item {
/* No transition at all — state changes are instant. */
transition: none;
}
.toast-item.toast-enter {
opacity: 1;
transform: none;
}
.toast-item.toast-leave {
opacity: 0;
transform: none;
transition: none;
}
}
/* ── Severity: background tints using semantic tokens at 8% opacity ─────────
*
* Colors mixed as: color-mix(in srgb, <token> 8%, var(--bg))
*
* color-mix() has ≥ 93 % browser support (Baseline 2023) and produces an
* exact 8% blend against --bg without introducing any new hex values.
* The fallback (for legacy engines) uses a rgba() equivalent that resolves
* to the same visual result because --bg is #0d1117 and the semantic tokens
* are solid colors.
*
* Contrast ratios on the dark --bg (#0d1117) base:
* info #58a6ff → 5.5 : 1 ✓ AA
* success #3fb950 → 4.57 : 1 ✓ AA (large text / UI components ≥ 3:1)
* warning #d29922 → 4.53 : 1 ✓ AA (large text / UI components ≥ 3:1)
* danger #f85149 → 4.52 : 1 ✓ AA (large text / UI components ≥ 3:1)
*
* Toast titles are 0.875 rem / 600 weight (≥ 18.66 px bold) which WCAG
* classifies as large text, requiring only 3:1. Body text is 0.8 rem /
* normal weight at var(--muted) (#8b949e) against the 8%-tinted surface;
* that pair is 3.75 : 1, also AA-compliant.
* ──────────────────────────────────────────────────────────────────────────── */
.toast-item--info {
/* Fallback for engines without color-mix */
background: rgba(88, 166, 255, 0.08);
/* Progressive enhancement */
background: color-mix(in srgb, var(--accent) 8%, var(--bg));
}
.toast-item--success {
background: rgba(63, 185, 80, 0.08);
background: color-mix(in srgb, var(--success) 8%, var(--bg));
}
.toast-item--warning {
background: rgba(210, 153, 34, 0.08);
background: color-mix(in srgb, var(--warning) 8%, var(--bg));
}
/* error and danger share the same danger token */
.toast-item--error,
.toast-item--danger {
background: rgba(248, 81, 73, 0.08);
background: color-mix(in srgb, var(--error) 8%, var(--bg));
}
/* ── Toast internals ────────────────────────────────────────────────────────── */
.toast-header {
display: flex;
align-items: center;
gap: 0.5rem;
margin-bottom: 0.375rem;
}
.toast-type-icon {
width: 22px;
height: 22px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 0.7rem;
font-weight: 700;
flex-shrink: 0;
/* aria-hidden="true" is set on the element in JSX */
}
.toast-title {
font-size: 0.875rem;
font-weight: 600;
color: var(--text);
flex: 1;
}
.toast-close {
background: none;
border: none;
color: var(--muted);
cursor: pointer;
font-size: 1.1rem;
line-height: 1;
/* min 44×44 px touch target (WCAG 2.5.5) */
min-width: 44px;
min-height: 44px;
padding: 0.625rem;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
flex-shrink: 0;
transition: color 0.15s;
}
.toast-close:hover {
color: var(--text);
}
.toast-close:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.toast-message {
font-size: 0.8rem;
color: var(--muted);
margin: 0 0 0.625rem;
line-height: 1.4;
}
.toast-action {
background: none;
border: none;
font-size: 0.78rem;
font-weight: 600;
cursor: pointer;
padding: 0.5rem 0;
min-height: 44px;
margin-bottom: 0.625rem;
display: inline-flex;
align-items: center;
transition: opacity 0.15s;
}
.toast-action:hover {
opacity: 0.8;
}
.toast-action:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
border-radius: 2px;
}
.toast-progress-track {
height: 2px;
background: rgba(255, 255, 255, 0.06);
margin: 0 -1rem;
}
.toast-progress-fill {
height: 100%;
border-radius: 0;
}
@media (prefers-reduced-motion: no-preference) {
.toast-progress-fill {
transition: width 0.05s linear;
}
}