1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-12-18 05:41:31 +00:00

feat: support vertical scrolling for toc in desktop mode (#2064)

This commit is contained in:
Cotes Chung
2024-11-28 02:58:25 +08:00
parent 11647697bb
commit 5265b03974
5 changed files with 61 additions and 13 deletions

View File

@@ -154,3 +154,7 @@
%max-w-100 {
max-width: 100%;
}
%panel-border {
border-left: 1px solid var(--main-border-color);
}

View File

@@ -6,7 +6,6 @@
top: 2rem;
transition: top 0.2s ease-in-out;
margin-top: 3rem;
margin-bottom: 4rem;
&:only-child {
position: -webkit-sticky;
@@ -14,11 +13,12 @@
}
> section {
padding-left: 1rem;
border-left: 1px solid var(--main-border-color);
@extend %panel-border;
&:not(:last-child) {
margin-bottom: 4rem;
padding-left: 1rem;
&:not(:first-child) {
margin-top: 4rem;
}
}
@@ -48,6 +48,10 @@
}
}
> :last-child {
margin-bottom: 4rem;
}
@include bp.lt(bp.get(xl)) {
display: none;
}

View File

@@ -246,14 +246,26 @@ header {
}
/* TOC panel */
#toc-wrapper {
border-left: 1px solid rgba(158, 158, 158, 0.17);
position: -webkit-sticky;
%top-cover {
content: '';
display: block;
position: sticky;
top: 4rem;
top: 0;
width: 100%;
height: 3rem;
background: linear-gradient(var(--main-bg) 50%, transparent);
}
#toc-wrapper {
top: 0;
transition: top 0.2s ease-in-out;
-webkit-animation: fade-up 0.8s;
animation: fade-up 0.8s;
overflow-y: auto;
max-height: calc(100vh - 2rem);
scrollbar-width: none;
margin-top: 2rem;
ul {
list-style: none;
@@ -266,6 +278,10 @@ header {
margin: 0.4rem 0;
}
&:first-child {
margin-top: 0;
}
a {
padding: 0.2rem 0 0.2rem 1.25rem;
}
@@ -295,7 +311,6 @@ header {
&::before {
display: inline-block;
width: 1px;
left: -1px;
height: 1.25rem;
background-color: var(--toc-highlight) !important;
}
@@ -305,6 +320,30 @@ header {
padding-left: 0.75rem;
}
}
@at-root .toc-border-cover {
@extend %top-cover;
margin-bottom: -4rem;
}
&::before {
@extend %top-cover;
}
&::after {
content: '';
position: fixed;
bottom: 0;
width: 15%;
height: 3.25rem;
margin-left: -1px;
background: linear-gradient(transparent, var(--main-bg) 70%);
}
> * {
@extend %panel-border;
}
}
/* --- TOC button, bar and popup in mobile/tablet --- */