forked from mirrors/hugo-theme-terminal
redesign code blocks
This commit is contained in:
@ -1,14 +1,15 @@
|
||||
code {
|
||||
color: var(--accent);
|
||||
border: 1px solid color-mix(in srgb, var(--foreground) 10%, transparent)
|
||||
:root {
|
||||
--code-border: color-mix(in srgb, var(--foreground) 10%, transparent);
|
||||
}
|
||||
|
||||
pre:not(.chroma),
|
||||
.highlight {
|
||||
pre:not(.chroma) {
|
||||
margin: 20px 0;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
pre.chroma {
|
||||
margin: 0;
|
||||
padding: 10px 0;
|
||||
color: var(--foreground);
|
||||
}
|
||||
|
||||
@ -17,10 +18,45 @@ pre code {
|
||||
border: none;
|
||||
}
|
||||
|
||||
code {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.highlight {
|
||||
position: relative;
|
||||
padding-top: 30px;
|
||||
margin: 20px 0;
|
||||
border: 1px solid var(--code-border);
|
||||
}
|
||||
|
||||
.highlight pre {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.chroma code[data-lang]:before {
|
||||
content: attr(data-lang);
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: auto;
|
||||
height: 30px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: color-mix(in srgb, var(--foreground) 5%, transparent);
|
||||
border-bottom: 1px solid var(--code-border);
|
||||
color: var(--comment);
|
||||
text-transform:uppercase;
|
||||
font-size: .8em;
|
||||
padding: 0 10px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.collapsable-code {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
margin: 40px 0;
|
||||
margin: 20px 0;
|
||||
border: 1px solid var(--accent);
|
||||
|
||||
.highlight {
|
||||
margin: 0;
|
||||
@ -28,9 +64,12 @@ pre code {
|
||||
}
|
||||
|
||||
.collapsable-code__title {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
color: var(--accent);
|
||||
padding: 3px 10px;
|
||||
font-size: .9em;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
@ -45,7 +84,6 @@ pre code {
|
||||
}
|
||||
|
||||
.collapsable-code summary {
|
||||
border-bottom: 1px solid var(--accent);
|
||||
color: var(--accent);
|
||||
padding: 0 10px;
|
||||
cursor: pointer;
|
||||
@ -56,12 +94,12 @@ pre code {
|
||||
}
|
||||
|
||||
.collapsable-code summary::marker {
|
||||
content: "+";
|
||||
/* content: "+"; */
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.collapsable-code[open] summary::marker {
|
||||
content: "-";
|
||||
/* content: "-"; */
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,20 +5,19 @@
|
||||
}
|
||||
|
||||
/* Background */ .bg { }
|
||||
/* PreWrapper */ pre.chroma { position: relative; padding:15px 0; }
|
||||
/* Custom:CodeInfo */ .chroma code[data-lang]:before { content: attr(data-lang);position:absolute;top:0;right:0;color:var(--comment);text-transform:uppercase;font-size:.8em;padding:.5em;line-height:1;}
|
||||
/* PreWrapper */ .chroma { overflow:auto; }
|
||||
/* Other */ .chroma .x { }
|
||||
/* Error */ .chroma .err { }
|
||||
/* CodeLine */ .chroma .cl { }
|
||||
/* LineLink */ .chroma .lnlinks { outline:none;text-decoration:none;color:inherit }
|
||||
/* Custom */ .chroma .lntd:first-child { width:auto;vertical-align:top;padding:0;margin:0;border:0; }
|
||||
/* LineTableTD */ .chroma .lntd { width:100%;vertical-align:top;padding:0;margin:0;border:0; }
|
||||
/* LineTableTDNumbers */ .chroma .lntd:first-child { width: auto; }
|
||||
/* Custom */ .chroma .lntd code { display:grid; }
|
||||
/* LineTable */ .chroma .lntable { border-spacing:0;padding:0;margin:0;border:0; }
|
||||
/* LineTable */ .chroma .lntable { width:100%;border-spacing:0;padding:0;margin:0;border:0; }
|
||||
/* LineHighlight */ .chroma .hl { background-color:color-mix(in srgb, var(--foreground) 5%, transparent) !important}
|
||||
/* LineNumbersTable */ .chroma .lnt { color:var(--comment);white-space:pre;-webkit-user-select:none;user-select:none;padding:0 15px; }
|
||||
/* LineNumbersTable */ .chroma .lnt { color:var(--comment);white-space:pre;-webkit-user-select:none;user-select:none;padding:0 10px; }
|
||||
/* LineNumbers */ .chroma .ln { color:var(--comment);white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.8em;padding:0 0.4em 0 0; }
|
||||
/* Line */ .chroma .line { display:flex;padding:0 15px; }
|
||||
/* Line */ .chroma .line { display:flex;padding:0 10px; }
|
||||
/* Keyword */ .chroma .k { color:var(--second-tone) }
|
||||
/* KeywordConstant */ .chroma .kc { color:var(--second-tone) }
|
||||
/* KeywordDeclaration */ .chroma .kd { color:var(--second-tone) }
|
||||
|
@ -1,15 +1,15 @@
|
||||
{{ $id := delimit (shuffle (seq 1 9)) "" }}
|
||||
{{ $open := .Get "open" }}
|
||||
{{ $lang := .Get "language" }}
|
||||
{{ $opts := .Get "opts" }}
|
||||
|
||||
{{- if $lang -}}
|
||||
<details class="collapsable-code" title="Click to interact" {{ if eq $open "true" -}} open {{- end }}>
|
||||
<summary>
|
||||
<span class="collapsable-code__language">{{ $lang }}</span>
|
||||
<details class="collapsable-code" {{ if eq $open "true" -}} open {{- end }}>
|
||||
<summary title="Click to interact">
|
||||
{{- if .Get "title" }}<span class="collapsable-code__title">{{ .Get "title" | markdownify }}</span>{{ end -}}
|
||||
</summary>
|
||||
{{ $trInner := trim .Inner "\n" }}
|
||||
{{- transform.Highlight $trInner ($lang) -}}
|
||||
{{- transform.Highlight $trInner $lang $opts -}}
|
||||
</details>
|
||||
{{ else }}
|
||||
{{ errorf "If you want to use the \"collapsable code\" shortcode, you need to pass a mandatory \"language\" param. The issue occured in %q (%q)" .Page.File .Page.Permalink }}
|
||||
|
Reference in New Issue
Block a user