Skip to content

Commit 55e272e

Browse files
committed
improve TOC style somewhat
1 parent 415c5f5 commit 55e272e

File tree

19 files changed

+60
-54
lines changed

19 files changed

+60
-54
lines changed

src/components/Header.astro

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,21 @@ if (!data) {
3939
sidebarData = undefined;
4040
}
4141
42-
const { headings } = Astro.props;
42+
const {
43+
title = null,
44+
headings = [],
45+
} = Astro.props;
4346
---
4447
<div class="header">
4548
<div class="header-item header-left">
46-
{url.length > 2 ?
47-
<Nav mobile={true}/>
48-
<div class="nav-collapsed-spacer header-spacer"/>
49-
: null}
49+
<Nav mobile={true}/>
5050
<h3 class="header-title">
5151
<a href="/">Quickshell</a>
5252
</h3>
5353
</div>
5454
<div class="header-item header-right">
5555
<Search/>
56-
<div class="header-spacer"/>
5756
<ThemeSelect client:load />
58-
{url.length > 2 ?
59-
<div class="toc-collapsed-spacer header-spacer"/>
60-
<TOC headings={headings} types={sidebarData} mobile={true}/>
61-
: null}
57+
<TOC title={title} headings={headings} types={sidebarData} mobile={true}/>
6258
</div>
6359
</div>

