diff options
| author | Volpeon <git@volpeon.ink> | 2026-07-22 19:40:59 +0200 |
|---|---|---|
| committer | Volpeon <git@volpeon.ink> | 2026-07-22 19:40:59 +0200 |
| commit | c1e28224aa2e1450031669d9a7e359b63e04687d (patch) | |
| tree | 68f3d8905c763a91f68001d868197effa92adafa /src/ui/objects/NavbarItem.tsx | |
| download | corvos-website-c1e28224aa2e1450031669d9a7e359b63e04687d.tar.gz corvos-website-c1e28224aa2e1450031669d9a7e359b63e04687d.tar.bz2 corvos-website-c1e28224aa2e1450031669d9a7e359b63e04687d.zip | |
Init
Diffstat (limited to 'src/ui/objects/NavbarItem.tsx')
| -rw-r--r-- | src/ui/objects/NavbarItem.tsx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/ui/objects/NavbarItem.tsx b/src/ui/objects/NavbarItem.tsx new file mode 100644 index 0000000..c0e347f --- /dev/null +++ b/src/ui/objects/NavbarItem.tsx | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | import type { HTMLTag, Polymorphic } from "corvos/plugins/jsx.ts"; | ||
| 2 | |||
| 3 | export type Props<Tag extends HTMLTag> = Polymorphic<{ | ||
| 4 | as: Tag; | ||
| 5 | icon?: JSX.Element; | ||
| 6 | pre?: JSX.Element; | ||
| 7 | post?: JSX.Element; | ||
| 8 | selected?: boolean; | ||
| 9 | }>; | ||
| 10 | |||
| 11 | export const NavbarItem = <T extends HTMLTag = "a">({ | ||
| 12 | children, | ||
| 13 | as: Tag = "a" as T, | ||
| 14 | icon, | ||
| 15 | pre, | ||
| 16 | post, | ||
| 17 | selected, | ||
| 18 | class: cls, | ||
| 19 | ...props | ||
| 20 | }: Props<T>) => ( | ||
| 21 | <Tag | ||
| 22 | aria-current={selected ? "page" : undefined} | ||
| 23 | class:list={["o-navbar__item", { "is-selected": selected }, cls]} | ||
| 24 | role="menuitem" | ||
| 25 | {...props} | ||
| 26 | > | ||
| 27 | {icon && <div class="o-navbar__item-label">{children}</div>} | ||
| 28 | |||
| 29 | <div class="o-navbar__item-content"> | ||
| 30 | {pre} {icon ?? <span class="o-navbar__item-content-text">{children}</span>} {post} | ||
| 31 | </div> | ||
| 32 | </Tag> | ||
| 33 | ); | ||
