improve TOC style somewhat
This commit is contained in:
parent
415c5f56ef
commit
55e272eb2e
19 changed files with 60 additions and 54 deletions
|
@ -39,25 +39,21 @@ if (!data) {
|
||||||
sidebarData = undefined;
|
sidebarData = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { headings } = Astro.props;
|
const {
|
||||||
|
title = null,
|
||||||
|
headings = [],
|
||||||
|
} = Astro.props;
|
||||||
---
|
---
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="header-item header-left">
|
<div class="header-item header-left">
|
||||||
{url.length > 2 ?
|
<Nav mobile={true}/>
|
||||||
<Nav mobile={true}/>
|
|
||||||
<div class="nav-collapsed-spacer header-spacer"/>
|
|
||||||
: null}
|
|
||||||
<h3 class="header-title">
|
<h3 class="header-title">
|
||||||
<a href="/">Quickshell</a>
|
<a href="/">Quickshell</a>
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-item header-right">
|
<div class="header-item header-right">
|
||||||
<Search/>
|
<Search/>
|
||||||
<div class="header-spacer"/>
|
|
||||||
<ThemeSelect client:load />
|
<ThemeSelect client:load />
|
||||||
{url.length > 2 ?
|
<TOC title={title} headings={headings} types={sidebarData} mobile={true}/>
|
||||||
<div class="toc-collapsed-spacer header-spacer"/>
|
|
||||||
<TOC headings={headings} types={sidebarData} mobile={true}/>
|
|
||||||
: null}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
window.addEventListener('DOMContentLoaded', () => {
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
const observer = new IntersectionObserver(entries => {
|
const observer = new IntersectionObserver(entries => {
|
||||||
entries.forEach(entry => {
|
entries.forEach(entry => {
|
||||||
const heading = entry.target.querySelector('h2, h3, h4, h5, h6')
|
const heading = entry.target.querySelector('h1, h2, h3, h4, h5, h6')
|
||||||
if(heading) {
|
if(heading) {
|
||||||
const id = heading.id
|
const id = heading.id
|
||||||
if (entry.intersectionRatio > 0) {
|
if (entry.intersectionRatio > 0) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ const videos = [
|
||||||
</video>
|
</video>
|
||||||
<p>
|
<p>
|
||||||
Configuration by <Fragment set:html={author}/>
|
Configuration by <Fragment set:html={author}/>
|
||||||
{source ? <Fragment>(<a href={source}>source code</a>)</Fragment> : null}
|
{source && <>(<a href={source}>source code</a>)</>}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>)}
|
</div>)}
|
||||||
|
|
|
@ -3,19 +3,22 @@ import TableOfContents from "./toc";
|
||||||
import type { ConfigHeading, TypeTOC } from "./types.d.ts";
|
import type { ConfigHeading, TypeTOC } from "./types.d.ts";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
|
title?: string;
|
||||||
headings?: ConfigHeading[];
|
headings?: ConfigHeading[];
|
||||||
types?: TypeTOC;
|
types?: TypeTOC;
|
||||||
mobile: boolean;
|
mobile: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { headings, types, mobile } = Astro.props;
|
const { title, headings, types, mobile } = Astro.props;
|
||||||
---
|
---
|
||||||
|
{((headings?.length ?? 0) != 0 || types) &&
|
||||||
<div id="toc" aria-mobile={mobile} class=`toc-wrapper${mobile ? "-mobile":""}`>
|
<div id="toc" aria-mobile={mobile} class=`toc-wrapper${mobile ? "-mobile":""}`>
|
||||||
<TableOfContents
|
<TableOfContents
|
||||||
config={headings}
|
title={title}
|
||||||
type={types}
|
config={headings}
|
||||||
mobile={mobile}
|
type={types}
|
||||||
client:idle
|
mobile={mobile}
|
||||||
/>
|
client:idle
|
||||||
</div>
|
/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
|
@ -11,15 +11,19 @@ import {
|
||||||
import { Heading } from "./Heading";
|
import { Heading } from "./Heading";
|
||||||
|
|
||||||
export const Table: Component<{
|
export const Table: Component<{
|
||||||
|
title?: string;
|
||||||
typeTOC?: TypeTOC;
|
typeTOC?: TypeTOC;
|
||||||
configTOC?: ConfigTOC[];
|
configTOC?: ConfigTOC[];
|
||||||
}> = props => {
|
}> = props => {
|
||||||
const { typeTOC, configTOC } = props;
|
const { title, typeTOC, configTOC } = props;
|
||||||
|
|
||||||
if (configTOC) {
|
if (configTOC) {
|
||||||
return (
|
return (
|
||||||
<div class="toc-content">
|
<div class="toc-content">
|
||||||
<p>Contents</p>
|
{title && <>
|
||||||
|
<p>{title}</p>
|
||||||
|
<hr/>
|
||||||
|
</>}
|
||||||
<For each={configTOC}>
|
<For each={configTOC}>
|
||||||
{heading => (
|
{heading => (
|
||||||
<Heading
|
<Heading
|
||||||
|
|
|
@ -15,7 +15,7 @@ const TableOfContents: Component<TOCProps> = props => {
|
||||||
const [open, setOpen] = createSignal<boolean>(false);
|
const [open, setOpen] = createSignal<boolean>(false);
|
||||||
const [clientWidth, setClientWidth] = createSignal<number>(0);
|
const [clientWidth, setClientWidth] = createSignal<number>(0);
|
||||||
const [screenWidth, setScreenWidth] = createSignal<number>(0);
|
const [screenWidth, setScreenWidth] = createSignal<number>(0);
|
||||||
const { mobile, config, type } = props;
|
const { mobile, title, config, type } = props;
|
||||||
let tocRef: HTMLDivElement;
|
let tocRef: HTMLDivElement;
|
||||||
|
|
||||||
function toggle(e: MouseEvent) {
|
function toggle(e: MouseEvent) {
|
||||||
|
@ -27,9 +27,10 @@ const TableOfContents: Component<TOCProps> = props => {
|
||||||
return type ? (
|
return type ? (
|
||||||
<Table typeTOC={type} />
|
<Table typeTOC={type} />
|
||||||
) : (
|
) : (
|
||||||
<Table configTOC={buildHierarchy(config!)} />
|
<Table title={title} configTOC={buildHierarchy(config!)} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
const isInBody = document.body.contains(event.target as Node);
|
||||||
|
@ -97,7 +98,7 @@ const TableOfContents: Component<TOCProps> = props => {
|
||||||
{type ? (
|
{type ? (
|
||||||
<Table typeTOC={type} />
|
<Table typeTOC={type} />
|
||||||
) : (
|
) : (
|
||||||
<Table configTOC={buildHierarchy(config!)} />
|
<Table title={title} configTOC={buildHierarchy(config!)} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -17,6 +17,7 @@ export interface TreeProps {
|
||||||
|
|
||||||
// Right
|
// Right
|
||||||
export interface TOCProps {
|
export interface TOCProps {
|
||||||
|
title?: string;
|
||||||
config?: ConfigHeading[];
|
config?: ConfigHeading[];
|
||||||
type?: TypeTableProps;
|
type?: TypeTableProps;
|
||||||
mobile: boolean;
|
mobile: boolean;
|
||||||
|
|
|
@ -28,9 +28,16 @@ export function buildHierarchy(headings: ConfigHeading[]) {
|
||||||
if (heading.depth === 1) {
|
if (heading.depth === 1) {
|
||||||
toc.push(heading);
|
toc.push(heading);
|
||||||
} else {
|
} else {
|
||||||
parentHeadings
|
let depth = heading.depth - 1;
|
||||||
.get(heading.depth - 1)
|
let parent = null;
|
||||||
.subheadings.push(heading);
|
|
||||||
|
while (!parent && depth != 0) {
|
||||||
|
parent = parentHeadings.get(depth);
|
||||||
|
depth -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent) parent.subheadings.push(heading);
|
||||||
|
else toc.push(heading);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return toc;
|
return toc;
|
||||||
|
|
|
@ -3,8 +3,6 @@ title: "FAQ"
|
||||||
description: "Frequently Asked Questions"
|
description: "Frequently Asked Questions"
|
||||||
index: 1000
|
index: 1000
|
||||||
---
|
---
|
||||||
# {frontmatter.title}
|
|
||||||
|
|
||||||
This page is being actively expanded as common questions come up again.
|
This page is being actively expanded as common questions come up again.
|
||||||
|
|
||||||
Make sure to also read the [Item Size and Position](/docs/guide/size-position) and
|
Make sure to also read the [Item Size and Position](/docs/guide/size-position) and
|
||||||
|
|
|
@ -3,8 +3,6 @@ title: "Usage Guide"
|
||||||
description: "Configuring the shell"
|
description: "Configuring the shell"
|
||||||
index: -1
|
index: -1
|
||||||
---
|
---
|
||||||
# {frontmatter.title}
|
|
||||||
|
|
||||||
See the [Installation and Setup](/docs/guide/install-setup) page to get started.
|
See the [Installation and Setup](/docs/guide/install-setup) page to get started.
|
||||||
|
|
||||||
To write a Quickshell config, start by following the
|
To write a Quickshell config, start by following the
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
title: "Installation & Setup"
|
title: "Installation & Setup"
|
||||||
index: 0
|
index: 0
|
||||||
---
|
---
|
||||||
# {frontmatter.title}
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> Quickshell is still in a somewhat early stage of development.
|
> Quickshell is still in a somewhat early stage of development.
|
||||||
> There will be breaking changes before 1.0, however a migration guide will be provided.
|
> There will be breaking changes before 1.0, however a migration guide will be provided.
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
title: "Introduction"
|
title: "Introduction"
|
||||||
index: 2
|
index: 2
|
||||||
---
|
---
|
||||||
|
|
||||||
# {frontmatter.title}
|
|
||||||
|
|
||||||
This page will walk you through the process of creating a simple bar/panel, and
|
This page will walk you through the process of creating a simple bar/panel, and
|
||||||
introduce you to all the basic concepts involved. You can use the
|
introduce you to all the basic concepts involved. You can use the
|
||||||
[QML Language Reference](/docs/guide/qml-language) to learn about the syntax
|
[QML Language Reference](/docs/guide/qml-language) to learn about the syntax
|
||||||
|
|
|
@ -4,8 +4,6 @@ index: 10
|
||||||
---
|
---
|
||||||
import Collapsible from "@components/Collapsible.astro";
|
import Collapsible from "@components/Collapsible.astro";
|
||||||
|
|
||||||
# {frontmatter.title}
|
|
||||||
|
|
||||||
Quickshell is configured using the Qt Modeling Language, or QML.
|
Quickshell is configured using the Qt Modeling Language, or QML.
|
||||||
This page explains what you need to know about QML to start using quickshell.
|
This page explains what you need to know about QML to start using quickshell.
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
title: "Item Size and Position"
|
title: "Item Size and Position"
|
||||||
index: 2
|
index: 2
|
||||||
---
|
---
|
||||||
# {frontmatter.title}
|
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> Read the entire page, understanding this is critical to building a well designed shell.
|
> Read the entire page, understanding this is critical to building a well designed shell.
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ if (url[2]) {
|
||||||
<CreateCopyButtons />
|
<CreateCopyButtons />
|
||||||
</head>
|
</head>
|
||||||
<body class="docslayout">
|
<body class="docslayout">
|
||||||
<Header headings={headings}/>
|
<Header title={title} headings={headings}/>
|
||||||
<div class="docslayout-root">
|
<div class="docslayout-root">
|
||||||
<Nav mobile={false}/>
|
<Nav mobile={false}/>
|
||||||
<div class="docslayout-inner" data-pagefind-body>
|
<div class="docslayout-inner" data-pagefind-body>
|
||||||
|
@ -89,10 +89,11 @@ if (url[2]) {
|
||||||
></path></svg
|
></path></svg
|
||||||
>
|
>
|
||||||
</Breadcrumbs>
|
</Breadcrumbs>
|
||||||
<slot />
|
<slot/>
|
||||||
</div>
|
</div>
|
||||||
|
<slot name="alongside-content"/>
|
||||||
</div>
|
</div>
|
||||||
<Footer />
|
<Footer/>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ import TOCIntersectionObserver from "@src/components/hooks/TOCIntersectionObserv
|
||||||
import type { ConfigHeading } from "@src/components/navigation/sidebars/types";
|
import type { ConfigHeading } from "@src/components/navigation/sidebars/types";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
headings: ConfigHeading[];
|
|
||||||
title: string;
|
title: string;
|
||||||
|
headings: ConfigHeading[];
|
||||||
description: string;
|
description: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,11 +15,12 @@ const { title, description, headings } = Astro.props;
|
||||||
<DocsLayout title={title} description={description} headings={headings}>
|
<DocsLayout title={title} description={description} headings={headings}>
|
||||||
<div class="docs">
|
<div class="docs">
|
||||||
<div class="docs-content">
|
<div class="docs-content">
|
||||||
<hr>
|
<hr/>
|
||||||
|
<h1>{title}</h1>
|
||||||
<slot/>
|
<slot/>
|
||||||
</div>
|
</div>
|
||||||
<TOC mobile={false} headings={headings} data-pagefind-ignore/>
|
|
||||||
</div>
|
</div>
|
||||||
|
<TOC slot="alongside-content" mobile={false} title={title} headings={headings} data-pagefind-ignore/>
|
||||||
</DocsLayout>
|
</DocsLayout>
|
||||||
|
|
||||||
<TOCIntersectionObserver/>
|
<TOCIntersectionObserver/>
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
layout: "@layouts/GuideMdLayout.astro"
|
layout: "@layouts/GuideMdLayout.astro"
|
||||||
title: "About Quickshell"
|
title: "About Quickshell"
|
||||||
---
|
---
|
||||||
# {frontmatter.title}
|
|
||||||
Quickshell is a toolkit for building a desktop shell, which is to say components
|
Quickshell is a toolkit for building a desktop shell, which is to say components
|
||||||
of your desktop like bars, widgets, lock screens, display managers, and the like.
|
of your desktop like bars, widgets, lock screens, display managers, and the like.
|
||||||
|
|
||||||
|
@ -27,4 +26,4 @@ Quickshell is actively developed and will still receive breaking changes.
|
||||||
A tagged release is planned soon, however there will be breakage before
|
A tagged release is planned soon, however there will be breakage before
|
||||||
that point.
|
that point.
|
||||||
|
|
||||||
See the [Usage Guide](/docs/guide) to learn how to set up and use Quickshell
|
See the [Usage Guide](/docs/guide) to learn how to set up and use Quickshell
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
margin: 0;
|
margin: 0;
|
||||||
margin-block: 0.618rem;
|
margin-block: 0.618rem;
|
||||||
|
|
||||||
& * {
|
& li {
|
||||||
margin-left: 0.348rem;
|
margin-left: 0.618rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,11 @@
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.toc-content > p {
|
||||||
|
margin-top: calc(0.94rem - 6px);
|
||||||
|
margin-bottom: 0.318rem;
|
||||||
|
}
|
||||||
|
|
||||||
.toc-toggle {
|
.toc-toggle {
|
||||||
--width: 80svw;
|
--width: 80svw;
|
||||||
display: block;
|
display: block;
|
||||||
|
@ -132,8 +137,8 @@
|
||||||
margin: 0;
|
margin: 0;
|
||||||
margin-block: 0.618rem;
|
margin-block: 0.618rem;
|
||||||
|
|
||||||
& * {
|
& li {
|
||||||
margin-left: 0.348rem;
|
margin-left: 0.618rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue