瀏覽代碼

fix(tui): style destructive dialog actions

Kit Langton 1 周之前
父節點
當前提交
4a7e5a3897

+ 1 - 0
packages/tui/src/component/dialog-mcp.tsx

@@ -128,6 +128,7 @@ export function DialogMcp() {
               {
                 title: toggleTitle(),
                 command: "dialog.mcp.toggle",
+                variant: toggleTitle() === "disconnect" ? "destructive" : "primary",
                 onTrigger: (option) => {
                   setFocused(option.value as string)
                   toggle(option.value as string)

+ 1 - 0
packages/tui/src/component/dialog-move-session.tsx

@@ -372,6 +372,7 @@ export function DialogMoveSession(props: DialogMoveSessionProps) {
                 {
                   command: "dialog.move_session.delete",
                   title: "delete",
+                  variant: "destructive",
                   disabled: (option) => {
                     const value = option?.value
                     if (!value || value.type !== "directory" || value.subdirectory) return true

+ 1 - 0
packages/tui/src/component/dialog-session-list.tsx

@@ -236,6 +236,7 @@ export function DialogSessionList() {
         {
           command: "session.delete",
           title: "delete",
+          variant: "destructive",
           onTrigger: (option: { value: string }) => {
             if (toDelete() !== option.value) {
               setToDelete(option.value)

+ 1 - 0
packages/tui/src/component/dialog-stash.tsx

@@ -75,6 +75,7 @@ export function DialogStash(props: { onSelect: (entry: StashEntry) => void }) {
         {
           command: "stash.delete",
           title: "delete",
+          variant: "destructive",
           onTrigger: (option) => {
             if (toDelete() === option.value) {
               stash.remove(option.value)

+ 10 - 6
packages/tui/src/ui/dialog-select.tsx

@@ -45,6 +45,7 @@ export interface DialogSelectProps<T> {
 type DialogSelectActionBase<T> = {
   command: string
   title: string
+  variant?: "primary" | "destructive"
   side?: "left" | "right"
   hidden?: boolean
   disabled?: boolean | ((option: DialogSelectOption<T> | undefined) => boolean)
@@ -551,19 +552,22 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
     const item = action.item
     const active = createMemo(() => isActionFocused(item))
     const disabled = createMemo(() => isActionDisabled(item))
+    const variant = () => item.variant ?? "primary"
     return (
       <box
         flexDirection="row"
-        backgroundColor={active() ? theme.background.action.primary.focused : RGBA.fromInts(0, 0, 0, 0)}
+        backgroundColor={active() ? theme.background.action[variant()].focused : RGBA.fromInts(0, 0, 0, 0)}
         onMouseUp={() => trigger(item)}
       >
         <text
           fg={
             disabled()
-              ? theme.text.action.primary.disabled
+              ? theme.text.action[variant()].disabled
               : active()
-                ? theme.text.action.primary.focused
-                : theme.text.default
+                ? theme.text.action[variant()].focused
+                : variant() === "destructive"
+                  ? theme.text.action.destructive.default
+                  : theme.text.default
           }
           attributes={active() ? TextAttributes.BOLD : undefined}
         >
@@ -572,9 +576,9 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
         <text
           fg={
             disabled()
-              ? theme.text.action.primary.disabled
+              ? theme.text.action[variant()].disabled
               : active()
-                ? theme.text.action.primary.focused
+                ? theme.text.action[variant()].focused
                 : theme.text.subdued
           }
         >