diff --git a/deno.json b/deno.json index ed5c112a..273ae0f9 100644 --- a/deno.json +++ b/deno.json @@ -51,6 +51,7 @@ "$std/": "https://deno.land/std@0.208.0/", "$fresh/": "https://deno.land/x/fresh@1.6.1/", "tabler_icons_tsx/": "https://deno.land/x/tabler_icons_tsx@0.0.5/tsx/", + "@headlessui/react": "https://esm.sh/v135/*@headlessui/react@1.7.17", "@preact/signals-core": "https://esm.sh/v135/@preact/signals-core@1.5.1", "@preact/signals": "https://esm.sh/v135/*@preact/signals@1.2.2", "preact": "https://esm.sh/v135/preact@10.19.3", @@ -79,5 +80,11 @@ "fmt": { "proseWrap": "preserve" }, - "scopes": {} + "scopes": { + "https://esm.sh/v135/": { + "client-only": "https://esm.sh/client-only@0.0.1", + "react-dom": "https://esm.sh/v135/preact@10.19.3/compat", + "react": "https://esm.sh/v135/preact@10.19.3/compat" + } + } } diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 4afeec49..41f8260b 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,5 +1,6 @@ import IconSolarPanel2 from "tabler_icons_tsx/solar-panel-2.tsx"; import type { FunctionalComponent } from "preact"; +import { HeaderMenu } from "../islands/HeaderMenu.tsx"; interface Props { active: string; @@ -24,13 +25,11 @@ const Header: FunctionalComponent = ({ active }: Props) => { diff --git a/src/fresh.gen.ts b/src/fresh.gen.ts index 4a2e476f..1f51d489 100644 --- a/src/fresh.gen.ts +++ b/src/fresh.gen.ts @@ -11,7 +11,7 @@ import * as $green_index from "./routes/green/index.tsx"; import * as $index from "./routes/index.tsx"; import * as $monies_guarantees_in_life from "./routes/monies/guarantees-in-life.tsx"; import * as $monies_index from "./routes/monies/index.tsx"; - +import * as $HeaderMenu from "./islands/HeaderMenu.tsx"; import { type Manifest } from "$fresh/server.ts"; const manifest = { @@ -26,7 +26,9 @@ const manifest = { "./routes/monies/guarantees-in-life.tsx": $monies_guarantees_in_life, "./routes/monies/index.tsx": $monies_index, }, - islands: {}, + islands: { + "./islands/HeaderMenu.tsx": $HeaderMenu, + }, baseUrl: import.meta.url, } satisfies Manifest; diff --git a/src/islands/HeaderMenu.tsx b/src/islands/HeaderMenu.tsx new file mode 100644 index 00000000..ac973ca2 --- /dev/null +++ b/src/islands/HeaderMenu.tsx @@ -0,0 +1,59 @@ +import { Menu } from "@headlessui/react"; +import type { FunctionComponent } from "preact"; +import IconChevronDown from "tabler_icons_tsx/chevron-down.tsx"; + +interface Props { + title: string; + active: boolean; + items?: MenuItem[]; + href?: string; +} + +interface MenuItem { + url: string; + name: string; +} + +const HeaderMenu: FunctionComponent = ( + { + title, + items, + active, + href, + }, +) => { + return items !== undefined + ? ( + + + + {title} + {" "} + + + +
+ + {items.map(({ name, url }) => ( + + {({ active }) => ( + {name} + )} + + ))} + +
+
+ ) + : ( + + {title} + + ); +}; + +export { HeaderMenu };