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; const { headings, types, mobile } = Astro.props;
--- ---
<div class=`toc-wrapper${mobile ? "-mobile":""}`> <div id="toc" aria-mobile={mobile} class=`toc-wrapper${mobile ? "-mobile":""}`>
<TableOfContents <TableOfContents
config={headings} config={headings}
type={types} type={types}

View file

@ -126,7 +126,14 @@ export const Tree: Component<TreeProps> = props => {
<Accordion.ItemIndicator> <Accordion.ItemIndicator>
<LinkSimple /> <LinkSimple />
</Accordion.ItemIndicator> </Accordion.ItemIndicator>
<span> <span
class="link-outside"
onMouseDown={() =>
window.open(
"https://doc.qt.io/qt-6/qtquick-qmlmodule.html"
)
}
>
<a <a
href="https://doc.qt.io/qt-6/qtquick-qmlmodule.html" href="https://doc.qt.io/qt-6/qtquick-qmlmodule.html"
target="_blank" target="_blank"
@ -145,7 +152,14 @@ export const Tree: Component<TreeProps> = props => {
<Accordion.ItemIndicator> <Accordion.ItemIndicator>
<LinkSimple /> <LinkSimple />
</Accordion.ItemIndicator> </Accordion.ItemIndicator>
<span> <span
class="link-outside"
onMouseDown={() =>
window.open(
"https://git.outfoxxed.me/outfoxxed/quickshell-examples"
)
}
>
<a <a
href="https://git.outfoxxed.me/outfoxxed/quickshell-examples" href="https://git.outfoxxed.me/outfoxxed/quickshell-examples"
target="_blank" 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 { LoadingSpinner, MenuToX, XToMenu } from "@icons";
import { Tree } from "./Tree"; import { Tree } from "./Tree";
@ -41,10 +47,21 @@ const NavComponent: Component<NavProps> = props => {
}; };
onMount(() => { onMount(() => {
window.addEventListener("click", handleClickOutside); onCleanup(() => {
return () => {
window.removeEventListener("click", handleClickOutside); 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 ( 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 { Article } from "@icons";
import { Table } from "./Table"; import { Table } from "./Table";
@ -24,20 +30,33 @@ const TableOfContents: Component<TOCProps> = props => {
} }
const handleClickOutside = (event: MouseEvent) => { const handleClickOutside = (event: MouseEvent) => {
const isLink = "href" in (event.target || {}); const isLink = "href" in (event.target || {});
const isInBody = document.body.contains(event.target as Node);
if ( if (
isLink || isLink ||
(document.body.contains(event.target as Node) && !isInBody ||
!tocRef.contains(event.target as Node)) (isInBody && !tocRef.contains(event.target as Node))
) { ) {
setOpen(false); setOpen(false);
} }
}; };
onMount(() => { onMount(() => {
window.addEventListener("click", handleClickOutside); onCleanup(() => {
return () => {
window.removeEventListener("click", handleClickOutside); 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 ( return (

View file

@ -1,8 +1,25 @@
--- ---
import DocsLayout from "@layouts/DocsLayout.astro"; 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"> <DocsLayout title="Quickshell Type Definitions" description="Quickshell Type Documentation">
<h2>Type Definitions</h2> <h2>Type Definitions</h2>
<div class="root-nav"> <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> </div>
</DocsLayout> </DocsLayout>

View file

@ -8,6 +8,7 @@
justify-content: center; justify-content: center;
flex-direction: row; flex-direction: row;
flex-grow: 1; flex-grow: 1;
transition: filter 0.3s;
} }
.docslayout-inner { .docslayout-inner {
@ -19,6 +20,10 @@
flex-direction: row; flex-direction: row;
} }
.dim-content .docslayout-root {
filter: brightness(50%);
}
.docs-content { .docs-content {
flex-grow: 1; flex-grow: 1;
@ -44,7 +49,7 @@
} }
.heading { .heading {
& > [id] { &>[id] {
width: max-content; width: max-content;
} }
@ -82,7 +87,7 @@ ul {
.markdown-alert { .markdown-alert {
margin-block: 0.618rem; margin-block: 0.618rem;
& > *:not(:first-child) { &>*:not(:first-child) {
margin-block: 0.724rem; margin-block: 0.724rem;
} }
} }

View file

@ -39,7 +39,8 @@
display: none; display: none;
} }
transition: left 0.3s ease, padding 0.3s ease; transition: left 0.3s ease,
padding 0.3s ease;
&.shown { &.shown {
display: flex; display: flex;
@ -82,10 +83,10 @@
} }
& [data-part="item"] { & [data-part="item"] {
& [data-part="item-content"] > div { & [data-part="item-content"]>div {
min-height: 3em; min-height: 3em;
& > a { &>a {
margin: auto 0; margin: auto 0;
} }
} }
@ -94,6 +95,12 @@
} }
} }
.link-outside {
width: 100%;
height: 100%;
text-align: start;
}
@media (min-width: 40rem) { @media (min-width: 40rem) {
.nav-toggle { .nav-toggle {
.nav-items { .nav-items {
@ -128,7 +135,7 @@
} }
& [data-part="item"] { & [data-part="item"] {
& [data-part="item-content"] > div { & [data-part="item-content"]>div {
min-height: 2.2rem; min-height: 2.2rem;
} }
} }

View file

@ -13,17 +13,7 @@
.toc-wrapper-mobile { .toc-wrapper-mobile {
display: block; display: block;
scrollbar-width: none;
-ms-overflow-style: none;
&::-webkit-scrollbar {
display: none;
}
background-color: transparent;
}
.toc-content {
background-color: transparent; background-color: transparent;
} }
@ -35,7 +25,7 @@
font-size: 1.614rem; font-size: 1.614rem;
max-height: 500px; max-height: 500px;
& > svg { &>svg {
height: 100%; height: 100%;
width: 24px; width: 24px;
} }
@ -60,14 +50,20 @@
-ms-overflow-style: none; -ms-overflow-style: none;
background-color: hsl(var(--overlay-bkg)); background-color: hsl(var(--overlay-bkg));
border-left: 1px solid hsl(var(--overlay-bkg-border)); border-left: 1px solid hsl(var(--overlay-bkg-border));
cursor: default;
&::-webkit-scrollbar { &::-webkit-scrollbar {
display: none; display: none;
} }
transition: width 0.3s ease, padding 0.3s ease; transition: width 0.3s ease,
padding 0.3s ease;
&.shown { &.shown {
& .toc-content {
background-color: transparent;
}
overflow-y: scroll; overflow-y: scroll;
width: var(--width); width: var(--width);
display: flex; display: flex;
@ -122,7 +118,7 @@
list-style: none; list-style: none;
&.active { &.active {
& > .toc_a { &>.toc_a {
color: hsl(var(--green) 72 60); color: hsl(var(--green) 72 60);
} }
} }

View file

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