src/components/hooks/TOCIntersectionObserver.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
window.addEventListener('DOMContentLoaded', () => {
55
const observer = new IntersectionObserver(entries => {
66
entries.forEach(entry => {
7-
const heading = entry.target.querySelector('h2, h3, h4, h5, h6')
7+
const heading = entry.target.querySelector('h1, h2, h3, h4, h5, h6')
88
if(heading) {
99
const id = heading.id
1010
if (entry.intersectionRatio > 0) {

src/components/marquee/Marquee.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const videos = [
5252
</video>
5353
<p>
5454
Configuration by <Fragment set:html={author}/>
55-
{source ? <Fragment>(<a href={source}>source code</a>)</Fragment> : null}
55+
{source && <>(<a href={source}>source code</a>)</>}
5656
</p>
5757
</div>
5858
</div>)}

src/components/navigation/sidebars/TOC.astro

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@ import TableOfContents from "./toc";
33
import type { ConfigHeading, TypeTOC } from "./types.d.ts";
44
55
export interface Props {
6+
title?: string;
67
headings?: ConfigHeading[];
78
types?: TypeTOC;
89
mobile: boolean;
910
}
1011
11-
const { headings, types, mobile } = Astro.props;
12+
const { title, headings, types, mobile } = Astro.props;
1213
---
13-
14-
<div id="toc" aria-mobile={mobile} class=`toc-wrapper${mobile ? "-mobile":""}`>
15-
<TableOfContents
16-
config={headings}
17-
type={types}
18-
mobile={mobile}
19-
client:idle
20-
/>
21-
</div>
14+
{((headings?.length ?? 0) != 0 || types) &&
15+
<div id="toc" aria-mobile={mobile} class=`toc-wrapper${mobile ? "-mobile":""}`>
16+
<TableOfContents
17+
title={title}
18+
config={headings}
19+
type={types}
20+
mobile={mobile}
21+
client:idle
22+
/>
23+
</div>
24+
}

src/components/navigation/sidebars/toc/Table.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ import {
1111
import { Heading } from "./Heading";
1212

1313
export const Table: Component<{
14+
title?: string;
1415
typeTOC?: TypeTOC;
1516
configTOC?: ConfigTOC[];
1617
}> = props => {
17-
const { typeTOC, configTOC } = props;
18+
const { title, typeTOC, configTOC } = props;
1819

1920
if (configTOC) {
2021
return (
2122
<div class="toc-content">
22-
<p>Contents</p>
23+
{title && <>
24+
<p>{title}</p>
25+
<hr/>
26+
</>}
2327
<For each={configTOC}>
2428
{heading => (
2529
<Heading

src/components/navigation/sidebars/toc/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const TableOfContents: Component<TOCProps> = props => {
1515
const [open, setOpen] = createSignal<boolean>(false);
1616
const [clientWidth, setClientWidth] = createSignal<number>(0);
1717
const [screenWidth, setScreenWidth] = createSignal<number>(0);
18-
const { mobile, config, type } = props;
18+
const { mobile, title, config, type } = props;
1919
let tocRef: HTMLDivElement;
2020

2121
function toggle(e: MouseEvent) {
@@ -27,9 +27,10 @@ const TableOfContents: Component<TOCProps> = props => {
2727
return type ? (
2828
<Table typeTOC={type} />
2929
) : (
30-
<Table configTOC={buildHierarchy(config!)} />
30+
<Table title={title} configTOC={buildHierarchy(config!)} />
3131
);
3232
}
33+
3334
const handleClickOutside = (event: MouseEvent) => {
3435
const isLink = "href" in (event.target || {});
3536
const isInBody = document.body.contains(event.target as Node);
@@ -97,7 +98,7 @@ const TableOfContents: Component<TOCProps> = props => {
9798
{type ? (
9899
<Table typeTOC={type} />
99100
) : (
100-
<Table configTOC={buildHierarchy(config!)} />
101+
<Table title={title} configTOC={buildHierarchy(config!)} />
101102
)}
102103
</div>
103104
</div>

src/components/navigation/sidebars/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface TreeProps {
1717

1818
// Right
1919
export interface TOCProps {
20+
title?: string;
2021
config?: ConfigHeading[];
2122
type?: TypeTableProps;
2223
mobile: boolean;

src/config/io/helpers.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,16 @@ export function buildHierarchy(headings: ConfigHeading[]) {
2828
if (heading.depth === 1) {
2929
toc.push(heading);
3030
} else {
31-
parentHeadings
32-
.get(heading.depth - 1)
33-
.subheadings.push(heading);
31+
let depth = heading.depth - 1;
32+
let parent = null;
33+
34+
while (!parent && depth != 0) {
35+
parent = parentHeadings.get(depth);
36+
depth -= 1;
37+
}
38+
39+
if (parent) parent.subheadings.push(heading);
40+
else toc.push(heading);
3441
}
3542
}
3643
return toc;

src/guide/faq.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ title: "FAQ"
33
description: "Frequently Asked Questions"
44
index: 1000
55
---
6-
# {frontmatter.title}
7-
86
This page is being actively expanded as common questions come up again.
97

108
Make sure to also read the [Item Size and Position](/docs/guide/size-position) and

src/guide/index.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ title: "Usage Guide"
33
description: "Configuring the shell"
44
index: -1
55
---
6-
# {frontmatter.title}
7-
86
See the [Installation and Setup](/docs/guide/install-setup) page to get started.
97

108
To write a Quickshell config, start by following the

src/guide/install-setup.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: "Installation & Setup"
33
index: 0
44
---
5-
# {frontmatter.title}
65
> [!NOTE]
76
> Quickshell is still in a somewhat early stage of development.
87
> There will be breaking changes before 1.0, however a migration guide will be provided.

src/guide/introduction.mdx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
title: "Introduction"
33
index: 2
44
---
5-
6-
# {frontmatter.title}
7-
85
This page will walk you through the process of creating a simple bar/panel, and
96
introduce you to all the basic concepts involved. You can use the
107
[QML Language Reference](/docs/guide/qml-language) to learn about the syntax

src/guide/qml-language.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ index: 10
44
---
55
import Collapsible from "@components/Collapsible.astro";
66

7-
# {frontmatter.title}
8-
97
Quickshell is configured using the Qt Modeling Language, or QML.
108
This page explains what you need to know about QML to start using quickshell.
119

src/guide/size-position.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
title: "Item Size and Position"
33
index: 2
44
---
5-
# {frontmatter.title}
6-
75
> [!TIP]
86
> Read the entire page, understanding this is critical to building a well designed shell.
97

src/layouts/DocsLayout.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ if (url[2]) {
5959
<CreateCopyButtons />
6060
</head>
6161
<body class="docslayout">
62-
<Header headings={headings}/>
62+
<Header title={title} headings={headings}/>
6363
<div class="docslayout-root">
6464
<Nav mobile={false}/>
6565
<div class="docslayout-inner" data-pagefind-body>
@@ -89,10 +89,11 @@ if (url[2]) {
8989
></path></svg
9090
>
9191
</Breadcrumbs>
92-
<slot />
92+
<slot/>
9393
</div>
94+
<slot name="alongside-content"/>
9495
</div>
95-
<Footer />
96+
<Footer/>
9697
</body>
9798
</html>
9899

src/layouts/GuideLayout.astro

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import TOCIntersectionObserver from "@src/components/hooks/TOCIntersectionObserv
55
import type { ConfigHeading } from "@src/components/navigation/sidebars/types";
66
77
export interface Props {
8-
headings: ConfigHeading[];
98
title: string;
9+
headings: ConfigHeading[];
1010
description: string;
1111
}
1212
@@ -15,11 +15,12 @@ const { title, description, headings } = Astro.props;
1515
<DocsLayout title={title} description={description} headings={headings}>
1616
<div class="docs">
1717
<div class="docs-content">
18-
<hr>
18+
<hr/>
19+
<h1>{title}</h1>
1920
<slot/>
2021
</div>
21-
<TOC mobile={false} headings={headings} data-pagefind-ignore/>
2222
</div>
23+
<TOC slot="alongside-content" mobile={false} title={title} headings={headings} data-pagefind-ignore/>
2324
</DocsLayout>
2425

2526
<TOCIntersectionObserver/>

src/pages/docs/about.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
layout: "@layouts/GuideMdLayout.astro"
33
title: "About Quickshell"
44
---
5-
# {frontmatter.title}
65
Quickshell is a toolkit for building a desktop shell, which is to say components
76
of your desktop like bars, widgets, lock screens, display managers, and the like.
87

@@ -27,4 +26,4 @@ Quickshell is actively developed and will still receive breaking changes.
2726
A tagged release is planned soon, however there will be breakage before
2827
that point.
2928

30-
See the [Usage Guide](/docs/guide) to learn how to set up and use Quickshell
29+
See the [Usage Guide](/docs/guide) to learn how to set up and use Quickshell

src/styles/docs/toc/intro-toc.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
margin: 0;
2323
margin-block: 0.618rem;
2424

25-
& * {
26-
margin-left: 0.348rem;
25+
& li {
26+
margin-left: 0.618rem;
2727
}
2828
}
2929
}

src/styles/docs/toc/toc.css

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
background-color: transparent;
1818
}
1919

20+
.toc-content > p {
21+
margin-top: calc(0.94rem - 6px);
22+
margin-bottom: 0.318rem;
23+
}
24+
2025
.toc-toggle {
2126
--width: 80svw;
2227
display: block;
@@ -132,8 +137,8 @@
132137
margin: 0;
133138
margin-block: 0.618rem;
134139

135-
& * {
136-
margin-left: 0.348rem;
140+
& li {
141+
margin-left: 0.618rem;
137142
}
138143
}
139144
}

0 commit comments

Comments
 (0)