UNPKG

fumadocs-ui

Version:

The Radix UI version of Fumadocs UI

56 lines (53 loc) 1.9 kB
'use client'; import { buttonVariants } from "../../components/ui/button.js"; import { i18n_exports } from "../../contexts/i18n.js"; import { search_exports } from "../../contexts/search.js"; import { cn } from "@fumadocs/ui/cn"; import { jsx, jsxs } from "react/jsx-runtime"; import { Search } from "lucide-react"; //#region src/layouts/shared/search-toggle.tsx function SearchToggle({ hideIfDisabled, size = "icon-sm", color = "ghost", ...props }) { const { setOpenSearch, enabled } = (0, search_exports.useSearchContext)(); if (hideIfDisabled && !enabled) return null; return /* @__PURE__ */ jsx("button", { type: "button", className: cn(buttonVariants({ size, color }), props.className), "data-search": "", "aria-label": "Open Search", onClick: () => { setOpenSearch(true); }, children: /* @__PURE__ */ jsx(Search, {}) }); } function LargeSearchToggle({ hideIfDisabled, ...props }) { const { enabled, hotKey, setOpenSearch } = (0, search_exports.useSearchContext)(); const { text } = (0, i18n_exports.useI18n)(); if (hideIfDisabled && !enabled) return null; return /* @__PURE__ */ jsxs("button", { type: "button", "data-search-full": "", ...props, className: cn("inline-flex items-center gap-2 rounded-lg border bg-fd-secondary/50 p-1.5 ps-2 text-sm text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground", props.className), onClick: () => { setOpenSearch(true); }, children: [ /* @__PURE__ */ jsx(Search, { className: "size-4" }), text.search, /* @__PURE__ */ jsx("div", { className: "ms-auto inline-flex gap-0.5", children: hotKey.map((k, i) => /* @__PURE__ */ jsx("kbd", { className: "rounded-md border bg-fd-background px-1.5", children: k.display }, i)) }) ] }); } //#endregion export { LargeSearchToggle, SearchToggle }; //# sourceMappingURL=search-toggle.js.map