mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-10-27 02:33:18 +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}
|
## 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="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.
|
- {{% 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 |
|
| Name | Position | Default | Notes |
|
||||||
|-----------------------|----------|------------------|-------------|
|
|-----------------------|----------|------------------|-------------|
|
||||||
| **title** | 1 | `"Expand me..."` | Arbitrary text to appear next to the expand/collapse icon. |
|
| **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. |
|
| _**<content>**_ | | _<empty>_ | Arbitrary text to be displayed on expand. |
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
@ -72,10 +72,10 @@ While the examples are using shortcodes with named parameter you are free to use
|
||||||
### Initially Expanded
|
### Initially Expanded
|
||||||
|
|
||||||
````go
|
````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
|
### Arbitrary Text
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,11 @@
|
||||||
{{- $content := .content }}
|
{{- $content := .content }}
|
||||||
{{- $title := .title | default (T "Expand-title") }}
|
{{- $title := .title | default (T "Expand-title") }}
|
||||||
{{- $title = trim $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" }}
|
{{- if eq (printf "%T" $expanded) "string" }}
|
||||||
{{- $expanded = (eq $expanded "true") }}
|
{{- $expanded = (eq $expanded "true") }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
@ -15,9 +19,8 @@
|
||||||
<div class="expand">
|
<div class="expand">
|
||||||
<input type="checkbox" id="R-expand-{{ $id }}" aria-controls="R-expandcontent-{{ $id }}" {{ if $expanded }} checked{{ end }}>
|
<input type="checkbox" id="R-expand-{{ $id }}" aria-controls="R-expandcontent-{{ $id }}" {{ if $expanded }} checked{{ end }}>
|
||||||
<label class="expand-label" for="R-expand-{{ $id }}">
|
<label class="expand-label" for="R-expand-{{ $id }}">
|
||||||
<i class="fa-fw fas fa-chevron-down"></i>
|
<i class="expander-icon fa-fw fas fa-chevron-down"></i>
|
||||||
<i class="fa-fw fas fa-chevron-right"></i>
|
<i class="expander-icon fa-fw fas fa-chevron-right"></i> {{ $title | .RenderString }}
|
||||||
{{ $title | .RenderString }}
|
|
||||||
</label>
|
</label>
|
||||||
<div id="R-expandcontent-{{ $id }}" class="expand-content">
|
<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 -->
|
{{ 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 -->
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
{{- partial "shortcodes/expand.html" (dict
|
{{- partial "shortcodes/expand.html" (dict
|
||||||
"page" .Page
|
"page" .Page
|
||||||
"content" .Inner
|
"content" .Inner
|
||||||
"open" (.Get "open" | default (.Get 1))
|
"open" (.Get "open" | default "")
|
||||||
|
"expanded" (.Get "expanded" | default (.Get 1))
|
||||||
"title" (.Get "title" | default (.Get 0))
|
"title" (.Get "title" | default (.Get 0))
|
||||||
"id" $id
|
"id" $id
|
||||||
) }}
|
) }}
|
Loading…
Reference in a new issue