From 9b71987efaab5c001b874dce320fc87bbb62ccda Mon Sep 17 00:00:00 2001 From: sli1989 Date: Wed, 21 Mar 2018 12:56:26 +0800 Subject: [PATCH 1/3] Update codeblock style and add border-radius settings --- _config.yml | 5 +++++ source/css/_common/components/highlight/highlight.styl | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index 2b01f9c48b..eeecb1d2f3 100644 --- a/_config.yml +++ b/_config.yml @@ -265,6 +265,11 @@ symbols_count_time: awl: 5 wpm: 200 +# codeblock border-radius settings +# If enabled, the codeblock would be loaded with rounded corners +codeblock: + rounded: false + # Wechat Subscriber #wechat_subscriber: #enabled: true diff --git a/source/css/_common/components/highlight/highlight.styl b/source/css/_common/components/highlight/highlight.styl index 6b540fdc3e..f217cf26d3 100644 --- a/source/css/_common/components/highlight/highlight.styl +++ b/source/css/_common/components/highlight/highlight.styl @@ -28,6 +28,7 @@ code { pre { @extend $code-block; padding: 10px; + if hexo-config('codeblock.rounded') { border-radius: 5px;} code { padding: 0; @@ -39,7 +40,8 @@ pre { .highlight { @extend $code-block; - border-radius: 1px + if hexo-config('codeblock.rounded') { border-radius: 5px;} + if not hexo-config('codeblock.rounded'){ border-radius: 1px;} pre { border: none; @@ -64,6 +66,10 @@ pre { color: $highlight-foreground; line-height: 1em; margin-bottom: 1em; + margin: 0em; + padding: 0.5em; + background: #eee; + border-bottom: 1px solid #e9e9e9; a { float: right; From 786f75aaa4c61d70eb4c9aaebfd1547eb0dcb944 Mon Sep 17 00:00:00 2001 From: sli1989 Date: Wed, 21 Mar 2018 18:03:07 +0800 Subject: [PATCH 2/3] Add border radius as variable --- _config.yml | 6 +++--- .../css/_common/components/highlight/highlight.styl | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/_config.yml b/_config.yml index eeecb1d2f3..312bfed6e7 100644 --- a/_config.yml +++ b/_config.yml @@ -265,10 +265,10 @@ symbols_count_time: awl: 5 wpm: 200 -# codeblock border-radius settings -# If enabled, the codeblock would be loaded with rounded corners +# Manual define the border radius in codeblock +# Leave it empty for the default 1 codeblock: - rounded: false + border_radius: # Wechat Subscriber #wechat_subscriber: diff --git a/source/css/_common/components/highlight/highlight.styl b/source/css/_common/components/highlight/highlight.styl index f217cf26d3..3c4f495baf 100644 --- a/source/css/_common/components/highlight/highlight.styl +++ b/source/css/_common/components/highlight/highlight.styl @@ -22,14 +22,12 @@ code { color: $code-foreground; background: $code-background; border-radius: $code-border-radius; - font-size $code-font-size; + font-size: $code-font-size; } pre { @extend $code-block; padding: 10px; - if hexo-config('codeblock.rounded') { border-radius: 5px;} - code { padding: 0; color: $highlight-foreground; @@ -40,8 +38,9 @@ pre { .highlight { @extend $code-block; - if hexo-config('codeblock.rounded') { border-radius: 5px;} - if not hexo-config('codeblock.rounded'){ border-radius: 1px;} + // Read values from NexT config and set they as local variables to use as string variables (in any CSS section). + hexo-config('codeblock.border_radius') is a 'unit' ? (cbradius = unit(hexo-config('codeblock.border_radius'), px)) : (cbradius = 1px) + border-radius: cbradius; pre { border: none; @@ -68,7 +67,7 @@ pre { margin-bottom: 1em; margin: 0em; padding: 0.5em; - background: #eee; + background: $gainsboro; border-bottom: 1px solid #e9e9e9; a { From ccbaed8b77fcfe6eb0dedc1ab46bfa22364283a0 Mon Sep 17 00:00:00 2001 From: "Ivan.Nginx" Date: Wed, 21 Mar 2018 13:08:48 +0300 Subject: [PATCH 3/3] Replace `$gainsboro` by `$code-background`. --- source/css/_common/components/highlight/highlight.styl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/css/_common/components/highlight/highlight.styl b/source/css/_common/components/highlight/highlight.styl index 3c4f495baf..9b52eb9f5f 100644 --- a/source/css/_common/components/highlight/highlight.styl +++ b/source/css/_common/components/highlight/highlight.styl @@ -65,10 +65,10 @@ pre { color: $highlight-foreground; line-height: 1em; margin-bottom: 1em; - margin: 0em; - padding: 0.5em; - background: $gainsboro; - border-bottom: 1px solid #e9e9e9; + margin: 0em; + padding: 0.5em; + background: $code-background; + border-bottom: 1px solid #e9e9e9; a { float: right;