|
1 | 1 | import { Show } from "solid-js"; |
2 | | -import { AlertTriangle, RefreshCcw } from "lucide-solid"; |
| 2 | +import { AlertTriangle, RefreshCcw, X } from "lucide-solid"; |
3 | 3 |
|
4 | 4 | import Button from "./button"; |
5 | 5 |
|
6 | 6 | export type ReloadWorkspaceToastProps = { |
7 | 7 | open: boolean; |
8 | 8 | title: string; |
9 | 9 | description: string; |
10 | | - warning: string; |
| 10 | + warning?: string; |
11 | 11 | blockedReason?: string | null; |
12 | 12 | error?: string | null; |
13 | 13 | reloadLabel: string; |
14 | 14 | dismissLabel: string; |
15 | 15 | busy?: boolean; |
16 | 16 | canReload: boolean; |
| 17 | + hasActiveRuns: boolean; |
17 | 18 | onReload: () => void; |
18 | 19 | onDismiss: () => void; |
19 | 20 | }; |
20 | 21 |
|
21 | 22 | export default function ReloadWorkspaceToast(props: ReloadWorkspaceToastProps) { |
22 | 23 | return ( |
23 | 24 | <Show when={props.open}> |
24 | | - <div class="fixed top-6 right-6 z-50 w-[min(420px,calc(100vw-2rem))]"> |
25 | | - <div class="rounded-2xl border border-gray-6/70 bg-gray-1/95 p-4 shadow-xl backdrop-blur animate-in fade-in slide-in-from-top-11 duration-200"> |
26 | | - <div class="flex items-start gap-3"> |
27 | | - <div class="mt-0.5 flex h-9 w-9 items-center justify-center rounded-full border border-amber-7/30 bg-amber-7/10 text-amber-11"> |
28 | | - <RefreshCcw size={16} /> |
29 | | - </div> |
30 | | - <div class="flex-1 space-y-2"> |
31 | | - <div> |
32 | | - <div class="text-sm font-semibold text-gray-12">{props.title}</div> |
33 | | - <div class="text-xs text-gray-10">{props.description}</div> |
34 | | - </div> |
35 | | - <div class="text-xs text-gray-10">{props.warning}</div> |
36 | | - <Show when={props.blockedReason}> |
37 | | - <div class="flex items-start gap-2 rounded-lg border border-amber-7/30 bg-amber-7/10 px-3 py-2 text-xs text-amber-11"> |
38 | | - <AlertTriangle size={14} class="mt-0.5 shrink-0" /> |
39 | | - <span>{props.blockedReason}</span> |
40 | | - </div> |
41 | | - </Show> |
42 | | - <Show when={props.error}> |
43 | | - <div class="rounded-lg border border-red-7/30 bg-red-7/10 px-3 py-2 text-xs text-red-11"> |
44 | | - {props.error} |
45 | | - </div> |
| 25 | + <div class="fixed top-6 left-1/2 -translate-x-1/2 z-50 w-[min(480px,calc(100vw-2rem))]"> |
| 26 | + <div |
| 27 | + class=" |
| 28 | + flex items-center gap-3 p-2 pr-3 rounded-full |
| 29 | + border border-gray-6/50 bg-gray-2/95 shadow-xl backdrop-blur-md |
| 30 | + animate-in fade-in slide-in-from-top-4 duration-300 |
| 31 | + " |
| 32 | + > |
| 33 | + {/* Icon Circle */} |
| 34 | + <div class={` |
| 35 | + flex h-9 w-9 shrink-0 items-center justify-center rounded-full |
| 36 | + ${props.hasActiveRuns ? 'bg-amber-3 text-amber-11' : 'bg-blue-3 text-blue-11'} |
| 37 | + `}> |
| 38 | + <RefreshCcw size={16} class={props.busy ? "animate-spin" : ""} /> |
| 39 | + </div> |
| 40 | + |
| 41 | + {/* Text Content */} |
| 42 | + <div class="flex-1 min-w-0 flex flex-col justify-center"> |
| 43 | + <div class="flex items-center gap-2"> |
| 44 | + <span class="text-sm font-medium text-gray-12 truncate"> |
| 45 | + {props.title} |
| 46 | + </span> |
| 47 | + <Show when={props.hasActiveRuns}> |
| 48 | + <span class="inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider bg-amber-4 text-amber-11"> |
| 49 | + Active Tasks |
| 50 | + </span> |
46 | 51 | </Show> |
47 | 52 | </div> |
| 53 | + |
| 54 | + <Show when={props.description}> |
| 55 | + <div class="text-xs text-gray-10 truncate leading-none mt-0.5"> |
| 56 | + {props.hasActiveRuns |
| 57 | + ? <span class="text-amber-11 font-medium">Reloading will stop active tasks.</span> |
| 58 | + : props.description |
| 59 | + } |
| 60 | + </div> |
| 61 | + </Show> |
48 | 62 | </div> |
49 | | - <div class="mt-3 flex justify-end gap-2"> |
50 | | - <Button |
51 | | - variant="ghost" |
52 | | - class="h-8 px-3 text-xs" |
| 63 | + |
| 64 | + {/* Actions */} |
| 65 | + <div class="flex items-center gap-2 shrink-0 pl-2 border-l border-gray-5/50"> |
| 66 | + <button |
53 | 67 | onClick={() => props.onDismiss()} |
54 | | - disabled={props.busy} |
| 68 | + class="px-2 py-1.5 text-xs font-medium text-gray-10 hover:text-gray-12 transition-colors" |
55 | 69 | > |
56 | 70 | {props.dismissLabel} |
57 | | - </Button> |
| 71 | + </button> |
58 | 72 | <Button |
59 | | - variant="secondary" |
60 | | - class="h-8 px-3 text-xs" |
| 73 | + variant={props.hasActiveRuns ? "danger" : "primary"} |
| 74 | + class="h-7 px-3 text-xs rounded-full font-medium" |
61 | 75 | onClick={() => props.onReload()} |
62 | | - disabled={!props.canReload} |
| 76 | + disabled={props.busy || !props.canReload} |
63 | 77 | > |
64 | 78 | {props.reloadLabel} |
65 | 79 | </Button> |
|
0 commit comments