From 506a8e14c8428dad1febb317d63d17bc166c86f9 Mon Sep 17 00:00:00 2001 From: Pawan Osman Date: Wed, 15 Jul 2026 14:28:23 +0300 Subject: [PATCH] Refactor sidebar context picker and enhance styling - Updated the `ContextPicker` component to improve button styling and dropdown functionality, replacing the `ctx-chip` class with `ctx-pill` for better visual consistency. - Enhanced dropdown item layout with new classes for improved accessibility and user experience. - Adjusted positioning logic for the dropdown menu to ensure it remains within viewport bounds. --- webview-ui/sidebar/components/Composer.tsx | 27 +++++++++++++++++--- webview-ui/sidebar/sidebar.css | 29 +++++++++++----------- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/webview-ui/sidebar/components/Composer.tsx b/webview-ui/sidebar/components/Composer.tsx index 2033b55..f722deb 100644 --- a/webview-ui/sidebar/components/Composer.tsx +++ b/webview-ui/sidebar/components/Composer.tsx @@ -390,13 +390,27 @@ function ContextPicker({ const values = opt.values || []; const openMenu = () => { const r = btnRef.current?.getBoundingClientRect(); - if (r) setStyle({ position: "fixed", left: r.left, bottom: window.innerHeight - r.top + 4, zIndex: 200 }); + if (r) { + setStyle({ + position: "fixed", + left: Math.max(8, r.left), + bottom: window.innerHeight - r.top + 6, + zIndex: 200, + }); + } setOpen(true); }; return ( <> - {open && createPortal(
e.stopPropagation()}> @@ -411,7 +425,12 @@ function ContextPicker({ setOpen(false); }} > - {v} + {v} + {v === opt.value && ( + + + + )} ))}
, diff --git a/webview-ui/sidebar/sidebar.css b/webview-ui/sidebar/sidebar.css index f144d49..2323b4f 100644 --- a/webview-ui/sidebar/sidebar.css +++ b/webview-ui/sidebar/sidebar.css @@ -669,21 +669,23 @@ body { .composer .editor .mention:hover .mention-x { visibility: visible; } .composer .editor .mention .mention-x:hover { color: var(--vscode-errorForeground, #f14c4c); } .composer-bar { display: flex; align-items: center; gap: 5px; margin-top: 7px; flex-wrap: nowrap; min-width: 0; } -.ctx-chip { - flex: 0 0 auto; - height: 22px; - padding: 0 7px; - border-radius: 5px; - border: 1px solid var(--border, rgba(128,128,128,.35)); - background: transparent; - color: var(--fg-dim, var(--fg)); - font-size: 11px; - font-weight: 500; +.ctx-pill { padding: 3px 6px 3px 8px; gap: 2px; } +.ctx-pill .cd, .ctx-pill svg { width: 11px; height: 11px; opacity: .7; } +.ctx-dropdown { min-width: 96px; padding: 4px; } +.ctx-dropdown .mode-item { + width: 100%; + justify-content: space-between; + background: none; + border: none; + color: var(--fg); + font: inherit; + font-size: 12px; + text-align: left; cursor: pointer; - line-height: 20px; } -.ctx-chip:hover { background: var(--hover); color: var(--fg); } -.ctx-dropdown { min-width: 88px; } +.ctx-dropdown .mode-item .mi-label { flex: 1 1 auto; } +.ctx-dropdown .mode-item .mi-check { color: var(--fg-dim); display: inline-flex; } +.ctx-dropdown .mode-item.active { background: var(--hover); } .pill { display: inline-flex; align-items: center; gap: 4px; background: transparent; border: 1px solid var(--border-soft); border-radius: 6px; padding: 3px 8px; font-size: 11.5px; color: var(--fg-dim); cursor: pointer; flex: 0 0 auto; white-space: nowrap; position: relative; transition: background .1s ease, color .1s ease, border-color .1s ease; } .pill:hover { background: var(--hover); color: var(--fg); border-color: var(--border); } .mode-pill { color: var(--fg); } @@ -700,7 +702,6 @@ body { .mode-item .mi-check { display: inline-flex; flex: 0 0 auto; color: var(--fg); } .mode-item .mi-check svg { width: 13px; height: 13px; } .mode-item.active .mi-icon, .mode-item.active .mi-label { color: var(--fg); } -.mode-item.active { background: var(--hover); font-weight: 600; } .model-select { color: var(--fg-dim); font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; min-width: 0; position: relative; } .model-select .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }