Browse Source

wip(desktop): progress

Adam 2 months ago
parent
commit
6866a060bc

+ 1 - 1
packages/desktop/src/components/prompt-input.tsx

@@ -488,7 +488,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
               {(i) => (
                 <div class="w-full flex items-center justify-between gap-x-3">
                   <div class="flex items-center gap-x-2.5 text-text-muted grow min-w-0">
-                    <ProviderIcon name={i.provider.id as IconName} class="size-6 p-0.5 shrink-0" />
+                    {/* <ProviderIcon name={i.provider.id as IconName} class="size-6 p-0.5 shrink-0" /> */}
                     <div class="flex gap-x-3 items-baseline flex-[1_0_0]">
                       <span class="text-14-medium text-text-strong overflow-hidden text-ellipsis">{i.name}</span>
                       <Show when={false}>

+ 6 - 5
packages/ui/src/components/dialog.css

@@ -36,14 +36,14 @@
       flex-direction: column;
       align-items: flex-start;
       align-self: stretch;
-      gap: 8px;
       width: 100%;
       max-height: 100%;
+      min-height: 280px;
 
       /* padding: 8px; */
-      padding: 8px 8px 0 8px;
+      /* padding: 8px 8px 0 8px; */
       border: 1px solid var(--border-base);
-      border-radius: var(--radius-md);
+      border-radius: var(--radius-xl);
       background: var(--surface-raised-stronger-non-alpha);
       box-shadow:
         0 15px 45px 0 rgba(19, 16, 16, 0.22),
@@ -58,8 +58,9 @@
 
       [data-slot="dialog-header"] {
         display: flex;
-        height: 40px;
-        padding: 4px 4px 4px 8px;
+        /* height: 40px; */
+        /* padding: 4px 4px 4px 8px; */
+        padding: 20px;
         justify-content: space-between;
         align-items: center;
         flex-shrink: 0;

+ 1 - 1
packages/ui/src/components/dialog.tsx

@@ -79,7 +79,7 @@ function DialogDescription(props: DialogDescriptionProps & ComponentProps<"p">)
 }
 
 function DialogCloseButton(props: DialogCloseButtonProps & ComponentProps<"button">) {
-  return <Kobalte.CloseButton data-slot="dialog-close-button" as={IconButton} icon="close" {...props} />
+  return <Kobalte.CloseButton data-slot="dialog-close-button" as={IconButton} icon="close" variant="ghost" {...props} />
 }
 
 export const Dialog = Object.assign(DialogRoot, {

+ 2 - 0
packages/ui/src/components/input.css

@@ -1,7 +1,9 @@
 [data-component="input"] {
+  width: 100%;
   /* [data-slot="input-label"] {} */
 
   [data-slot="input-input"] {
+    width: 100%;
     color: var(--text-strong);
 
     /* text-14-regular */

+ 21 - 7
packages/ui/src/components/select-dialog.css

@@ -1,3 +1,12 @@
+[data-slot="select-dialog-content"] {
+  width: 100%;
+  display: flex;
+  flex-direction: column;
+  overflow: hidden;
+  gap: 12px;
+  padding: 0 10px;
+}
+
 [data-component="select-dialog-input"] {
   display: flex;
   height: 40px;
@@ -29,11 +38,11 @@
 [data-component="select-dialog"] {
   display: flex;
   flex-direction: column;
-  gap: 8px;
+  gap: 12px;
 
   [data-slot="select-dialog-empty-state"] {
     display: flex;
-    padding: 32px 160px;
+    padding: 32px 0px;
     flex-direction: column;
     justify-content: center;
     align-items: center;
@@ -63,25 +72,30 @@
   }
 
   [data-slot="select-dialog-group"] {
+    position: relative;
     display: flex;
     flex-direction: column;
     gap: 4px;
 
     [data-slot="select-dialog-header"] {
       display: flex;
-      padding: 4px 8px;
+      height: 28px;
+      padding: 0 10px;
       justify-content: space-between;
       align-items: center;
       align-self: stretch;
+      background: var(--surface-raised-stronger-non-alpha);
+      position: sticky;
+      top: 0;
 
-      color: var(--text-weak);
+      color: var(--text-base);
 
-      /* text-12-medium */
+      /* text-14-medium */
       font-family: var(--font-family-sans);
-      font-size: var(--font-size-small);
+      font-size: 14px;
       font-style: normal;
       font-weight: var(--font-weight-medium);
-      line-height: var(--line-height-large); /* 166.667% */
+      line-height: var(--line-height-large); /* 142.857% */
       letter-spacing: var(--letter-spacing-normal);
     }
 

+ 71 - 67
packages/ui/src/components/select-dialog.tsx

@@ -20,6 +20,7 @@ interface SelectDialogProps<T>
 export function SelectDialog<T>(props: SelectDialogProps<T>) {
   const [dialog, others] = splitProps(props, ["trigger", "onOpenChange", "defaultOpen"])
   let closeButton!: HTMLButtonElement
+  let inputRef: HTMLInputElement | undefined
   let scrollRef: HTMLDivElement | undefined
   const [store, setStore] = createStore({
     mouseActive: false,
@@ -87,77 +88,80 @@ export function SelectDialog<T>(props: SelectDialogProps<T>) {
     <Dialog modal {...dialog} onOpenChange={handleOpenChange}>
       <Dialog.Header>
         <Dialog.Title>{others.title}</Dialog.Title>
-        <Dialog.CloseButton ref={closeButton} style={{ display: "none" }} />
+        <Dialog.CloseButton ref={closeButton} tabIndex={-1} />
       </Dialog.Header>
-      <div data-component="select-dialog-input">
-        <div data-slot="select-dialog-input-container">
-          <Icon name="magnifying-glass" />
-          <Input
-            data-slot="select-dialog-input"
-            type="text"
-            value={filter()}
-            onChange={(value) => handleInput(value)}
-            onKeyDown={handleKey}
-            placeholder={others.placeholder}
-            autofocus
-            spellcheck={false}
-            autocorrect="off"
-            autocomplete="off"
-            autocapitalize="off"
-          />
+      <div data-slot="select-dialog-content">
+        <div data-component="select-dialog-input">
+          <div data-slot="select-dialog-input-container">
+            <Icon name="magnifying-glass" />
+            <Input
+              ref={inputRef}
+              autofocus
+              data-slot="select-dialog-input"
+              type="text"
+              value={filter()}
+              onChange={(value) => handleInput(value)}
+              onKeyDown={handleKey}
+              placeholder={others.placeholder}
+              spellcheck={false}
+              autocorrect="off"
+              autocomplete="off"
+              autocapitalize="off"
+            />
+          </div>
+          <Show when={filter()}>
+            <IconButton
+              icon="circle-x"
+              variant="ghost"
+              onClick={() => {
+                onInput("")
+                reset()
+              }}
+            />
+          </Show>
         </div>
-        <Show when={filter()}>
-          <IconButton
-            icon="circle-x"
-            variant="ghost"
-            onClick={() => {
-              onInput("")
-              reset()
-            }}
-          />
-        </Show>
-      </div>
-      <Dialog.Body ref={scrollRef} data-component="select-dialog" class="no-scrollbar">
-        <Show
-          when={flat().length > 0}
-          fallback={
-            <div data-slot="select-dialog-empty-state">
-              <div data-slot="select-dialog-message">
-                {props.emptyMessage ?? "No search results"} for{" "}
-                <span data-slot="select-dialog-filter">&quot;{filter()}&quot;</span>
-              </div>
-            </div>
-          }
-        >
-          <For each={grouped()}>
-            {(group) => (
-              <div data-slot="select-dialog-group">
-                <Show when={group.category}>
-                  <div data-slot="select-dialog-header">{group.category}</div>
-                </Show>
-                <div data-slot="select-dialog-list">
-                  <For each={group.items}>
-                    {(item) => (
-                      <button
-                        data-slot="select-dialog-item"
-                        data-key={others.key(item)}
-                        data-active={others.key(item) === active()}
-                        onClick={() => handleSelect(item)}
-                        onMouseMove={() => {
-                          setStore("mouseActive", true)
-                          setActive(others.key(item))
-                        }}
-                      >
-                        {others.children(item)}
-                      </button>
-                    )}
-                  </For>
+        <Dialog.Body ref={scrollRef} data-component="select-dialog" class="no-scrollbar">
+          <Show
+            when={flat().length > 0}
+            fallback={
+              <div data-slot="select-dialog-empty-state">
+                <div data-slot="select-dialog-message">
+                  {props.emptyMessage ?? "No search results"} for{" "}
+                  <span data-slot="select-dialog-filter">&quot;{filter()}&quot;</span>
                 </div>
               </div>
-            )}
-          </For>
-        </Show>
-      </Dialog.Body>
+            }
+          >
+            <For each={grouped()}>
+              {(group) => (
+                <div data-slot="select-dialog-group">
+                  <Show when={group.category}>
+                    <div data-slot="select-dialog-header">{group.category}</div>
+                  </Show>
+                  <div data-slot="select-dialog-list">
+                    <For each={group.items}>
+                      {(item) => (
+                        <button
+                          data-slot="select-dialog-item"
+                          data-key={others.key(item)}
+                          data-active={others.key(item) === active()}
+                          onClick={() => handleSelect(item)}
+                          onMouseMove={() => {
+                            setStore("mouseActive", true)
+                            setActive(others.key(item))
+                          }}
+                        >
+                          {others.children(item)}
+                        </button>
+                      )}
+                    </For>
+                  </div>
+                </div>
+              )}
+            </For>
+          </Show>
+        </Dialog.Body>
+      </div>
     </Dialog>
   )
 }

+ 1 - 0
packages/ui/src/styles/tailwind/index.css

@@ -57,6 +57,7 @@
   --radius-sm: 0.25rem;
   --radius-md: 0.375rem;
   --radius-lg: 0.5rem;
+  --radius-xl: 0.625rem;
 
   --shadow-xs: var(--shadow-xs);
   --shadow-md: var(--shadow-md);

+ 1 - 0
packages/ui/src/styles/theme.css

@@ -43,6 +43,7 @@
   --radius-sm: 0.25rem;
   --radius-md: 0.375rem;
   --radius-lg: 0.5rem;
+  --radius-xl: 0.625rem;
 
   --shadow-xs:
     0 1px 2px -1px rgba(19, 16, 16, 0.04), 0 1px 2px 0 rgba(19, 16, 16, 0.06), 0 1px 3px 0 rgba(19, 16, 16, 0.08);