Skip to content

Commit c5499a5

Browse files
committed
fix(web): share the sidebar project search styling
1 parent d57af40 commit c5499a5

3 files changed

Lines changed: 55 additions & 55 deletions

File tree

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ import { Input } from "./ui/input";
208208
import {
209209
Combobox,
210210
ComboboxEmpty,
211-
ComboboxInput,
211+
ComboboxSearchInput,
212212
ComboboxItem,
213213
ComboboxList,
214214
ComboboxPopup,
@@ -4395,48 +4395,34 @@ export default function Sidebar() {
43954395
align="start"
43964396
className="w-(--anchor-width) min-w-0 overflow-hidden"
43974397
>
4398-
<div className="shrink-0 px-3 pt-2.5">
4399-
<div className="relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring">
4400-
<SearchIcon
4401-
aria-hidden="true"
4402-
className="pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55"
4403-
/>
4404-
<ComboboxInput
4405-
aria-label="Search projects"
4406-
className="[&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5"
4407-
inputClassName="rounded-none bg-transparent text-sm"
4408-
placeholder="Search projects..."
4409-
showTrigger={false}
4410-
size="sm"
4411-
unstyled
4412-
value={projectScopeMenuState.query}
4413-
onKeyDown={(event) => {
4414-
if (
4415-
event.defaultPrevented ||
4416-
event.nativeEvent.isComposing ||
4417-
event.ctrlKey ||
4418-
event.altKey ||
4419-
event.metaKey ||
4420-
(event.key !== "ContextMenu" &&
4421-
!(event.shiftKey && event.key === "F10"))
4422-
) {
4423-
return;
4424-
}
4425-
// Combobox items use virtual focus: keyboard events
4426-
// stay on this input, not on the highlighted option.
4427-
const scopeKey = highlightedProjectScopeKeyRef.current;
4428-
const project = scopeKey ? projectGroupByScopeKey.get(scopeKey) : null;
4429-
if (project) handleProjectSettings(event, project);
4430-
}}
4431-
onChange={(event) =>
4432-
dispatchProjectScopeMenu({
4433-
type: "query-changed",
4434-
query: event.target.value,
4435-
})
4436-
}
4437-
/>
4438-
</div>
4439-
</div>
4398+
<ComboboxSearchInput
4399+
aria-label="Search projects"
4400+
placeholder="Search projects..."
4401+
value={projectScopeMenuState.query}
4402+
onKeyDown={(event) => {
4403+
if (
4404+
event.defaultPrevented ||
4405+
event.nativeEvent.isComposing ||
4406+
event.ctrlKey ||
4407+
event.altKey ||
4408+
event.metaKey ||
4409+
(event.key !== "ContextMenu" && !(event.shiftKey && event.key === "F10"))
4410+
) {
4411+
return;
4412+
}
4413+
// Combobox items use virtual focus: keyboard events
4414+
// stay on this input, not on the highlighted option.
4415+
const scopeKey = highlightedProjectScopeKeyRef.current;
4416+
const project = scopeKey ? projectGroupByScopeKey.get(scopeKey) : null;
4417+
if (project) handleProjectSettings(event, project);
4418+
}}
4419+
onChange={(event) =>
4420+
dispatchProjectScopeMenu({
4421+
type: "query-changed",
4422+
query: event.target.value,
4423+
})
4424+
}
4425+
/>
44404426
<ComboboxEmpty>No matching projects.</ComboboxEmpty>
44414427
<ComboboxList>
44424428
{(item: (typeof projectScopeItems)[number]) => {

‎apps/web/src/components/settings/ProjectsSettings.tsx‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { resolveEnvironmentMachineKind } from "@t3tools/contracts";
2-
import { ChevronDownIcon, FolderIcon, SearchIcon } from "lucide-react";
2+
import { ChevronDownIcon, FolderIcon } from "lucide-react";
33
import { type ReactNode, useState } from "react";
44
import { EnvironmentMachineIcon } from "../EnvironmentMachineIcon";
55
import { ProjectFavicon } from "../ProjectFavicon";
@@ -9,7 +9,7 @@ import { Toggle, ToggleGroup } from "../ui/toggle-group";
99
import {
1010
Combobox,
1111
ComboboxEmpty,
12-
ComboboxInput,
12+
ComboboxSearchInput,
1313
ComboboxItem,
1414
ComboboxList,
1515
ComboboxPopup,
@@ -60,15 +60,7 @@ function ScopePicker({
6060
<ChevronDownIcon aria-hidden className="-me-1 size-3 opacity-50" />
6161
</ComboboxTrigger>
6262
<ComboboxPopup align="start" className="w-64">
63-
<div className="shrink-0 p-2">
64-
<ComboboxInput
65-
aria-label={`Search ${label}s`}
66-
placeholder={`Search ${label}s...`}
67-
startAddon={<SearchIcon />}
68-
showTrigger={false}
69-
size="sm"
70-
/>
71-
</div>
63+
<ComboboxSearchInput aria-label={`Search ${label}s`} placeholder={`Search ${label}s...`} />
7264
<ComboboxEmpty>No matching {label}s.</ComboboxEmpty>
7365
<ComboboxList>
7466
{(item: (typeof items)[number]) => (

‎apps/web/src/components/ui/combobox.tsx‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { Combobox as ComboboxPrimitive } from "@base-ui/react/combobox";
4-
import { ChevronsUpDownIcon, XIcon } from "lucide-react";
4+
import { ChevronsUpDownIcon, SearchIcon, XIcon } from "lucide-react";
55
import * as React from "react";
66

77
import { cn } from "~/lib/utils";
@@ -130,6 +130,27 @@ function ComboboxInput({
130130
);
131131
}
132132

133+
function ComboboxSearchInput(props: React.ComponentProps<typeof ComboboxInput>) {
134+
return (
135+
<div className="shrink-0 px-3 pt-2.5">
136+
<div className="relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring">
137+
<SearchIcon
138+
aria-hidden="true"
139+
className="pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55"
140+
/>
141+
<ComboboxInput
142+
{...props}
143+
className="[&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5"
144+
inputClassName="rounded-none bg-transparent text-sm"
145+
showTrigger={false}
146+
size="sm"
147+
unstyled
148+
/>
149+
</div>
150+
</div>
151+
);
152+
}
153+
133154
function ComboboxTrigger({ className, children, ...props }: ComboboxPrimitive.Trigger.Props) {
134155
return (
135156
<ComboboxPrimitive.Trigger className={className} data-slot="combobox-trigger" {...props}>
@@ -393,6 +414,7 @@ export {
393414
Combobox,
394415
ComboboxChipsInput,
395416
ComboboxInput,
417+
ComboboxSearchInput,
396418
ComboboxTrigger,
397419
ComboboxPopup,
398420
ComboboxItem,

0 commit comments

Comments
 (0)