Files
hinode/layouts/shortcodes/tooltip.html
2024-01-01 12:32:39 +01:00

45 lines
1.3 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" "tooltip" "args" .Params) }}
{{ errorf "Invalid arguments: %s" .Position -}}
{{ $error = true }}
{{ end }}
<!-- Initialize arguments -->
{{ $type := "link" -}}
{{ $title := trim .Inner " \r\n" | plainify -}}
{{ if not $title -}}
{{ errorf "Missing inner element text: %s" .Position -}}
{{ $error = true }}
{{ end -}}
{{ $color := .Get "color" | default "primary" -}}
{{ $tooltip := .Get "title" | default "" -}}
{{ $href := .Get "href" | default "" -}}
{{ $placement := .Get "placement" | default "top" -}}
{{- $class := .Get "class" | default "" -}}
{{- $spacing := .Get "spacing" | default true -}}
<!-- Main code -->
{{ if not $error }}
<div class="d-inline-flex">
{{- partial "assets/button.html" (dict
"type" $type
"title" $title
"color" $color
"tooltip" $tooltip
"href" $href
"placement" $placement
"class" $class
"spacing" $spacing)
-}}
</div>
{{ end }}