expand: use notice internally #953

This commit is contained in:
Sören Weber 2024-11-29 22:41:13 +01:00
parent 21dbabfdb4
commit e32ff04f06
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
9 changed files with 64 additions and 44 deletions

View file

@ -214,23 +214,15 @@ body .anchor {
body .badge, body .badge,
body .btn, body .btn,
body div.box { body div.box:not(.cstyle.transparent) {
box-shadow: box-shadow: 0 0 1px rgba(255, 255, 255, 1), 0 0 2px rgba(255, 255, 255, 1), 0 0 4px rgba(128, 128, 128, 1), 0 0 4px var(--VARIABLE-BOX-color);
0 0 1px rgba(255, 255, 255, 1),
0 0 2px rgba(255, 255, 255, 1),
0 0 4px rgba(128, 128, 128, 1),
0 0 4px var(--VARIABLE-BOX-color);
} }
body .badge > .badge-content, body .badge > .badge-content,
body .btn, body .btn,
body .btn > *, body .btn > *,
body div.box > .box-label { body div.box:not(.cstyle.transparent) > .box-label {
text-shadow: text-shadow: 0 0 1px rgba(255, 255, 255, 1), 0 0 2px rgba(255, 255, 255, 1), 0 0 4px rgba(128, 128, 128, 1), 0 0 4px var(--VARIABLE-BOX-CAPTION-color);
0 0 1px rgba(255, 255, 255, 1),
0 0 2px rgba(255, 255, 255, 1),
0 0 4px rgba(128, 128, 128, 1),
0 0 4px var(--VARIABLE-BOX-CAPTION-color);
} }
body .tab-panel-cstyle:not(.transparent), body .tab-panel-cstyle:not(.transparent),
@ -256,7 +248,7 @@ body .btn.cstyle.interactive.transparent > *:focus {
color: var(--INTERNAL-MAIN-TEXT-color); color: var(--INTERNAL-MAIN-TEXT-color);
} }
body .box.cstyle.transparent { body div.box.cstyle.transparent {
box-shadow: none; box-shadow: none;
} }

View file

