import "./index.scss"; import * as React from "react"; import { KBarAnimator } from "../../src/KBarAnimator"; import { KBarProvider } from "../../src/KBarContextProvider"; import KBarPortal from "../../src/KBarPortal"; import useMatches, { NO_GROUP } from "../../src/useMatches"; import KBarPositioner from "../../src/KBarPositioner"; import KBarSearch from "../../src/KBarSearch"; import KBarResults from "../../src/KBarResults"; import { Switch, Route, useHistory, Redirect } from "react-router-dom"; import Layout from "./Layout"; import Home from "./Home"; import Docs from "./Docs"; import SearchDocsActions from "./SearchDocsActions"; import { createAction } from "../../src/utils"; import { useAnalytics } from "./utils"; import { Action } from "../../src"; import Blog from "./Blog"; const searchStyle = { padding: "12px 16px", fontSize: "16px", width: "100%", boxSizing: "border-box" as React.CSSProperties["boxSizing"], outline: "none", border: "none", background: "var(--background)", color: "var(--foreground)", }; const animatorStyle = { maxWidth: "600px", width: "100%", background: "var(--background)", color: "var(--foreground)", borderRadius: "8px", overflow: "hidden", boxShadow: "var(--shadow)", }; const groupNameStyle = { padding: "8px 16px", fontSize: "10px", textTransform: "uppercase" as const, opacity: 0.5, background: "var(--background)", }; const App = () => { useAnalytics(); const history = useHistory(); return ( history.push("/"), icon: , subtitle: "Subtitles can help add more context.", }, { id: "docsAction", name: "Docs", shortcut: ["g", "d"], keywords: "help", section: "Navigation", perform: () => history.push("/docs"), }, { id: "contactAction", name: "Contact", shortcut: ["c"], keywords: "email hello", section: "Navigation", perform: () => window.open("mailto:timchang@hey.com", "_blank"), }, { id: "twitterAction", name: "Twitter", shortcut: ["t"], keywords: "social contact dm", section: "Navigation", perform: () => window.open("https://twitter.com/timcchang", "_blank"), }, createAction({ name: "Github", shortcut: ["g", "h"], keywords: "sourcecode", section: "Navigation", perform: () => window.open("https://github.com/timc1/kbar", "_blank"), }), { id: "theme", name: "Change theme…", shortcut: [], keywords: "interface color dark light", section: "Preferences", children: ["darkTheme", "lightTheme"], }, { id: "darkTheme", name: "Dark", shortcut: [], keywords: "dark", section: "", perform: () => document.documentElement.setAttribute("data-theme-dark", ""), parent: "theme", }, { id: "lightTheme", name: "Light", shortcut: [], keywords: "light", section: "", perform: () => document.documentElement.removeAttribute("data-theme-dark"), parent: "theme", }, ]} > ); }; function RenderResults() { const groups = useMatches(); const flattened = React.useMemo( () => groups.reduce((acc, curr) => { acc.push(curr.name); acc.push(...curr.actions); return acc; }, []), [groups] ); return ( i !== NO_GROUP)} onRender={({ item, active }) => typeof item === "string" ? (
{item}
) : ( ) } /> ); } const ResultItem = React.forwardRef( ( { action, active, }: { action: Action; active: boolean; }, ref: React.Ref ) => { return (
{action.icon && action.icon}
{action.name} {action.subtitle && ( {action.subtitle} )}
{action.shortcut?.length ? (
{action.shortcut.map((sc) => ( {sc} ))}
) : null}
); } ); export default App; function HomeIcon() { return ( ); }