mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-18 10:50:24 +00:00
expand: rename open parameter to expanded #902
This commit is contained in:
parent
67fb8b987f
commit
0cb97716e0
4 changed files with 22 additions and 16 deletions
|
@ -20,6 +20,8 @@ This document shows you what's new in the latest release and flags it with one o
|
|||
|
||||
## 6.3.0.beta (XXXX-XX-XX) {#630}
|
||||
|
||||
- {{% badge style="note" title=" " %}}Change{{% /badge %}} The [`expand` shortcode](shortcodes/expand) changed the naming of the `open` parameter to `expanded`. You don't need to change anything yet but may get deprecation warnings.
|
||||
|
||||
- {{% badge style="note" title=" " %}}Change{{% /badge %}} If the content for the [`notice` shortcode](shortcodes/notice) is empty, now only the title bar will be displayed. Previously an empty content box was displayed.
|
||||
|
||||
- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The [`notice` shortcode](shortcodes/notice) has a new parameter `expanded` to make the content collapsible.
|
||||
|
|
|
@ -56,7 +56,7 @@ While the examples are using shortcodes with named parameter you are free to use
|
|||
| Name | Position | Default | Notes |
|
||||
|-----------------------|----------|------------------|-------------|
|
||||
| **title** | 1 | `"Expand me..."` | Arbitrary text to appear next to the expand/collapse icon. |
|
||||
| **open** | 2 | `false` | When `true` the content text will be initially shown as expanded. |
|
||||
| **expanded** | 2 | `false` | How the content is displayed.<br><br>- `true`: the content is initially shown<br>- `false`: the content is initially hidden |
|
||||
| _**<content>**_ | | _<empty>_ | Arbitrary text to be displayed on expand. |
|
||||
|
||||
## Examples
|
||||
|
@ -72,10 +72,10 @@ While the examples are using shortcodes with named parameter you are free to use
|
|||
### Initially Expanded
|
||||
|
||||
````go
|
||||
{{%/* expand title="Expand me..." open="true" */%}}No need to press you!{{%/* /expand */%}}
|
||||
{{%/* expand title="Expand me..." expanded="true" */%}}No need to press you!{{%/* /expand */%}}
|
||||
````
|
||||
|
||||
{{% expand title="Expand me..." open="true" %}}No need to press you!{{% /expand %}}
|
||||
{{% expand title="Expand me..." expanded="true" %}}No need to press you!{{% /expand %}}
|
||||
|
||||
### Arbitrary Text
|
||||
|
||||
|
|
|
@ -6,20 +6,23 @@
|
|||
{{- $content := .content }}
|
||||
{{- $title := .title | default (T "Expand-title") }}
|
||||
{{- $title = trim $title " " }}
|
||||
{{- $expanded := .open | default false }}
|
||||
{{- $expanded := .expanded | default false }}
|
||||
{{- if and (isset . "open") (or (ne (printf "%T" .open) "string") (ne (trim .open " " ) "")) }}
|
||||
{{- warnf "%q: DEPRECATED parameter 'open' for shortcode 'expand' found, use 'expanded' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#630" $page.File.Filename }}
|
||||
{{- $expanded = .open }}
|
||||
{{- end }}
|
||||
{{- if eq (printf "%T" $expanded) "string" }}
|
||||
{{- $expanded = (eq $expanded "true") }}
|
||||
{{- end }}
|
||||
{{- $id := cond (or (eq .id nil) (eq .id "")) (partial "make-random-md5.hugo" $page) .id }}
|
||||
{{- with $page }}
|
||||
<div class="expand">
|
||||
<input type="checkbox" id="R-expand-{{ $id }}" aria-controls="R-expandcontent-{{ $id }}" {{ if $expanded }} checked{{ end }}>
|
||||
<label class="expand-label" for="R-expand-{{ $id }}" >
|
||||
<i class="fa-fw fas fa-chevron-down"></i>
|
||||
<i class="fa-fw fas fa-chevron-right"></i>
|
||||
{{ $title | .RenderString }}
|
||||
</label>
|
||||
<div id="R-expandcontent-{{ $id }}" class="expand-content">
|
||||
<input type="checkbox" id="R-expand-{{ $id }}" aria-controls="R-expandcontent-{{ $id }}" {{ if $expanded }} checked{{ end }}>
|
||||
<label class="expand-label" for="R-expand-{{ $id }}">
|
||||
<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">
|
||||
{{ if ne "<" (substr (strings.TrimLeft " \n\r\t" $content) 0 1) }}<p>{{ end }}<!-- we add a DOM element here if there is none to make collapsing marings work -->
|
||||
{{ $content | safeHTML }}</div><!-- no line break allowed here because of awkward behavior of Hugo 110 or this theme when tag shortcode is called standalone outside of tags shortcode ? -->
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- $id := "" }}
|
||||
{{- partial "shortcodes/expand.html" (dict
|
||||
"page" .Page
|
||||
"content" .Inner
|
||||
"open" (.Get "open" | default (.Get 1))
|
||||
"title" (.Get "title" | default (.Get 0))
|
||||
"id" $id
|
||||
"page" .Page
|
||||
"content" .Inner
|
||||
"open" (.Get "open" | default "")
|
||||
"expanded" (.Get "expanded" | default (.Get 1))
|
||||
"title" (.Get "title" | default (.Get 0))
|
||||
"id" $id
|
||||
) }}
|
Loading…
Reference in a new issue