feat(ui): improve code snippet design
This commit is contained in:
parent
0c80552d77
commit
6d99f5cc36
4 changed files with 45 additions and 38 deletions
|
@ -219,11 +219,11 @@
|
||||||
|
|
||||||
{% if _left contains 'file="' %}
|
{% if _left contains 'file="' %}
|
||||||
{% assign _label_text = _left | split: 'file="' | last | split: '"' | first %}
|
{% assign _label_text = _left | split: 'file="' | last | split: '"' | first %}
|
||||||
{% assign _label_icon = 'far fa-file-code' %}
|
{% assign _label_icon = 'far fa-file-code fa-fw' %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% assign _lang = _left | split: 'language-' | last | split: ' ' | first %}
|
{% assign _lang = _left | split: 'language-' | last | split: ' ' | first %}
|
||||||
{% capture _label_text %}{% include language-alias.html language=_lang %}{% endcapture %}
|
{% capture _label_text %}{% include language-alias.html language=_lang %}{% endcapture %}
|
||||||
{% assign _label_icon = 'fas fa-code small' %}
|
{% assign _label_icon = 'fas fa-code fa-fw small' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% capture _label %}
|
{% capture _label %}
|
||||||
|
|
|
@ -32,7 +32,7 @@ html {
|
||||||
/* -- code snippets -- */
|
/* -- code snippets -- */
|
||||||
|
|
||||||
%code-snippet-bg {
|
%code-snippet-bg {
|
||||||
background: var(--highlight-bg-color);
|
background-color: var(--highlight-bg-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
%code-snippet-padding {
|
%code-snippet-padding {
|
||||||
|
@ -41,9 +41,6 @@ html {
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlighter-rouge {
|
.highlighter-rouge {
|
||||||
@extend %code-snippet-bg;
|
|
||||||
@extend %rounded;
|
|
||||||
|
|
||||||
color: var(--highlighter-rouge-color);
|
color: var(--highlighter-rouge-color);
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
margin-bottom: 1.2em; /* Override BS Inline-code style */
|
margin-bottom: 1.2em; /* Override BS Inline-code style */
|
||||||
|
@ -140,13 +137,25 @@ td.rouge-code {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div[class^='language-'] {
|
||||||
|
@extend %rounded;
|
||||||
|
@extend %code-snippet-bg;
|
||||||
|
|
||||||
|
box-shadow: var(--language-border-color) 0 0 0 1px;
|
||||||
|
|
||||||
|
.post-content > & {
|
||||||
|
@include ml-mr(-1.25rem);
|
||||||
|
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Hide line numbers for default, console, and terminal code snippets */
|
/* Hide line numbers for default, console, and terminal code snippets */
|
||||||
div {
|
div {
|
||||||
&[class^='highlighter-rouge'],
|
|
||||||
&.nolineno,
|
&.nolineno,
|
||||||
&.language-plaintext.highlighter-rouge,
|
&.language-plaintext,
|
||||||
&.language-console.highlighter-rouge,
|
&.language-console,
|
||||||
&.language-terminal.highlighter-rouge {
|
&.language-terminal {
|
||||||
pre.lineno {
|
pre.lineno {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -166,28 +175,15 @@ div {
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: $code-header-height;
|
height: $code-header-height;
|
||||||
|
|
||||||
&::before {
|
|
||||||
$dot-size: 0.75rem;
|
|
||||||
$dot-margin: 0.5rem;
|
|
||||||
|
|
||||||
content: '';
|
|
||||||
display: inline-block;
|
|
||||||
margin-left: 1rem;
|
margin-left: 1rem;
|
||||||
width: $dot-size;
|
margin-right: 0.25rem;
|
||||||
height: $dot-size;
|
|
||||||
border-radius: 50%;
|
|
||||||
background-color: var(--code-header-muted-color);
|
|
||||||
box-shadow: ($dot-size + $dot-margin) 0 0 var(--code-header-muted-color),
|
|
||||||
($dot-size + $dot-margin) * 2 0 0 var(--code-header-muted-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* the label block */
|
/* the label block */
|
||||||
span {
|
span {
|
||||||
/* label icon */
|
/* label icon */
|
||||||
i {
|
i {
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
margin-right: 0.4rem;
|
margin-right: 0.5rem;
|
||||||
color: var(--code-header-icon-color);
|
color: var(--code-header-icon-color);
|
||||||
|
|
||||||
&.small {
|
&.small {
|
||||||
|
@ -248,21 +244,30 @@ div {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media all and (max-width: 576px) {
|
@media all and (min-width: 576px) {
|
||||||
.post-content {
|
div[class^='language-'] {
|
||||||
> div[class^='language-'] {
|
.post-content > & {
|
||||||
@include ml-mr(-1.25rem);
|
@include ml-mr(0);
|
||||||
|
|
||||||
border-radius: 0;
|
border-radius: $base-radius;
|
||||||
|
|
||||||
.highlight {
|
|
||||||
padding-left: 0.25rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-header {
|
.code-header {
|
||||||
border-radius: 0;
|
@include ml-mr(0);
|
||||||
padding-left: 0.4rem;
|
|
||||||
padding-right: 0.5rem;
|
&::before {
|
||||||
|
$dot-size: 0.75rem;
|
||||||
|
$dot-margin: 0.5rem;
|
||||||
|
|
||||||
|
content: '';
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 1rem;
|
||||||
|
width: $dot-size;
|
||||||
|
height: $dot-size;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: var(--code-header-muted-color);
|
||||||
|
box-shadow: ($dot-size + $dot-margin) 0 0 var(--code-header-muted-color),
|
||||||
|
($dot-size + $dot-margin) * 2 0 0 var(--code-header-muted-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@mixin dark-syntax {
|
@mixin dark-syntax {
|
||||||
|
--language-border-color: rgba(84, 83, 83, 0.27);
|
||||||
--highlight-bg-color: #252525;
|
--highlight-bg-color: #252525;
|
||||||
--highlighter-rouge-color: #de6b18;
|
--highlighter-rouge-color: #de6b18;
|
||||||
--highlight-lineno-color: #6c6c6d;
|
--highlight-lineno-color: #6c6c6d;
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
.highlight .il { color: #009999; } /* Literal.Number.Integer.Long */
|
.highlight .il { color: #009999; } /* Literal.Number.Integer.Long */
|
||||||
|
|
||||||
/* --- custom light colors --- */
|
/* --- custom light colors --- */
|
||||||
|
--language-border-color: rgba(172, 169, 169, 0.2);
|
||||||
--highlight-bg-color: #f7f7f7;
|
--highlight-bg-color: #f7f7f7;
|
||||||
--highlighter-rouge-color: #3f596f;
|
--highlighter-rouge-color: #3f596f;
|
||||||
--highlight-lineno-color: #c2c6cc;
|
--highlight-lineno-color: #c2c6cc;
|
||||||
|
|
Loading…
Reference in a new issue