2023-07-27 14:14:55 +00:00
{{- $page := .page }}
{{- if and (not $page) .context }}
{{- $page = .context }}
2024-09-29 21:54:17 +00:00
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'notice' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/5/#5-18-0" $page.File.Filename }}
2023-07-27 14:14:55 +00:00
{{- end }}
2024-09-05 19:25:52 +00:00
{{- $class := .class | default "notices" }}
{{- $containerstyle := .containerstyle | default "div" }}
{{- $containerclass := .containerclass | default slice | append "box-content" }}
2023-01-23 21:35:43 +00:00
{{- $color := .color | default "" }}
2024-09-05 18:02:38 +00:00
{{- $content := trim .content "\n\r\t " }}
2024-12-09 17:53:02 +00:00
{{- $hasContent := ne (strings.TrimPrefix "< p > " $content) "" }}
2024-09-05 18:02:38 +00:00
{{- if not (hasPrefix $content "< ") }}
{{- $content = printf "< p > \n%s" $content }}
{{- end }}
2024-11-30 18:36:58 +00:00
{{- $groupid := .groupid }}
2022-06-22 18:32:18 +00:00
{{- $style := .style | default "default" }}
2024-09-12 05:55:24 +00:00
{{- $boxStyle := partial "_relearn/boxStyle.gotmpl" (dict "style" $style "title" .title "icon" .icon) }}
{{- $title := trim ($boxStyle.title) " " }}
{{- $icon := trim ($boxStyle.icon) " " }}
2022-06-22 18:32:18 +00:00
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
{{- $icon = printf "fa-fw fas fa-%s" $icon }}
{{- end }}
2024-09-01 11:56:39 +00:00
{{- $expander := false }}
{{- $expanded := .expanded | default "" }}
{{- if $hasContent }}
{{- if eq (printf "%T" $expanded) "string" }}
{{- if ne (trim $expanded " ") "" }}
{{- $expander = true }}
{{- $expanded = (eq $expanded "true") }}
{{- end }}
{{- else }}
{{- $expander = true }}
{{- end }}
{{- end }}
2024-12-01 21:17:19 +00:00
{{- $params := .params | default dict }}
{{- $classes := split (index $params "class" | default "") " " }}
{{- $classes = $classes | append "box" }}
{{- $classes = $classes | append "cstyle" }}
{{- $classes = $classes | append $class }}
{{- $classes = $classes | append $style }}
{{- if $expander }}
{{- $classes = $classes | append "expand" }}
{{- else }}
{{- $expanded = true }}
{{- end }}
{{- $params = dict "class" (delimit $classes " ") | merge $params }}
{{- if $color }}
{{- $styles := split (index $params "style" | default "") ";" }}
2024-12-01 21:38:48 +00:00
{{- $styles = $styles | append (printf "--VARIABLE-BOX-color: %s" $color) }}
2024-12-01 21:17:19 +00:00
{{- $params = dict "style" (delimit $styles ";") | merge $params }}
{{- end }}
{{ if $groupid }}
{{- $params = dict "name" $groupid | merge $params }}
{{- end }}
2023-07-27 14:14:55 +00:00
{{- with $page }}
2024-09-05 18:02:38 +00:00
{{- if or $icon $title $hasContent -}}
2024-12-01 21:17:19 +00:00
< details
{{- if $expanded }} open{{ end }}
{{- range $k, $v := $params }}
{{- if not (or (in (slice "open" "summary") $k) (strings.HasPrefix $k "on")) }}
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
{{- end }}
{{- end }}>
2024-12-29 17:48:41 +00:00
< summary class = "box-label{{ if and (not $expander) (not $icon) (not $title) }} a11y-only{{ end }}" { { if not $ expander } } tabindex = "-1" { { end } } > {{ if $expander }}
2024-11-30 18:10:52 +00:00
< i class = "expander-icon fa-fw fas fa-chevron-right" > < / i > {{ end }}{{ if $icon }}
< i class = "{{ $icon }}" > < / i > {{ end }}{{ if $title }}
{{ $title | .RenderString }}{{ else }}
< span class = "a11y-only" > {{ T "Details" }}< / span > {{ end }}
< / summary >
2024-09-03 17:08:30 +00:00
{{- if $hasContent }}
2024-11-30 18:10:52 +00:00
{{ printf " < %s class=\"%s\">" $containerstyle (delimit $containerclass " ") | safeHTML }}
2024-09-05 18:02:38 +00:00
{{ $content | safeHTML }}
2024-09-05 19:25:52 +00:00
{{ printf " < /%s>" $containerstyle | safeHTML }}
2024-09-03 17:08:30 +00:00
{{- end }}
2024-11-30 18:10:52 +00:00
< / details >
2024-09-03 17:08:30 +00:00
{{- end }}
2022-06-22 18:32:18 +00:00
{{- end }}