@marv3l/canopy-ui 1.2.3 → 1.2.5
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 +1 -1
- package/package.json +1 -1
- package/templates/toast/toast.tsx +13 -7
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -181,12 +181,10 @@ function ToastElement({
|
|
|
181
181
|
const startTimeRef = React.useRef<number>(0);
|
|
182
182
|
const timerRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
183
183
|
|
|
184
|
-
// Update remaining ref on prop changes without triggering synchronous setState re-renders
|
|
185
184
|
React.useEffect(() => {
|
|
186
185
|
remainingTimeRef.current = activeDuration;
|
|
187
186
|
}, [toast.variant, toast.title, toast.count, activeDuration]);
|
|
188
187
|
|
|
189
|
-
// Handle countdown timeout
|
|
190
188
|
React.useEffect(() => {
|
|
191
189
|
if (!isAutoDismissible || isPaused) {
|
|
192
190
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
@@ -225,8 +223,10 @@ function ToastElement({
|
|
|
225
223
|
if (toast.customColor?.border) customInlineStyle.borderColor = toast.customColor.border;
|
|
226
224
|
if (toast.customColor?.text) customInlineStyle.color = toast.customColor.text;
|
|
227
225
|
|
|
226
|
+
// Check if custom colors or custom tailwind classes exist
|
|
228
227
|
const userHasBg = Boolean(toast.customColor?.bg || toast.className?.match(/(?:^|\s)bg-/));
|
|
229
228
|
const userHasBorder = Boolean(toast.customColor?.border || toast.className?.match(/(?:^|\s)border-/));
|
|
229
|
+
const userHasText = Boolean(toast.customColor?.text || toast.className?.match(/(?:^|\s)text-/));
|
|
230
230
|
|
|
231
231
|
const isError = variant === "error";
|
|
232
232
|
|
|
@@ -246,7 +246,7 @@ function ToastElement({
|
|
|
246
246
|
) : (
|
|
247
247
|
IconComponent && (
|
|
248
248
|
<IconComponent
|
|
249
|
-
className={`w-5 h-5 mt-0.5 shrink-0 ${defaultStyle.iconColor}`}
|
|
249
|
+
className={`w-5 h-5 mt-0.5 shrink-0 ${!toast.customColor?.icon ? defaultStyle.iconColor : ""}`}
|
|
250
250
|
style={{ color: toast.customColor?.icon }}
|
|
251
251
|
/>
|
|
252
252
|
)
|
|
@@ -256,7 +256,11 @@ function ToastElement({
|
|
|
256
256
|
<div className="flex-1 text-sm">
|
|
257
257
|
<div className="flex items-center gap-2">
|
|
258
258
|
{toast.title && (
|
|
259
|
-
<div
|
|
259
|
+
<div
|
|
260
|
+
className={`font-semibold leading-tight tracking-tight ${
|
|
261
|
+
!userHasText ? defaultStyle.title : ""
|
|
262
|
+
}`}
|
|
263
|
+
>
|
|
260
264
|
{toast.title}
|
|
261
265
|
</div>
|
|
262
266
|
)}
|
|
@@ -289,7 +293,9 @@ function ToastElement({
|
|
|
289
293
|
>
|
|
290
294
|
<div className="overflow-hidden">
|
|
291
295
|
<div
|
|
292
|
-
className={`leading-relaxed text-xs pt-1 opacity-0 font-normal ${
|
|
296
|
+
className={`leading-relaxed text-xs pt-1 opacity-0 font-normal ${
|
|
297
|
+
!userHasText ? defaultStyle.description : "opacity-90"
|
|
298
|
+
}`}
|
|
293
299
|
style={{
|
|
294
300
|
animation: "toast-fade-in 200ms ease-out 250ms forwards",
|
|
295
301
|
}}
|
|
@@ -306,7 +312,7 @@ function ToastElement({
|
|
|
306
312
|
<button
|
|
307
313
|
onClick={onDismiss}
|
|
308
314
|
aria-label="Close toast"
|
|
309
|
-
className="p-1 rounded-md opacity-70 hover:opacity-100 hover:bg-neutral-500/15 dark:hover:bg-white/10 transition-colors text-
|
|
315
|
+
className="p-1 rounded-md opacity-70 hover:opacity-100 hover:bg-neutral-500/15 dark:hover:bg-white/10 transition-colors text-inherit"
|
|
310
316
|
>
|
|
311
317
|
<X className="w-4 h-4" />
|
|
312
318
|
</button>
|
|
@@ -327,4 +333,4 @@ function ToastElement({
|
|
|
327
333
|
)}
|
|
328
334
|
</div>
|
|
329
335
|
);
|
|
330
|
-
}
|
|
336
|
+
}
|