Skip to content

Commit b029eea

Browse files
authored
feat(explorer): improve accessibility and consistency (+ bug fix) (#488)
* feat(consistency): use `all: unset` on button * style: improve accessibility and consistency for explorer * fix: localStorage bug with folder name changes * chore: bump quartz version
1 parent 6a9e635 commit b029eea

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@jackyzha0/quartz",
33
"description": "🌱 publish your digital garden and notes as a website",
44
"private": true,
5-
"version": "4.0.11",
5+
"version": "4.1.0",
66
"type": "module",
77
"author": "jackyzha0 <[email protected]>",
88
"license": "MIT",

quartz/components/Explorer.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default ((userOpts?: Partial<Options>) => {
7979
data-savestate={opts.useSavedState}
8080
data-tree={jsonTree}
8181
>
82-
<h3>{opts.title}</h3>
82+
<h1>{opts.title}</h1>
8383
<svg
8484
xmlns="http://www.w3.org/2000/svg"
8585
width="14"
@@ -98,7 +98,7 @@ export default ((userOpts?: Partial<Options>) => {
9898
<div id="explorer-content">
9999
<ul class="overflow" id="explorer-ul">
100100
<ExplorerNode node={fileTree} opts={opts} fileData={fileData} />
101-
<div id="explorer-end" />
101+
<li id="explorer-end" />
102102
</ul>
103103
</div>
104104
</div>

quartz/components/ExplorerNode.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export function ExplorerNode({ node, opts, fullPath, fileData }: ExplorerNodePro
145145
}
146146

147147
return (
148-
<div>
148+
<li>
149149
{node.file ? (
150150
// Single file node
151151
<li key={node.file.slug}>
@@ -174,17 +174,17 @@ export function ExplorerNode({ node, opts, fullPath, fileData }: ExplorerNodePro
174174
<polyline points="6 9 12 15 18 9"></polyline>
175175
</svg>
176176
{/* render <a> tag if folderBehavior is "link", otherwise render <button> with collapse click event */}
177-
<li key={node.name} data-folderpath={folderPath}>
177+
<div key={node.name} data-folderpath={folderPath}>
178178
{folderBehavior === "link" ? (
179179
<a href={`${folderPath}`} data-for={node.name} class="folder-title">
180180
{node.name}
181181
</a>
182182
) : (
183183
<button class="folder-button">
184-
<h3 class="folder-title">{node.name}</h3>
184+
<p class="folder-title">{node.name}</p>
185185
</button>
186186
)}
187-
</li>
187+
</div>
188188
</div>
189189
)}
190190
{/* Recursively render children of folder */}
@@ -210,6 +210,6 @@ export function ExplorerNode({ node, opts, fullPath, fileData }: ExplorerNodePro
210210
</div>
211211
</div>
212212
)}
213-
</div>
213+
</li>
214214
)
215215
}

quartz/components/scripts/explorer.inline.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,11 @@ function setupExplorer() {
113113
) as HTMLElement
114114

115115
// Get corresponding content <ul> tag and set state
116-
const folderUL = folderLi.parentElement?.nextElementSibling
117-
if (folderUL) {
118-
setFolderState(folderUL as HTMLElement, folderUl.collapsed)
116+
if (folderLi) {
117+
const folderUL = folderLi.parentElement?.nextElementSibling
118+
if (folderUL) {
119+
setFolderState(folderUL as HTMLElement, folderUl.collapsed)
120+
}
119121
}
120122
})
121123
} else {

quartz/components/styles/explorer.scss

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
button#explorer {
2+
all: unset;
23
background-color: transparent;
34
border: none;
45
text-align: left;
@@ -8,7 +9,7 @@ button#explorer {
89
display: flex;
910
align-items: center;
1011

11-
& h3 {
12+
& h1 {
1213
font-size: 1rem;
1314
display: inline-block;
1415
margin: 0;
@@ -58,7 +59,7 @@ button#explorer {
5859
max-height 0.35s ease,
5960
transform 0.35s ease,
6061
opacity 0.2s ease;
61-
& div > li > a {
62+
& li > a {
6263
color: var(--dark);
6364
opacity: 0.75;
6465
pointer-events: all;
@@ -92,7 +93,7 @@ svg {
9293
color: var(--tertiary) !important;
9394
}
9495

95-
& li > button {
96+
& div > button {
9697
color: var(--dark);
9798
background-color: transparent;
9899
border: none;
@@ -103,7 +104,7 @@ svg {
103104
display: flex;
104105
align-items: center;
105106

106-
& h3 {
107+
& p {
107108
font-size: 0.95rem;
108109
display: inline-block;
109110
color: var(--secondary);
@@ -138,5 +139,7 @@ div:has(> .folder-outer:not(.open)) > .folder-container > svg {
138139

139140
#explorer-end {
140141
// needs height so IntersectionObserver gets triggered
141-
height: 1px;
142+
height: 4px;
143+
// remove default margin from li
144+
margin: 0;
142145
}

0 commit comments

Comments
 (0)