added index to the docs/types route, minor fixes to styling

This commit is contained in:
Xanazf 2024-10-17 19:35:39 +03:00
parent ea5b56acc8
commit 349c87a205
Signed by: Xanazf
GPG key ID: 4E4A5AD1FB748427
9 changed files with 109 additions and 32 deletions

View file

@ -11,7 +11,7 @@ export interface Props {
const { headings, types, mobile } = Astro.props;
---
<div class=`toc-wrapper${mobile ? "-mobile":""}`>
<div id="toc" aria-mobile={mobile} class=`toc-wrapper${mobile ? "-mobile":""}`>
<TableOfContents
config={headings}
type={types}

View file

@ -126,7 +126,14 @@ export const Tree: Component<TreeProps> = props => {
<Accordion.ItemIndicator>
<LinkSimple />
</Accordion.ItemIndicator>
<span>
<span
class="link-outside"
onMouseDown={() =>
window.open(
"https://doc.qt.io/qt-6/qtquick-qmlmodule.html"
)
}
>
<a
href="https://doc.qt.io/qt-6/qtquick-qmlmodule.html"
target="_blank"
@ -145,7 +152,14 @@ export const Tree: Component<TreeProps> = props => {
<Accordion.ItemIndicator>
<LinkSimple />
</Accordion.ItemIndicator>
<span>
<span
class="link-outside"
onMouseDown={() =>
window.open(
"https://git.outfoxxed.me/outfoxxed/quickshell-examples"
)
}
>
<a
href="https://git.outfoxxed.me/outfoxxed/quickshell-examples"
target="_blank"

View file

@ -1,4 +1,10 @@
import { createSignal, onMount, type Component } from "solid-js";
import {
createSignal,
createEffect,
onMount,
onCleanup,
type Component,
} from "solid-js";
import { LoadingSpinner, MenuToX, XToMenu } from "@icons";
import { Tree } from "./Tree";
@ -41,10 +47,21 @@ const NavComponent: Component<NavProps> = props => {
};
onMount(() => {
window.addEventListener("click", handleClickOutside);
return () => {
onCleanup(() => {
window.removeEventListener("click", handleClickOutside);
};
});
});
createEffect(() => {
if (open()) {
window.addEventListener("click", handleClickOutside);
document.body.style.overflow = "hidden";
document.body.classList.add("dim-content");
} else {
window.removeEventListener("click", handleClickOutside);
document.body.style.overflow = "auto";
document.body.classList.remove("dim-content");
}
});
return (

View file

@ -1,4 +1,10 @@
import { createSignal, onMount, type Component } from "solid-js";
import {
createEffect,
createSignal,
onMount,
onCleanup,
type Component,
} from "solid-js";
import { Article } from "@icons";
import { Table } from "./Table";
@ -24,20 +30,33 @@ const TableOfContents: Component<TOCProps> = props => {
}
const handleClickOutside = (event: MouseEvent) => {
const isLink = "href" in (event.target || {});
const isInBody = document.body.contains(event.target as Node);
if (
isLink ||
(document.body.contains(event.target as Node) &&
!tocRef.contains(event.target as Node))
!isInBody ||
(isInBody && !tocRef.contains(event.target as Node))
) {
setOpen(false);
}
};
onMount(() => {
window.addEventListener("click", handleClickOutside);
return () => {
onCleanup(() => {
window.removeEventListener("click", handleClickOutside);
};
});
});
createEffect(() => {
const tocRoot = document.getElementById("toc")!;
if (open()) {
window.addEventListener("click", handleClickOutside);
document.body.style.overflow = "hidden";
document.body.classList.add("dim-content");
} else {
window.removeEventListener("click", handleClickOutside);
document.body.style.overflow = "auto";
document.body.classList.remove("dim-content");
}
});
return (

View file

@ -1,8 +1,25 @@
---
import DocsLayout from "@layouts/DocsLayout.astro";
import { generateTypeData } from "@config/io/generateTypeData";
const routes = await generateTypeData();
const modules = [...new Set(routes.map(route => route.type))];
---
<DocsLayout title="Quickshell Type Definitions" description="Quickshell Type Documentation">
<h2>Type Definitions</h2>
<div class="root-nav">
{modules.map(moduleEntry => {
const indexData = routes.filter(route => route.name === "index")
const indexSingled = indexData.filter(indexEntry => indexEntry.type === moduleEntry)[0]
const description = indexSingled.data.description
return (
<div class="root-nav-entry">
<a class="root-nav-link" href={`/docs/types/${moduleEntry}`}>
{moduleEntry}
</a>
<span class="root-nav-desc">{description}</span>
</div>)
})}
</div>
</DocsLayout>

View file

@ -8,6 +8,7 @@
justify-content: center;
flex-direction: row;
flex-grow: 1;
transition: filter 0.3s;
}
.docslayout-inner {
@ -19,6 +20,10 @@
flex-direction: row;
}
.dim-content .docslayout-root {
filter: brightness(50%);
}
.docs-content {
flex-grow: 1;

View file

@ -39,7 +39,8 @@
display: none;
}
transition: left 0.3s ease, padding 0.3s ease;
transition: left 0.3s ease,
padding 0.3s ease;
&.shown {
display: flex;
@ -94,6 +95,12 @@
}
}
.link-outside {
width: 100%;
height: 100%;
text-align: start;
}
@media (min-width: 40rem) {
.nav-toggle {
.nav-items {

View file

@ -13,17 +13,7 @@
.toc-wrapper-mobile {
display: block;
scrollbar-width: none;
-ms-overflow-style: none;
&::-webkit-scrollbar {
display: none;
}
background-color: transparent;
}
.toc-content {
background-color: transparent;
}
@ -60,14 +50,20 @@
-ms-overflow-style: none;
background-color: hsl(var(--overlay-bkg));
border-left: 1px solid hsl(var(--overlay-bkg-border));
cursor: default;
&::-webkit-scrollbar {
display: none;
}
transition: width 0.3s ease, padding 0.3s ease;
transition: width 0.3s ease,
padding 0.3s ease;
&.shown {
& .toc-content {
background-color: transparent;
}
overflow-y: scroll;
width: var(--width);
display: flex;

View file

@ -63,6 +63,8 @@
}
&:hover {
cursor: pointer;
& svg {
opacity: 1;
}