Skip to content

Commit e0d2933

Browse files
Jitmisraagnik
andauthored
feat(webui): add global modern Spotlight Search (#367)
Co-authored-by: agnik <agnik@agniks-MacBook-Pro.local>
1 parent 4a9ea11 commit e0d2933

File tree

4 files changed

+623
-1
lines changed

4 files changed

+623
-1
lines changed

webui/src/app/globals.css

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,34 @@ img[data-loaded="false"] {
484484
box-shadow: none;
485485
}
486486
}
487+
488+
/* Spotlight Search Keyboard Shortcuts */
489+
kbd {
490+
display: inline-block;
491+
padding: 3px 8px;
492+
font-family:
493+
ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
494+
font-size: 0.7rem;
495+
line-height: 1.2;
496+
font-weight: 600;
497+
color: #555;
498+
background: linear-gradient(180deg, #fafafa 0%, #f0f0f0 100%);
499+
border: 1px solid #d0d0d0;
500+
border-radius: 6px;
501+
box-shadow:
502+
0 1px 2px rgba(0, 0, 0, 0.1),
503+
0 0 0 1px rgba(255, 255, 255, 0.8) inset,
504+
0 -1px 0 rgba(0, 0, 0, 0.05) inset;
505+
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
506+
}
507+
508+
.dark kbd {
509+
color: #d0d0d0;
510+
background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%);
511+
border: 1px solid #4a4a4a;
512+
box-shadow:
513+
0 1px 2px rgba(0, 0, 0, 0.3),
514+
0 0 0 1px rgba(255, 255, 255, 0.05) inset,
515+
0 -1px 0 rgba(0, 0, 0, 0.2) inset;
516+
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
517+
}

webui/src/app/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { Container } from "@mui/material";
2525
import { ThemeProvider } from "./theme-provider";
2626
import Footer from "./ui/footer";
2727
import Breadcrumb from "./ui/breadcrumb";
28+
import SpotlightSearch from "./ui/spotlight-search";
2829

2930
const inter = Inter({ subsets: ["latin"] });
3031

@@ -45,6 +46,7 @@ export default function RootLayout({
4546
suppressHydrationWarning
4647
>
4748
<ThemeProvider>
49+
<SpotlightSearch />
4850
<Banner />
4951
<Container
5052
sx={{ marginTop: "64px", height: "calc(100vh - 64px)" }}

webui/src/app/ui/banner.tsx

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@
1919

2020
"use client";
2121

22-
import { AppBar, Container, Toolbar, IconButton, Box, Tooltip, Typography } from "@mui/material";
22+
import {
23+
AppBar,
24+
Container,
25+
Toolbar,
26+
IconButton,
27+
Box,
28+
Tooltip,
29+
Typography,
30+
Button,
31+
} from "@mui/material";
2332
import Image from "next/image";
2433
import NavLinks from "./nav-links";
2534
import { useTheme } from "../theme-provider";
@@ -29,6 +38,7 @@ import GitHubIcon from "@mui/icons-material/GitHub";
2938
import HomeIcon from "@mui/icons-material/Home";
3039
import FolderIcon from "@mui/icons-material/Folder";
3140
import MenuBookIcon from "@mui/icons-material/MenuBook";
41+
import SearchIcon from "@mui/icons-material/Search";
3242
import { usePathname } from "next/navigation";
3343
import { useEffect, useState } from "react";
3444
import Link from "next/link";
@@ -174,6 +184,53 @@ export default function Banner() {
174184
<NavLinks links={links} scrolled={scrolled} />
175185
</Box>
176186

187+
<Box className="flex items-center">
188+
<Button
189+
onClick={() => {
190+
const event = new KeyboardEvent("keydown", {
191+
key: "k",
192+
metaKey: true,
193+
ctrlKey: true,
194+
});
195+
window.dispatchEvent(event);
196+
}}
197+
startIcon={<SearchIcon fontSize="small" />}
198+
sx={{
199+
mr: 1,
200+
px: 1.5,
201+
py: 0.5,
202+
fontSize: "0.875rem",
203+
textTransform: "none",
204+
backgroundColor: isDarkMode
205+
? "rgba(255,255,255,0.1)"
206+
: "rgba(0,0,0,0.05)",
207+
color: isDarkMode ? "rgba(255,255,255,0.9)" : "rgba(0,0,0,0.7)",
208+
borderRadius: 2,
209+
transition: "all 0.3s ease",
210+
"&:hover": {
211+
backgroundColor: isDarkMode
212+
? "rgba(255,255,255,0.2)"
213+
: "rgba(0,0,0,0.08)",
214+
},
215+
}}
216+
>
217+
<Box component="span" sx={{ mr: 0.5 }}>
218+
Search
219+
</Box>
220+
<Box
221+
component="kbd"
222+
sx={{
223+
fontSize: "0.7rem",
224+
px: 0.5,
225+
py: 0.25,
226+
ml: 0.5,
227+
}}
228+
>
229+
⌘K
230+
</Box>
231+
</Button>
232+
</Box>
233+
177234
<Box className="flex items-center">
178235
<Tooltip title="Toggle dark mode">
179236
<IconButton

0 commit comments

Comments
 (0)