Files
FixIt/assets/css/_page/_single/_toc.scss
T
Cell 3926cc0220 refactor: reorganize CSS structure and standardize CSS variable usage for improved maintainability (#690)
* refactor: CSS variables to use fixit-var for consistency across styles

* refactor: reorganize CSS structure and consolidate imports for improved maintainability

* refactor: unify CSS variable usage and improve structure across stylesheets

* refactor: standardize CSS variable usage for layout

* refactor: standardize CSS variable usage for archive and special pages

* refactor: standardize CSS variable usage for single page

* refactor: standardize CSS variable usage for widgets

* refactor(css): refactors the border-radius mixin and adds the .rounded-full utility class

* refactor: standardize z-index usage across components

* refactor(css): removes deprecated compatibility mixins and replaces them with native CSS properties

* feat: unify color variable naming and update theme color values

- Rename `global-font-secondary-color` to `global-placeholder-color` for more accurate description of its purpose
- Update multiple style references to use the new `secondary` theme color variable
- Update theme color mapping to the new color values ​​for improved visual consistency
- Fixed the use of search box placeholder colors and removed hard-coded transparency values
- Added color preview test documentation for easier verification of color rendering
- Cleaned up some duplicate dark mode styles and replaced them with unified CSS variables

* refactor: remove the `hr-background-color` variable and uses `global-border-color` uniformly

* feat(CSE): add dark theme style to Google CSE search box and results container

* fix(task-lists): fixed styling and rendering issues with nested task lists
2026-02-28 17:24:10 +08:00

292 lines
5.3 KiB
SCSS

// Common styles for all TOC types
.toc {
.toc-title {
font-size: fixit-var(toc-title-font-size);
font-weight: bold;
text-transform: uppercase;
}
.toc-content {
font-size: fixit-var(toc-content-font-size);
code {
@extend %code;
}
ul {
margin: 0;
text-indent: -0.8em;
padding-left: 0.8em;
list-style: none;
a:first-child::before {
content: '|';
font-weight: bolder;
margin-right: 0.5em;
position: relative;
bottom: 2px;
color: fixit-var(single-link-color);
}
ul {
padding-left: 1em;
}
}
ol {
margin: 0;
padding-left: 2.25em;
ol {
padding-left: 1.25em;
}
li:has(> a:hover)::marker {
color: fixit-var(single-link-color);
}
}
}
ruby {
background-color: fixit-var(code-block-background-color);
rt {
color: fixit-var(secondary);
}
}
}
// Common active state styles for auto and dialog TOC
#toc-auto,
#toc-dialog {
.toc-content {
li.has-active {
&::marker {
color: fixit-var(single-link-color);
}
&:has(> .active)::marker {
font-weight: bold;
}
> a {
color: fixit-var(single-link-color);
}
}
ul {
a.active::before {
color: fixit-var(single-link-hover-color);
}
}
a.active {
font-weight: bold;
}
}
}
#toc-auto {
display: block;
position: sticky;
top: calc(#{fixit-var(header-height)} + #{fixit-var(breadcrumb-height)});
box-sizing: border-box;
visibility: hidden;
@include overflow-wrap(break-word);
@include blur;
@extend .print-d-none;
[data-header-desktop='normal'] & {
@include set-fixit-var(scroll-mt, fixit-var(global-scroll-margin-top));
}
.toc-title {
margin-block: 0 0.5em;
cursor: pointer;
@include user-select(none);
&::before {
content: '|';
font-weight: bolder;
margin-right: 0.5em;
position: relative;
bottom: 2px;
color: fixit-var(global-border-color);
}
i.toc-icon {
transition: transform 0.2s ease;
}
}
&.toc-hidden i.toc-icon {
transform: rotate(-90deg);
transition: transform 0.2s ease;
}
.toc-content {
overflow-y: scroll;
// TODO 这里计算错误,待重构使用 JS 计算
max-height: calc(100vh - #{2 * #{fixit-var(header-height)}});
@include scrollbar-width(none, 0);
&.always-active ul,
&.always-active ol {
display: block;
}
// for unordered list automatically collapsed
ul {
ul {
display: none;
}
.has-active > ul {
display: block;
}
}
// for ordered list automatically collapsed
ol {
ol {
display: none;
}
.has-active > ol {
display: block;
}
}
}
}
#toc-static {
display: none;
margin: 0.8em 0;
&[data-kept='true'] {
display: block;
}
.toc-title {
display: flex;
justify-content: space-between;
line-height: 2em;
padding: 0 0.75em;
background-color: fixit-var(code-header-background-color);
}
.toc-content {
background-color: fixit-var(code-block-background-color);
> nav {
> ul {
padding: 0.4em 1em 0.4em 1.8em;
a:hover {
font-weight: bold;
&::before {
color: fixit-var(single-link-hover-color);
}
}
}
> ol {
padding: 0.4em 1em 0.4em 2.25em;
li:has(> a:hover)::marker,
a:hover {
font-weight: bold;
}
}
}
}
&:not(.open) {
.toc-title {
@include set-fixit-var(code-header-background-color, darken($code-background-color, 6%));
[data-theme=dark] & {
@include set-fixit-var(code-header-background-color, darken($code-background-color-dark, 6%));
}
}
}
}
#toc-dialog {
transition:
display 0.2s allow-discrete,
overlay 0.2s allow-discrete,
translate 0.2s,
opacity 0.2s 0.4s;
opacity: 0;
translate: 100vw 0;
width: MIN(calc(100% - 4rem), 460px);
height: 100dvh;
max-width: 100%;
max-height: 100%;
margin-right: 0;
border: none;
border-left: 1px solid fixit-var(global-border-color);
background-color: fixit-var(global-background-color);
.toc {
max-width: 100%;
margin-inline: 1rem;
.toc-title {
font-size: calc(#{fixit-var(toc-title-font-size)} * 1.5);
line-height: calc(#{fixit-var(toc-title-font-size)} * 2);
margin-block: fixit-var(toc-title-font-size);
}
.toc-content {
font-size: MAX(fixit-var(toc-content-font-size), 1rem);
nav {
max-height: calc(100dvh - 5rem);
overflow: auto;
}
}
}
&::backdrop {
background-color: rgba(0, 0, 0, 0.25);
backdrop-filter: blur(2px);
transition:
display 0.5s allow-discrete,
overlay 0.5s allow-discrete,
opacity 0.2s 0.4s;
opacity: 0;
}
&[open],
&[open]::backdrop {
opacity: 1;
transition:
display 0.2s allow-discrete,
overlay 0.2s allow-discrete,
translate 0.2s,
opacity 0.2s;
}
&[open] {
translate: 0 0;
}
@starting-style {
&[open],
&[open]::backdrop {
opacity: 0;
}
&[open] {
translate: 100vw 0;
}
}
}
html:has(#toc-dialog[open]) {
overflow: hidden;
}