mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-26 22:34:06 -06:00
Added collapsible callouts
This commit is contained in:
parent
1f8a8a2fe7
commit
9bb9e42417
6
assets/js/callouts.js
Normal file
6
assets/js/callouts.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
const addCollapsibleCallouts = () => {
|
||||||
|
const collapsibleCallouts = document.querySelectorAll("blockquote.callout-collapsible");
|
||||||
|
collapsibleCallouts.forEach(el => el.addEventListener('click', event => {
|
||||||
|
event.currentTarget.classList.toggle("callout-collapsed");
|
||||||
|
}));
|
||||||
|
}
|
||||||
@ -52,7 +52,18 @@
|
|||||||
--callout-warning-accent: #7f4800 !important;
|
--callout-warning-accent: #7f4800 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockquote[class$="-callout"] {
|
blockquote.callout-collapsible {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
blockquote.callout-collapsed {
|
||||||
|
border-bottom-right-radius: 5px !important;
|
||||||
|
padding-bottom: 0 !important;
|
||||||
|
}
|
||||||
|
blockquote.callout-collapsed > p:not(:first-child) {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockquote[class*="-callout"] {
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -61,14 +72,14 @@ blockquote[class$="-callout"] {
|
|||||||
color: var(--dark);
|
color: var(--dark);
|
||||||
background-color: var(--outlinegray);
|
background-color: var(--outlinegray);
|
||||||
}
|
}
|
||||||
blockquote[class$="-callout"] > p {
|
blockquote[class*="-callout"] > p {
|
||||||
border-top-right-radius: 5px;
|
border-top-right-radius: 5px;
|
||||||
padding-left: 1em;
|
padding-left: 1em;
|
||||||
padding-right: 1em;
|
padding-right: 1em;
|
||||||
color: var(--dark);
|
color: var(--dark);
|
||||||
background-color: var(--outlinegray);
|
background-color: var(--outlinegray);
|
||||||
}
|
}
|
||||||
blockquote[class$="-callout"] > p:first-child::after {
|
blockquote[class*="-callout"] > p:first-child::after {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
width: 18px;
|
width: 18px;
|
||||||
@ -77,10 +88,11 @@ blockquote[class$="-callout"] > p:first-child::after {
|
|||||||
left: 6px;
|
left: 6px;
|
||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
blockquote[class$="-callout"] > p:first-child {
|
blockquote[class*="-callout"] > p:first-child {
|
||||||
font-size: 125%;
|
font-size: 125%;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
padding-left: 30px;
|
padding-left: 30px;
|
||||||
|
border-bottom-right-radius: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockquote.abstract-callout,
|
blockquote.abstract-callout,
|
||||||
|
|||||||
@ -24,15 +24,15 @@
|
|||||||
|
|
||||||
<!-- CSS Stylesheets and Fonts -->
|
<!-- CSS Stylesheets and Fonts -->
|
||||||
{{$sass := resources.Match "styles/[!_]*.scss" }}
|
{{$sass := resources.Match "styles/[!_]*.scss" }}
|
||||||
|
{{ if (not $.Site.Data.config.enableCallouts) }}
|
||||||
|
{{ $calloutsCss := resources.Get "styles/callouts.scss" }}
|
||||||
|
{{$sass = $sass | symdiff (slice $calloutsCss)}}
|
||||||
|
{{end}}
|
||||||
{{$css := slice }}
|
{{$css := slice }}
|
||||||
{{range $sass}}
|
{{range $sass}}
|
||||||
{{$scss := . | resources.ToCSS (dict "outputStyle" "compressed") }}
|
{{$scss := . | resources.ToCSS (dict "outputStyle" "compressed") }}
|
||||||
{{$css = $css | append $scss}}
|
{{$css = $css | append $scss}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{ if $.Site.Data.config.enableCallouts }}
|
|
||||||
{{ $calloutsCss := resources.Get "styles/callouts.scss" | resources.ToCSS (dict "outputStyle" "compressed") }}
|
|
||||||
{{$css = $css | append $calloutsCss}}
|
|
||||||
{{end}}
|
|
||||||
{{$finalCss := $css | resources.Concat "styles.css" | resources.Fingerprint "md5" | resources.Minify }}
|
{{$finalCss := $css | resources.Concat "styles.css" | resources.Fingerprint "md5" | resources.Minify }}
|
||||||
<link href="{{$finalCss.Permalink}}" rel="stylesheet" />
|
<link href="{{$finalCss.Permalink}}" rel="stylesheet" />
|
||||||
|
|
||||||
@ -62,6 +62,11 @@
|
|||||||
<script src="{{$clipboard.Permalink}}"></script>
|
<script src="{{$clipboard.Permalink}}"></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if $.Site.Data.config.enableCallouts }}
|
||||||
|
{{ $callouts := resources.Get "js/callouts.js" | resources.Fingerprint "md5" | resources.Minify }}
|
||||||
|
<script src="{{$callouts.Permalink}}"></script>
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<!-- Preload page vars -->
|
<!-- Preload page vars -->
|
||||||
{{$linkIndex := resources.Get "indices/linkIndex.json" | resources.Fingerprint
|
{{$linkIndex := resources.Get "indices/linkIndex.json" | resources.Fingerprint
|
||||||
"md5" | resources.Minify | }} {{$contentIndex := resources.Get
|
"md5" | resources.Minify | }} {{$contentIndex := resources.Get
|
||||||
@ -101,6 +106,10 @@
|
|||||||
addTitleToCodeBlocks();
|
addTitleToCodeBlocks();
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{if $.Site.Data.config.enableCallouts -}}
|
||||||
|
addCollapsibleCallouts();
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{if $.Site.Data.config.enableFooter}}
|
{{if $.Site.Data.config.enableFooter}}
|
||||||
const container = document.getElementById("graph-container")
|
const container = document.getElementById("graph-container")
|
||||||
// retry if the graph is not ready
|
// retry if the graph is not ready
|
||||||
|
|||||||
@ -68,8 +68,14 @@
|
|||||||
{{ $finder = index $blockquoteclasses1 $counter }}
|
{{ $finder = index $blockquoteclasses1 $counter }}
|
||||||
{{ if (in $finder "[!") }}
|
{{ if (in $finder "[!") }}
|
||||||
{{ $inner := index $blockquoteclasses $counter1 }}
|
{{ $inner := index $blockquoteclasses $counter1 }}
|
||||||
{{ $inner = $inner | replaceRE `\[!([a-zA-Z]+)\]` `${1}` }}
|
{{ if (in $finder "]-") }}
|
||||||
{{ $inner = printf "blockquote class=%s-callout" $inner}}
|
{{ $inner = $inner | replaceRE `\[!([a-zA-Z]+)\]` `callout-collapsible callout-collapsed ${1}`}}
|
||||||
|
{{ else if (in $finder "]+") }}
|
||||||
|
{{ $inner = $inner | replaceRE `\[!([a-zA-Z]+)\]` `callout-collapsible ${1}`}}
|
||||||
|
{{ else}}
|
||||||
|
{{ $inner = $inner | replaceRE `\[!([a-zA-Z]+)\]` `${1}` }}
|
||||||
|
{{ end }}
|
||||||
|
{{ $inner = printf "blockquote class=\"%s-callout\"" $inner}}
|
||||||
{{ $content = replace $content . $inner 1}}
|
{{ $content = replace $content . $inner 1}}
|
||||||
{{ $counter1 = add $counter1 1 }}
|
{{ $counter1 = add $counter1 1 }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user