@ -1518,8 +1518,8 @@ option {
} }
.expand { .expand {
margin-bottom: 1rem; margin-bottom: 1.5rem;
margin-top: 1rem; margin-top: 1.5rem;
position: relative; position: relative;
} }
@ -2762,6 +2762,30 @@ body.notfound #shrug svg {
width: 15rem; width: 15rem;
} }
/* notice box */
div.box.cstyle.transparent {
border-width: 0;
}
div.box.cstyle.transparent > .box-label {
margin: 0;
padding-bottom: 0;
padding-top: 0;
}
div.box.expand.cstyle.transparent > .box-label {
color: var(--INTERNAL-MAIN-LINK-color);
}
div.box.cstyle.transparent > .box-spacer {
display: none;
}
div.box.cstyle.transparent > .box-content {
margin-top: 0;
padding-bottom: 0;
}
/* color style definitions */ /* color style definitions */
.cstyle { .cstyle {

View file

@ -0,0 +1,13 @@
+++
disableToc = false
hidden = true
title = "Version 7.2"
type = "releasenotes"
weight = -1
+++
## 7.2.0.beta (XXXX-XX-XX) {#7-2-0}
### Change
- {{% badge style="note" title=" " %}}Change{{% /badge %}} Due to refactoring, the [`expand` shortcode](shortcodes/expand) and the [`notice` shortcode](shortcodes/notice) with `style=transparent` now generate slightly different margins.

View file

@ -23,6 +23,14 @@ That's some more text with a footnote.[^someid]
## Usage ## Usage
{{< tabs groupid="shortcode-parameter">}} {{< tabs groupid="shortcode-parameter">}}
{{% tab title="callout" %}}
````md
> [!transparent]- Expand me...
> Thank you!
````
{{% /tab %}}
{{% tab title="shortcode" %}} {{% tab title="shortcode" %}}
````go ````go
@ -50,7 +58,9 @@ That's some more text with a footnote.[^someid]
{{% /tab %}} {{% /tab %}}
{{< /tabs >}} {{< /tabs >}}
The [`notice` shortcode](shortcodes/notice) is also capable of displaying expandable/collapsible sections of text but with color options. [Extended callout syntax](https://gohugo.io/render-hooks/blockquotes/#extended-syntax) is available in other Markdown parsers like Obsidian and therefore is the recommend syntax for generating portable Markdown.
The [`notice` shortcode](shortcodes/notice) is also capable of displaying expandable/collapsible sections of text but with additional parameter for color and additional icons.
### Parameter ### Parameter

View file

@ -55,7 +55,7 @@ It is all about the boxes.
{{% /tab %}} {{% /tab %}}
{{< /tabs >}} {{< /tabs >}}
Callout syntax has limited features as it does not provide all of the below parameter. Nevertheless, it is widely available in other Markdown parsers like with [GitHub alerts](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts) or [Obsidian callouts](https://help.obsidian.md/Editing+and+formatting/Callouts#Change+the+title) and therefore is the recommend syntax for generating portable Markdown. Callout syntax has limited features as it does not provide all of the below parameter. Nevertheless, it is widely available in other Markdown parsers like [GitHub](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts) or [Obsidian](https://help.obsidian.md/Editing+and+formatting/Callouts#Change+the+title) and therefore is the recommend syntax for generating portable Markdown.
If you want to display a transparent expandable box without any border, you can also use the [`expand` shortcode](/shortcodes/expand). If you want to display a transparent expandable box without any border, you can also use the [`expand` shortcode](/shortcodes/expand).

View file

@ -3,11 +3,6 @@
{{- $page = .context }} {{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'expand' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/5/#5-18-0" $page.File.Filename }} {{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'expand' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/5/#5-18-0" $page.File.Filename }}
{{- end }} {{- end }}
{{- $content := trim .content "\n\r\t " }}
{{- $hasContent := ne (strings.TrimLeft "<p>" $content) "" }}
{{- if not (hasPrefix $content "<") }}
{{- $content = printf "<p>\n%s" $content }}
{{- end }}
{{- $title := .title | default (T "Expand-title") }} {{- $title := .title | default (T "Expand-title") }}
{{- $title = trim $title " " }} {{- $title = trim $title " " }}
{{- $expanded := .expanded | default false }} {{- $expanded := .expanded | default false }}
@ -18,18 +13,10 @@
{{- if eq (printf "%T" $expanded) "string" }} {{- if eq (printf "%T" $expanded) "string" }}
{{- $expanded = (eq $expanded "true") }} {{- $expanded = (eq $expanded "true") }}
{{- end }} {{- end }}
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "_relearn/makeRandomMd5.gotmpl" $page) .id }} {{- partial "shortcodes/notice.html" (dict
{{- with $page }} "page" .page
{{- if $hasContent -}} "content" .content
<div class="expand"> "expanded" $expanded
<input type="checkbox" id="R-expand-{{ $id }}" aria-controls="R-expandcontent-{{ $id }}"{{ if $expanded }} checked{{ end }}> "style" "transparent"
<label class="expand-label" for="R-expand-{{ $id }}"> "title" $title
<i class="expander-icon fa-fw fas fa-chevron-down"></i> ) }}
<i class="expander-icon fa-fw fas fa-chevron-right"></i> {{ $title | .RenderString }}
</label>
<div id="R-expandcontent-{{ $id }}" class="expand-content">
{{ $content | safeHTML }}
</div>
</div>
{{- end }}
{{- end }}

View file

@ -14,15 +14,11 @@
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
{{- $icon = printf "fa-fw fas fa-%s" $icon }} {{- $icon = printf "fa-fw fas fa-%s" $icon }}
{{- end }} {{- end }}
{{- $expander := false }}
{{- $expanded := .expanded | default "" }} {{- $expanded := .expanded | default "" }}
{{- if eq (printf "%T" $expanded) "string" }} {{- if eq (printf "%T" $expanded) "string" }}
{{- if ne (trim $expanded " ") "" }} {{- if ne (trim $expanded " ") "" }}
{{- $expander = true }}
{{- $expanded = (eq $expanded "true") }} {{- $expanded = (eq $expanded "true") }}
{{- end }} {{- end }}
{{- else }}
{{- $expander = true }}
{{- end }} {{- end }}
{{- $sort := .sort | default "asc" }} {{- $sort := .sort | default "asc" }}
{{- $pattern := .pattern | default "" }} {{- $pattern := .pattern | default "" }}

View file

@ -1 +1 @@
7.1.1+575353a9b128563d7d1a3c1fbbbb8e68d859ae47 7.1.1+21dbabfdb4bb1f5143ed79f24fb620988059f655

View file

@ -1,10 +1,8 @@
{{- $_hugo_config := `{ "version": 1 }` }} {{- $_hugo_config := `{ "version": 1 }` }}
{{- $id := "" }}
{{- partial "shortcodes/expand.html" (dict {{- partial "shortcodes/expand.html" (dict
"page" .Page "page" .Page
"content" .Inner "content" .Inner
"open" (.Get "open" | default "") "open" (.Get "open" | default "")
"expanded" (.Get "expanded" | default (.Get 1)) "expanded" (.Get "expanded" | default (.Get 1))
"title" (.Get "title" | default (.Get 0)) "title" (.Get "title" | default (.Get 0))
"id" $id
) }} ) }}