Welcome to mirror list, hosted at ThFree Co, Russian Federation.

button.html « partials « layouts - github.com/marketempower/axiom.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3738425fa3fc70fb1004e70303923f3eed607593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{{- if not .text }}
{{- errorf "Missing required 'text'. Partial: 'button'." -}}
{{- end }}
{{- $text := .text -}}
{{- $type := .type | default "default" -}}
{{- $id := .id -}}
{{- $class := "" -}}
{{- $svg := "" -}}
{{- with .icon }}
{{- $svg = printf "svg/%s.svg" . -}}
{{- $svg = partial $svg (dict "class" "fill-current h-4 w-auto mr-2") -}}
{{- $class = "inline-flex items-center" -}}
{{- end }}
{{- $dot := . -}}
{{- $href := "" -}}
{{- with .href }}
{{- $href = partial "cdn-src" (dict "Site" $.Site "Page" $dot "src" .) -}}
{{- end }}
{{/* verbose class names for purgecss */}}
{{- $textColor := index (dict "default" "text-raven-700" "base" "text-raven-900" "info" "text-blue-700" "warn" "text-orange-700" "alert" "text-red-700") $type -}}
{{- $bgColor := index (dict "default" "bg-raven-100" "base" "bg-white" "info" "bg-blue-100" "warn" "bg-orange-100" "alert" "bg-red-100") $type -}}
{{- $hoverColor := index (dict "default" "hover:bg-raven-200" "base" "hover:bg-raven-100" "info" "hover:bg-blue-200" "warn" "hover:bg-orange-200" "alert" "hover:bg-red-200") $type -}}
{{- $borderColor := index (dict "default" "" "base" "border border-raven-900" "info" "" "warn" "" "alert" "") $type -}}
{{- $class = printf "%s rounded font-content-sans font-semibold %s %s %s py-2 px-4 %s" $class $textColor $bgColor $hoverColor $borderColor -}}
{{- $class = trim $class " " -}}
{{- if $href }}
<a{{ with $id }} id="{{ . }}"{{ end }} class="{{ $class }}" href="{{ $href }}" role="button">
  {{- with $svg }}
  {{ . | safeHTML }}
  {{- end }}
  <span>{{ $text }}</span>
</a>
{{- else }}
<button class="{{ $class }}" role="button">
  {{- with $svg }}
  {{ . | safeHTML }}
  {{- end }}
  <span>{{ $text }}</span>
</button>
{{- end }}