🚧 Change the code block style settings.

This commit is contained in:
凡梦星尘 2022-06-29 08:56:13 +08:00
parent 748c44e25d
commit b9cd603c04
5 changed files with 44 additions and 37 deletions

View File

@ -1,6 +1,3 @@
.highlight:hover .copy-btn, pre:hover .copy-btn {
opacity: 1;
}
.highlight { .highlight {
@ -15,38 +12,45 @@
} }
} }
.copy-btn { @if $codeblock_copy_btn_enable {
color: $black-dim;
cursor: pointer;
line-height: 1.6;
opacity: 0;
padding: 2px 6px;
position: absolute;
right: 8px;
top: 4px;
transition: opacity $transition-ease;
background: var(--highlight-background);
@if $codeblock_copy_btn_style == 'flat' { .highlight:hover .copy-btn, pre:hover .copy-btn {
background: white; opacity: 1;
border: 0; }
font-size: $font-size-smaller;
.copy-btn {
} @else if $codeblock_copy_btn_style == 'mac' { color: $black-dim;
color: var(--highlight-foreground); cursor: pointer;
font-size: 14px; line-height: 1.6;
border-radius: 3px; opacity: 0;
} @else { padding: 2px 6px;
background-color: $gainsboro; position: absolute;
background-image: linear-gradient(#fcfcfc, $gainsboro); right: 8px;
border: 1px solid #d5d5d5; top: 4px;
border-radius: 3px; transition: opacity $transition-ease;
font-size: $font-size-smaller; background: var(--highlight-background);
@if $codeblock_style == 'flat' {
background: white;
border: 0;
font-size: $font-size-smaller;
} @else if $codeblock_style == 'mac' {
color: var(--highlight-foreground);
font-size: 14px;
border-radius: 3px;
} @else {
background-color: $gainsboro;
background-image: linear-gradient(#fcfcfc, $gainsboro);
border: 1px solid #d5d5d5;
border-radius: 3px;
font-size: $font-size-smaller;
}
} }
} }
@if $codeblock_copy_btn_style == 'mac' { @if $codeblock_style == 'mac' {
.highlight { .highlight {
border-radius: 5px; border-radius: 5px;
box-shadow: 0 10px 30px 0 rgba(0, 0, 0, .4); box-shadow: 0 10px 30px 0 rgba(0, 0, 0, .4);
@ -65,4 +69,4 @@
@include round-icon(12px); @include round-icon(12px);
} }
} }
} }

View File

@ -52,7 +52,8 @@ $highlight_dark_foreground : #fff;
$highlight_light_background : #565656; $highlight_light_background : #565656;
$highlight_light_foreground : #fff; $highlight_light_foreground : #fff;
$codeblock_copy_btn_style : {{ $P.codeblock.copyBtn.style }}; $codeblock_copy_btn_enable : {{ $P.codeblock.copyBtn }};
$codeblock_style : {{ $P.codeblock.style }};
// Sidebar // Sidebar
$sidebar_offset : {{ $P.sidebar.offset }}; $sidebar_offset : {{ $P.sidebar.offset }};
@ -113,7 +114,9 @@ $reading_progress_reversed : {{ $P.readingProgress.reversed }};
// Thirdparty // Thirdparty
$math_mathjax_enable : {{ $P.math.mathjax.enable }}; $math_mathjax_enable : {{ $P.math.mathjax.enable }};
$related_posts_enable : {{ $P.relatedPosts.enable }}; // TODO
//$related_posts_enable : {{ $P.relatedPosts.enable }};
$related_posts_enable : false;
$pdf_enable : {{ $P.pdf.enable }}; $pdf_enable : {{ $P.pdf.enable }};
$pdf_height : {{ $P.pdf.height }}; $pdf_height : {{ $P.pdf.height }};

View File

@ -10,7 +10,7 @@ if (!window.NexT) window.NexT = {};
"darkmode" : {{ .Site.Params.darkmode }}, "darkmode" : {{ .Site.Params.darkmode }},
"version" : "{{ .Site.Data.config.version }}", "version" : "{{ .Site.Data.config.version }}",
"sidebar" : {{ .Site.Params.sidebar | jsonify }}, "sidebar" : {{ .Site.Params.sidebar | jsonify }},
"copycode" : {{ .Site.Params.codeblock.copyBtn | jsonify }}, "copybtn" : {{ .Site.Params.codeblock.copyBtn }},
"bookmark" : {{ .Site.Params.bookmark | jsonify }}, "bookmark" : {{ .Site.Params.bookmark | jsonify }},
"comments" : {{ .Site.Params.comments | jsonify }}, "comments" : {{ .Site.Params.comments | jsonify }},
"mediumzoom" : {{ .Site.Params.mediumzoom }}, "mediumzoom" : {{ .Site.Params.mediumzoom }},

View File

@ -45,7 +45,7 @@ NexT.boot.refresh = function() {
CONFIG.pangu && window.pangu.spacingPage(); CONFIG.pangu && window.pangu.spacingPage();
CONFIG.isPage && NexT.utils.replacePostCRLink(); CONFIG.isPage && NexT.utils.replacePostCRLink();
CONFIG.isPage && NexT.utils.registerCopyCode(); CONFIG.isPage && CONFIG.copybtn && NexT.utils.registerCopyCode();
NexT.utils.registerTabsTag(); NexT.utils.registerTabsTag();
/*NexT.utils.registerActiveMenuItem(); /*NexT.utils.registerActiveMenuItem();
NexT.utils.registerLangSelect();*/ NexT.utils.registerLangSelect();*/

View File

@ -41,7 +41,7 @@ NexT.utils = {
*/ */
registerCopyCode: function() { registerCopyCode: function() {
let figure = document.querySelectorAll('.highlight pre'); let figure = document.querySelectorAll('.highlight pre');
if (figure.length === 0 || !CONFIG.copycode) return; if (figure.length === 0 || !CONFIG.copybtn) return;
figure.forEach(element => { figure.forEach(element => {
let cn = element.querySelector('code').className; let cn = element.querySelector('code').className;
// TODO seems hard code need find other ways fixed it. // TODO seems hard code need find other ways fixed it.