Files
FixIt/assets/css/_partials/_single/_toc.scss
T
Cell 93478b47e1 refactor: code block wrapper (#665)
* feat: optimize code highlighting for diff language

* refactor: update codeblock configuration and enhance code wrapper functionality

* fix: extra blank lines would appear when copying lines containing code highlighting

* refactor: enhance code block wrapper functionality and add new styles (mac style)

* refactor: enhance code block normal mode

* feat: do noting for code block simple mode

* feat: add copy btn for code block modes mac and simple

* refactor: add code-related variables and update styles for code blocks and gist layout

* feat: update code copy button visibility on hover for larger screens

* feat: update code block mode attribute and remove mac wrapper

* feat!: code block parameters accurate to a single

Remove the `data-open` attribute and use `.open` instead.

* refactor: enhance initCopyCode method to accept optional button parameter

* feat: improve code/diagram copy button styles and transitions for better visibility

* fix: disable copy buttons for simple/mac mode code blocks when copyable set to false

* chore: rename normal partial to code-header

* feat: add preview and expand feature for code blocks (close #312)

* fix: adjust transition timing for code header and fade-out animation

* test: update code block test case

* docs: update comments for code highlight and markup configurations

* feat: adjust code header background color darkening for light and dark themes

* fix: hide aside and breadcrumb pseudo-elements on small screens

* perf: change the code copy button and code expand button to server-side rendering

* fix: the code expand button obscured the code content

* fix: update code background and header colors for improved visibility

* fix: ensure code copy button is only added for copyable code blocks

* feat(code block): add lineNosToggler and lineWrapToggler params and feature for code blocks

* refactor: code syntax highlighting styles

* fix: update background color for line numbers and ensure proper sticky effect

* feat(code block): add support for code file names in code blocks

* fix: code review for PR #665

* feat(i18n): add Japanese and Korean translations; update toggle options in multiple languages

* docs: update configurations and comments
2025-12-17 16:56:52 +08:00

332 lines
5.7 KiB
SCSS

// Common styles for all TOC types
.toc {
.toc-title {
font-size: $toc-title-font-size;
font-weight: bold;
text-transform: uppercase;
}
.toc-content {
font-size: $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: $single-link-color;
[data-theme='dark'] & {
color: $single-link-color-dark;
}
}
ul {
padding-left: 1em;
}
}
ol {
margin: 0;
padding-left: 2.25em;
ol {
padding-left: 1.25em;
}
li:has(> a:hover)::marker {
color: $single-link-color;
[data-theme='dark'] & {
color: $single-link-color-dark;
}
}
}
}
ruby {
background: $code-background-color;
rt {
color: $global-font-secondary-color;
}
[data-theme='dark'] & {
background: $code-background-color-dark;
rt {
color: $global-font-secondary-color-dark;
}
}
}
}
// Common active state styles for auto and dialog TOC
#toc-auto,
#toc-dialog {
.toc-content {
li.has-active {
&::marker {
color: $single-link-color;
[data-theme='dark'] & {
color: $single-link-color-dark;
}
}
&:has(> .active)::marker {
font-weight: bold;
}
> a {
color: $single-link-color;
[data-theme='dark'] & {
color: $single-link-color-dark;
}
}
}
ul {
a.active::before {
color: $single-link-hover-color;
[data-theme='dark'] & {
color: $single-link-hover-color-dark;
}
}
}
a.active {
font-weight: bold;
}
}
}
#toc-auto {
display: block;
position: sticky;
top: calc(#{$header-height} + var(#{$rootPrefix}breadcrumb-height));
box-sizing: border-box;
visibility: hidden;
@include overflow-wrap(break-word);
@include blur;
@extend .print-d-none;
[data-header-desktop='normal'] & {
#{$rootPrefix}scroll-mt: #{$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: $global-border-color;
[data-theme='dark'] & {
color: $global-border-color-dark;
}
}
i.toc-icon {
@include transition(transform 0.2s ease);
}
}
&.toc-hidden i.toc-icon {
@include transform(rotate(-90deg));
@include transition(transform 0.2s ease);
}
.toc-content {
overflow-y: scroll;
// TODO 这里计算错误,待重构
max-height: calc(100vh - #{2 * $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: darken($code-background-color, 3%);
[data-theme='dark'] & {
background: darken($code-background-color-dark, 6%);
}
}
.toc-content {
background-color: $code-background-color;
> nav {
> ul {
padding: 0.4em 1em 0.4em 1.8em;
a:hover {
font-weight: bold;
&::before {
color: $single-link-hover-color;
[data-theme='dark'] & {
color: $single-link-hover-color-dark;
}
}
}
}
> ol {
padding: 0.4em 1em 0.4em 2.25em;
li:has(> a:hover)::marker,
a:hover {
font-weight: bold;
}
}
}
[data-theme='dark'] & {
background-color: $code-background-color-dark;
}
}
&.open {
.toc-title {
background: darken($code-background-color, 6%);
[data-theme='dark'] & {
background: darken($code-background-color-dark, 3%);
}
}
}
}
#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(100%, 500px);
height: 100%;
max-width: 100%;
max-height: 100%;
margin-right: 0;
border: none;
.toc {
max-width: 100%;
margin-inline: 1rem 5rem;
.toc-title {
font-size: $toc-title-font-size * 1.5;
line-height: $toc-title-font-size * 2;
margin-block: $toc-title-font-size;
}
.toc-content {
font-size: max($toc-content-font-size, 1rem);
nav {
max-height: calc(100vh - 5rem);
overflow: auto;
}
}
}
&::backdrop {
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: 4rem 0;
}
@starting-style {
&[open],
&[open]::backdrop {
opacity: 0;
}
&[open] {
translate: 100vw 0;
}
}
}
html:has(#toc-dialog[open]) {
overflow: hidden;
}