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.
This commit is contained in:
Pawan Osman
2026-07-15 14:28:23 +03:00
parent 75955a8033
commit 506a8e14c8
2 changed files with 38 additions and 18 deletions
+23 -4
View File
@@ -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 (
<>
<button ref={btnRef} type="button" className="ctx-chip" title="Context window size" onClick={() => (open ? setOpen(false) : openMenu())}>
{opt.value || "ctx"}
<button
ref={btnRef}
type="button"
className="pill ctx-pill"
title="Context window size"
onClick={() => (open ? setOpen(false) : openMenu())}
>
<span>{opt.value || "ctx"}</span>
<Icon name="chevD" className="cd" />
</button>
{open && createPortal(
<div ref={menuRef} className="mode-dropdown ctx-dropdown" style={style} onClick={(e) => e.stopPropagation()}>
@@ -411,7 +425,12 @@ function ContextPicker({
setOpen(false);
}}
>
{v}
<span className="mi-label">{v}</span>
{v === opt.value && (
<span className="mi-check">
<Icon name="check" size={13} />
</span>
)}
</button>
))}
</div>,
+15 -14
View File
@@ -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; }