quickshell-web/src/components/Header.astro

64 lines
1.6 KiB
Text
Raw Normal View History

2024-09-28 02:35:19 +03:00
---
import { ThemeSelect } from "@components/hooks/ThemeSwitch";
2024-10-24 19:40:53 -07:00
import { getTypeData } from "@config/io/generateTypeData";
2024-10-24 21:41:25 -07:00
import Nav from "@components/navigation/sidebars/nav/index.astro";
2024-09-28 02:35:19 +03:00
import TOC from "@components/navigation/sidebars/TOC.astro";
import type { TypeTOC } from "./navigation/sidebars/types";
import Search from "./navigation/Search.astro";
2024-10-24 19:40:53 -07:00
const routes = await getTypeData();
2024-09-28 02:35:19 +03:00
const url = Astro.url.pathname.split("/");
const currentClass = url[4];
const currentData = routes.find(
item => item.name === currentClass
);
const data = currentData?.data;
const tocFunctions =
data?.functions?.map(item => item.name) || null;
const propsKeys = data?.properties
? Object.keys(data.properties)
: null;
const signalKeys = data?.signals
? Object.keys(data.signals)
: null;
const variantKeys = data?.variants
? Object.keys(data.variants)
: null;
let sidebarData: TypeTOC | undefined = {
properties: propsKeys,
functions: tocFunctions,
signals: signalKeys,
variants: variantKeys,
};
if (!data) {
sidebarData = undefined;
}
const { headings } = Astro.props;
---
<div class="header">
<div class="header-item header-left">
{url.length > 2 ?
<Nav mobile={true}/>
<div class="nav-collapsed-spacer header-spacer"/>
2024-09-28 02:35:19 +03:00
: null}
<h3 class="header-title">
2024-09-28 02:35:19 +03:00
<a href="/">Quickshell</a>
</h3>
</div>
<div class="header-item header-right">
<Search/>
<div class="header-spacer"/>
2024-09-28 02:35:19 +03:00
<ThemeSelect client:load />
{url.length > 2 ?
2024-10-14 21:30:53 -07:00
<div class="toc-collapsed-spacer header-spacer"/>
2024-09-28 02:35:19 +03:00
<TOC headings={headings} types={sidebarData} mobile={true}/>
: null}
</div>
</div>