summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-05-16 15:09:58 +0800
committerEltrac <hi@guhub.cn>2025-05-16 15:09:58 +0800
commit8dd852807c702f57467658b579c270ba29b8b7aa (patch)
tree522cfd80d9563cbbcebba9d294d42e1108aa991f
parent4b4629edb733d5ebd6485755fd2f63b0457f62c8 (diff)
refactor: rewrite TOC css with scss
-rw-r--r--layouts/partials/components/toc.html115
1 files changed, 50 insertions, 65 deletions
diff --git a/layouts/partials/components/toc.html b/layouts/partials/components/toc.html
index 660d4bb2..eb75badd 100644
--- a/layouts/partials/components/toc.html
+++ b/layouts/partials/components/toc.html
@@ -8,10 +8,7 @@
left: auto;
height: 100%;
top: 12rem;
-}
-
-@media screen and (max-width: 1200px) {
- #toc-container {
+ @media screen and (max-width: 1200px) {
display: none
}
}
@@ -23,70 +20,58 @@
/* styling */
font-size: 1rem;
padding: 0 2rem;
-}
-
-@media screen and (max-width: 1700px) {
- #toc {
- font-size: 0.9rem;
- }
-}
-
-@media screen and (max-width: 1500px) {
- #toc {
+ @media screen and (max-width: 1500px) {
font-size: 0.825rem;
}
-}
-
-#toc ul, #toc ol {
- margin-block-start: 0;
- margin-block-end: 0;
- padding-inline-start: 1rem;
-}
-#toc li {
- list-style: none;
-}
-
-#toc li > a {
- color: var(--secondary-text-color);
- text-decoration: none;
- transition: color .3s;
- display: inline-flex;
- align-items: center;
- gap: .5rem;
-}
-
-#toc li > a::before {
- content: '';
- display: inline-block;
- width: 1rem;
- height: .3rem;
- background-color: var(--block-background-color);
- border-radius: .2rem;
- transition: background .3s;
-}
-
-#toc li a:hover,
-#toc li.active > a {
- color: var(--text-color);
-}
-
-#toc li.active > a::before {
- background-color: var(--secondary-text-color);
-}
-
-#toc ul {
- overflow: hidden;
- position: relative;
-}
-
-#toc .toc-list ul {
- max-height: 25rem;
- overflow-y: auto
-}
-
-#toc li:not(.active) ul {
- max-height: 0
+ ul {
+ margin-block-start: 0;
+ margin-block-end: 0;
+ padding-inline-start: 1rem;
+
+ overflow: hidden;
+ position: relative;
+ li {
+ list-style: none;
+
+ & > a {
+ color: var(--secondary-text-color);
+ text-decoration: none;
+ transition: color .3s;
+ display: inline-flex;
+ align-items: center;
+ gap: .5rem;
+ &::before {
+ content: '';
+ display: inline-block;
+ width: 1rem;
+ height: .3rem;
+ background-color: var(--block-background-color);
+ border-radius: .2rem;
+ transition: background .3s;
+ }
+ }
+
+ /* nested list */
+ ul {
+ max-height: 25rem;
+ overflow-y: auto
+ }
+
+ /* active styles */
+ &:not(.active) ul {
+ max-height: 0
+ }
+ a:hover,
+ &.active > a {
+ color: var(--text-color);
+ }
+
+ &.active > a::before {
+ background-color: var(--secondary-text-color);
+ }
+ }
+ }
}
</style>
<script>