fix(layout): grid triage and regression (#1440)

* fix(table of contents): multiple scrollbars (https://github.com/jackyzha0/quartz/issues/1388)

* fix(center): Main content mininum width (https://github.com/jackyzha0/quartz/issues/1439)

* fix(code block): Horizontal overflow fix (https://github.com/jackyzha0/quartz/issues/1438, https://github.com/jackyzha0/quartz/issues/1353)

* WIP fix for ul/ol .overflow

* Fix: restore former scrollbar behavior for overflow lists (https://github.com/jackyzha0/quartz/issues/1437)

* Fix: code block overflow-x

* fix: Table of Content overflow (https://github.com/jackyzha0/quartz/issues/1437)

* Address feedback

* Move max-height toggle from js to css
This commit is contained in:
Emile Bangma 2024-09-25 23:20:58 +02:00 committed by GitHub
parent 921f45cf70
commit a7a0dcad22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 34 additions and 23 deletions

View File

@ -25,7 +25,6 @@ function toggleExplorer(this: HTMLElement) {
if (!content) return if (!content) return
content.classList.toggle("collapsed") content.classList.toggle("collapsed")
content.style.maxHeight = content.style.maxHeight === "0px" ? content.scrollHeight + "px" : "0px"
} }
function toggleFolder(evt: MouseEvent) { function toggleFolder(evt: MouseEvent) {

View File

@ -23,7 +23,6 @@ function toggleToc(this: HTMLElement) {
const content = this.nextElementSibling as HTMLElement | undefined const content = this.nextElementSibling as HTMLElement | undefined
if (!content) return if (!content) return
content.classList.toggle("collapsed") content.classList.toggle("collapsed")
content.style.maxHeight = content.style.maxHeight === "0px" ? content.scrollHeight + "px" : "0px"
} }
function setupToc() { function setupToc() {
@ -32,7 +31,6 @@ function setupToc() {
const collapsed = toc.classList.contains("collapsed") const collapsed = toc.classList.contains("collapsed")
const content = toc.nextElementSibling as HTMLElement | undefined const content = toc.nextElementSibling as HTMLElement | undefined
if (!content) return if (!content) return
content.style.maxHeight = collapsed ? "0px" : content.scrollHeight + "px"
toc.addEventListener("click", toggleToc) toc.addEventListener("click", toggleToc)
window.addCleanup(() => toc.removeEventListener("click", toggleToc)) window.addCleanup(() => toc.removeEventListener("click", toggleToc))
} }

View File

@ -1,9 +1,10 @@
@use "../../styles/variables.scss" as *; @use "../../styles/variables.scss" as *;
.backlinks { .backlinks {
@media all and not ($desktop) { @media all and not ($mobile) {
overflow-y: auto; overflow-y: auto;
display: initial; display: flex;
flex-direction: column;
&:after { &:after {
pointer-events: none; pointer-events: none;
content: ""; content: "";
@ -17,10 +18,6 @@
background: linear-gradient(transparent 0px, var(--light)); background: linear-gradient(transparent 0px, var(--light));
} }
&:has(> .overflow) {
position: unset;
}
& > h3 { & > h3 {
font-size: 1rem; font-size: 1rem;
margin: 0; margin: 0;
@ -39,10 +36,6 @@
} }
& > .overflow { & > .overflow {
max-height: unset;
& > li:last-of-type {
margin-bottom: 0;
}
&:after { &:after {
display: none; display: none;
} }

View File

@ -1,8 +1,13 @@
@use "../../styles/variables.scss" as *; @use "../../styles/variables.scss" as *;
.explorer { .explorer {
display: flex;
flex-direction: column;
overflow-y: hidden;
&.desktop-only { &.desktop-only {
overflow-y: auto; @media all and not ($mobile) {
display: flex;
}
} }
&:after { &:after {
pointer-events: none; pointer-events: none;
@ -62,7 +67,8 @@ button#explorer {
#explorer-content { #explorer-content {
list-style: none; list-style: none;
overflow: hidden; overflow: hidden;
max-height: none; overflow-y: auto;
max-height: 100%;
transition: transition:
max-height 0.35s ease, max-height 0.35s ease,
visibility 0s linear 0s; visibility 0s linear 0s;
@ -70,6 +76,7 @@ button#explorer {
visibility: visible; visibility: visible;
&.collapsed { &.collapsed {
max-height: 0;
transition: transition:
max-height 0.35s ease, max-height 0.35s ease,
visibility 0s linear 0.35s; visibility 0s linear 0.35s;

View File

@ -1,5 +1,10 @@
.toc { .toc {
overflow-y: auto; display: flex;
flex-direction: column;
&.desktop-only {
display: flex;
max-height: 40%;
}
} }
button#toc { button#toc {
@ -32,17 +37,19 @@ button#toc {
#toc-content { #toc-content {
list-style: none; list-style: none;
overflow: hidden; overflow: hidden;
max-height: none; overflow-y: auto;
max-height: 100%;
transition: transition:
max-height 0.5s ease, max-height 0.35s ease,
visibility 0s linear 0s; visibility 0s linear 0s;
position: relative; position: relative;
visibility: visible; visibility: visible;
&.collapsed { &.collapsed {
max-height: 0;
transition: transition:
max-height 0.5s ease, max-height 0.35s ease,
visibility 0s linear 0.5s; visibility 0s linear 0.35s;
visibility: hidden; visibility: hidden;
} }
@ -65,6 +72,9 @@ button#toc {
} }
} }
} }
> ul.overflow {
max-height: none;
}
@for $i from 0 through 6 { @for $i from 0 through 6 {
& .depth-#{$i} { & .depth-#{$i} {

View File

@ -250,6 +250,8 @@ a {
& .center, & .center,
& footer { & footer {
max-width: 100%;
min-width: 100%;
margin-left: auto; margin-left: auto;
margin-right: auto; margin-right: auto;
@media all and ($desktop) { @media all and ($desktop) {
@ -416,7 +418,7 @@ pre {
counter-increment: line 0; counter-increment: line 0;
display: grid; display: grid;
padding: 0.5rem 0; padding: 0.5rem 0;
overflow-x: scroll; overflow-x: auto;
& [data-highlighted-chars] { & [data-highlighted-chars] {
background-color: var(--highlight); background-color: var(--highlight);
@ -535,12 +537,15 @@ video {
} }
div:has(> .overflow) { div:has(> .overflow) {
display: flex;
position: relative; position: relative;
overflow-y: auto;
max-height: 100%;
} }
ul.overflow, ul.overflow,
ol.overflow { ol.overflow {
max-height: 400; max-height: 100%;
overflow-y: auto; overflow-y: auto;
// clearfix // clearfix
@ -550,7 +555,6 @@ ol.overflow {
& > li:last-of-type { & > li:last-of-type {
margin-bottom: 30px; margin-bottom: 30px;
} }
&:after { &:after {
pointer-events: none; pointer-events: none;
content: ""; content: "";