mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 05:14:06 -06:00
fix a11y for explorer
This commit is contained in:
parent
e98d97a271
commit
9691ef3e2e
@ -61,7 +61,7 @@ export default ((userOpts?: Partial<Options>) => {
|
|||||||
|
|
||||||
const Explorer: QuartzComponent = ({ cfg, displayClass }: QuartzComponentProps) => {
|
const Explorer: QuartzComponent = ({ cfg, displayClass }: QuartzComponentProps) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<nav
|
||||||
class={classNames(displayClass, "explorer")}
|
class={classNames(displayClass, "explorer")}
|
||||||
data-behavior={opts.folderClickBehavior}
|
data-behavior={opts.folderClickBehavior}
|
||||||
data-collapsed={opts.folderDefaultState}
|
data-collapsed={opts.folderDefaultState}
|
||||||
@ -78,6 +78,7 @@ export default ((userOpts?: Partial<Options>) => {
|
|||||||
class="explorer-toggle mobile-explorer hide-until-loaded"
|
class="explorer-toggle mobile-explorer hide-until-loaded"
|
||||||
data-mobile={true}
|
data-mobile={true}
|
||||||
aria-controls="explorer-content"
|
aria-controls="explorer-content"
|
||||||
|
aria-label="Explorer"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
@ -116,7 +117,7 @@ export default ((userOpts?: Partial<Options>) => {
|
|||||||
<polyline points="6 9 12 15 18 9"></polyline>
|
<polyline points="6 9 12 15 18 9"></polyline>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
<div class="explorer-content" aria-expanded={false}>
|
<div id="explorer-content">
|
||||||
<OverflowList class="explorer-ul" />
|
<OverflowList class="explorer-ul" />
|
||||||
</div>
|
</div>
|
||||||
<template id="template-file">
|
<template id="template-file">
|
||||||
@ -152,7 +153,7 @@ export default ((userOpts?: Partial<Options>) => {
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</nav>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -151,7 +151,7 @@ function createFolderNode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function setupExplorer(currentSlug: FullSlug) {
|
async function setupExplorer(currentSlug: FullSlug) {
|
||||||
const allExplorers = document.querySelectorAll("div.explorer") as NodeListOf<HTMLElement>
|
const allExplorers = document.querySelectorAll("nav.explorer") as NodeListOf<HTMLElement>
|
||||||
|
|
||||||
for (const explorer of allExplorers) {
|
for (const explorer of allExplorers) {
|
||||||
const dataFns = JSON.parse(explorer.dataset.dataFns || "{}")
|
const dataFns = JSON.parse(explorer.dataset.dataFns || "{}")
|
||||||
|
|||||||
@ -1,12 +1,14 @@
|
|||||||
@use "../../styles/variables.scss" as *;
|
@use "../../styles/variables.scss" as *;
|
||||||
|
|
||||||
@media all and ($mobile) {
|
@media all and ($mobile) {
|
||||||
.page > #quartz-body {
|
.page>#quartz-body {
|
||||||
|
|
||||||
// Shift page position when toggling Explorer on mobile.
|
// Shift page position when toggling Explorer on mobile.
|
||||||
& > :not(.sidebar.left:has(.explorer)) {
|
&> :not(.sidebar.left:has(.explorer)) {
|
||||||
transition: transform 300ms ease-in-out;
|
transition: transform 300ms ease-in-out;
|
||||||
}
|
}
|
||||||
&.lock-scroll > :not(.sidebar.left:has(.explorer)) {
|
|
||||||
|
&.lock-scroll> :not(.sidebar.left:has(.explorer)) {
|
||||||
transform: translateX(100dvw);
|
transform: translateX(100dvw);
|
||||||
transition: transform 300ms ease-in-out;
|
transition: transform 300ms ease-in-out;
|
||||||
}
|
}
|
||||||
@ -20,7 +22,7 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hide-until-loaded ~ .explorer-content {
|
.hide-until-loaded~#explorer-content {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,8 +35,10 @@
|
|||||||
|
|
||||||
min-height: 1.2rem;
|
min-height: 1.2rem;
|
||||||
flex: 0 1 auto;
|
flex: 0 1 auto;
|
||||||
|
|
||||||
&.collapsed {
|
&.collapsed {
|
||||||
flex: 0 1 1.2rem;
|
flex: 0 1 1.2rem;
|
||||||
|
|
||||||
& .fold {
|
& .fold {
|
||||||
transform: rotateZ(-90deg);
|
transform: rotateZ(-90deg);
|
||||||
}
|
}
|
||||||
@ -84,7 +88,7 @@
|
|||||||
pointer-events: all;
|
pointer-events: all;
|
||||||
transition: transform 0.35s ease;
|
transition: transform 0.35s ease;
|
||||||
|
|
||||||
& > polyline {
|
&>polyline {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,7 +112,7 @@ button.desktop-explorer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.explorer-content {
|
#explorer-content {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
@ -120,7 +124,7 @@ button.desktop-explorer {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
overscroll-behavior: contain;
|
overscroll-behavior: contain;
|
||||||
|
|
||||||
& li > a {
|
& li>a {
|
||||||
color: var(--dark);
|
color: var(--dark);
|
||||||
opacity: 0.75;
|
opacity: 0.75;
|
||||||
pointer-events: all;
|
pointer-events: all;
|
||||||
@ -142,7 +146,7 @@ button.desktop-explorer {
|
|||||||
grid-template-rows: 1fr;
|
grid-template-rows: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
.folder-outer > ul {
|
.folder-outer>ul {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-left: 6px;
|
margin-left: 6px;
|
||||||
padding-left: 0.8rem;
|
padding-left: 0.8rem;
|
||||||
@ -156,7 +160,7 @@ button.desktop-explorer {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
|
||||||
& div > a {
|
& div>a {
|
||||||
color: var(--secondary);
|
color: var(--secondary);
|
||||||
font-family: var(--headerFont);
|
font-family: var(--headerFont);
|
||||||
font-size: 0.95rem;
|
font-size: 0.95rem;
|
||||||
@ -165,11 +169,11 @@ button.desktop-explorer {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
& div > a:hover {
|
& div>a:hover {
|
||||||
color: var(--tertiary);
|
color: var(--tertiary);
|
||||||
}
|
}
|
||||||
|
|
||||||
& div > button {
|
& div>button {
|
||||||
color: var(--dark);
|
color: var(--dark);
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
@ -202,7 +206,7 @@ button.desktop-explorer {
|
|||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
li:has(> .folder-outer:not(.open)) > .folder-container > svg {
|
li:has(> .folder-outer:not(.open))>.folder-container>svg {
|
||||||
transform: rotate(-90deg);
|
transform: rotate(-90deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +219,7 @@ li:has(> .folder-outer:not(.open)) > .folder-container > svg {
|
|||||||
&.collapsed {
|
&.collapsed {
|
||||||
flex: 0 0 34px;
|
flex: 0 0 34px;
|
||||||
|
|
||||||
& > .explorer-content {
|
&>#explorer-content {
|
||||||
transform: translateX(-100vw);
|
transform: translateX(-100vw);
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
@ -224,13 +228,13 @@ li:has(> .folder-outer:not(.open)) > .folder-container > svg {
|
|||||||
&:not(.collapsed) {
|
&:not(.collapsed) {
|
||||||
flex: 0 0 34px;
|
flex: 0 0 34px;
|
||||||
|
|
||||||
& > .explorer-content {
|
&>#explorer-content {
|
||||||
transform: translateX(0);
|
transform: translateX(0);
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.explorer-content {
|
#explorer-content {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user