mirror of
https://github.com/gethinode/hinode.git
synced 2025-10-11 12:03:10 +00:00
93 lines
3.0 KiB
HTML
93 lines
3.0 KiB
HTML
<!--
|
|
Copyright © 2024 The Hinode Team / Mark Dumay. All rights reserved.
|
|
Use of this source code is governed by The MIT License (MIT) that can be found in the LICENSE file.
|
|
Visit gethinode.com/license for more details.
|
|
-->
|
|
|
|
{{ $error := false }}
|
|
|
|
<!-- Validate arguments -->
|
|
{{ if partial "utilities/IsInvalidArgs.html" (dict "structure" "button" "args" .Params "group" "shortcode") }}
|
|
{{ errorf "Invalid arguments: %s" .Position -}}
|
|
{{ $error = true }}
|
|
{{ end }}
|
|
|
|
<!-- Initialize arguments -->
|
|
{{ $type := "button" -}}
|
|
|
|
{{- $icon := .Get "icon" | default "" }}
|
|
{{ $title := trim .Inner " \r\n" | .Page.RenderString -}}
|
|
{{ if not (or $title $icon) -}}
|
|
{{ errorf "Missing icon or inner element text: %s" .Position -}}
|
|
{{ $error = true }}
|
|
{{ end -}}
|
|
|
|
{{ $state := .Get "state" | default "enabled" -}}
|
|
{{ $size := .Get "size" | default "md" -}}
|
|
{{ $color := .Get "color" | default "primary" -}}
|
|
{{ $outline := false -}}
|
|
{{ with .Get "outline" }}{{ $outline = partial "utilities/CastBool.html" . }}{{ end -}}
|
|
{{ $badge := .Get "badge" | default "" -}}
|
|
{{ $label := or (.Get "label") (.Get "aria-label") | default "" -}}
|
|
{{ $tooltip := .Get "tooltip" | default "" -}}
|
|
{{ $collapse := .Get "collapse" | default "" -}}
|
|
{{ $href := .Get "href" | default "" -}}
|
|
{{ $relref := .Get "relref" | default "" -}}
|
|
{{ $id := .Get "id" | default "" -}}
|
|
{{ if $relref }}
|
|
{{ $href = relref . $relref }}
|
|
{{ end }}
|
|
{{ $class := .Get "class" | default "" -}}
|
|
{{ $placement := .Get "placement" | default "top" -}}
|
|
{{- $toast := .Get "toast" | default "" -}}
|
|
{{- $order := .Get "order" | default "last" -}}
|
|
{{- $justify := .Get "justify" | default "center" -}}
|
|
{{- $cue := site.Params.main.externalLinks.cue -}}
|
|
{{ with .Get "cue" }}{{ $show = partial "utilities/CastBool.html" . }}{{ end -}}
|
|
{{- $tab := default site.Params.main.externalLinks.tab -}}
|
|
{{ with .Get "tab" }}{{ $show = partial "utilities/CastBool.html" . }}{{ end -}}
|
|
{{- $spacing := default (not .Parent) -}}
|
|
{{ with .Get "spacing" }}{{ $show = partial "utilities/CastBool.html" . }}{{ end -}}
|
|
|
|
<!-- Main code -->
|
|
{{ if not $error }}
|
|
{{- $output := partial "assets/button.html" (dict
|
|
"type" $type
|
|
"title" $title
|
|
"size" $size
|
|
"color" $color
|
|
"outline" $outline
|
|
"badge" $badge
|
|
"label" $label
|
|
"tooltip" $tooltip
|
|
"collapse" $collapse
|
|
"href" $href
|
|
"id" $id
|
|
"state" $state
|
|
"class" $class
|
|
"placement" $placement
|
|
"icon" $icon
|
|
"order" $order
|
|
"justify" $justify
|
|
"cue" $cue
|
|
"tab" $tab
|
|
"toast" $toast
|
|
"spacing" $spacing)
|
|
-}}
|
|
|
|
{{ with .Get "wrapper" }}
|
|
{{ $output = printf `<div class="%s">%s</div>` . $output }}
|
|
{{ end }}
|
|
|
|
{{- if .Parent -}}
|
|
{{ $current := .Parent.Scratch.Get "inner" }}
|
|
{{ if $current }}
|
|
{{ .Parent.Scratch.Set "inner" (print $current $output) }}
|
|
{{ else }}
|
|
{{ .Parent.Scratch.Set "inner" $output }}
|
|
{{ end }}
|
|
{{- else -}}
|
|
{{ $output | safeHTML }}
|
|
{{- end -}}
|
|
{{ end }}
|