Browse Source

feat(shortcodes): allow button disablement

use html attribute and allow disabled and true to disable

closes #65
Josh Habdas 1 year ago
parent
commit
7bbf79bbd4
Signed by: Josh Habdas <jhabdas@protonmail.com> GPG Key ID: B148B31154C75A74

+ 3
- 0
assets/css/theme.css View File

@@ -54,6 +54,9 @@ blockquote cite::before {
54 54
 :target {
55 55
   color: #fff;
56 56
 }
57
+:disabled {
58
+  cursor: not-allowed;
59
+}
57 60
 /* hack.css overrides and enhancements */
58 61
 .hack li ul {
59 62
   margin: 0;

+ 1
- 0
layouts/partials/components/button.html View File

@@ -4,6 +4,7 @@
4 4
   {{ with .target }}formtarget="{{ . }}" {{ end }}
5 5
   {{ with .tabindex }}tabindex="{{ . }}" {{ end }}
6 6
   {{ with .onclick }}onclick={{ . | safeJS }} {{ end }}
7
+  {{ if in (slice "true" "disabled") .disabled }}disabled {{ end }}
7 8
   {{ if in (slice "get" "post") .method }}formmethod="{{ .method }}" {{ end }}
8 9
   class="btn btn-{{ .type | default "default" }}{{ if eq .isghost "true" }} btn-ghost{{ end }}
9 10
   {{- if eq .isblock "true" }} btn-block{{ end }}"

+ 4
- 3
layouts/shortcodes/hackcss-button.html View File

@@ -1,6 +1,6 @@
1 1
 <!-- {{/*
2
-HTML attributes: "id", "action", "onclick", "tabindex", "target", "method"
3
-Custom attributes: "type", "text", "isghost", "isblock", "disabled"
2
+HTML attributes: "id", "action", "onclick", "tabindex", "target", "method", "disabled"
3
+Custom attributes: "type", "text", "isghost", "isblock"
4 4
 
5 5
 Available types: [default], "primary", "success", "info", "warning", "error"
6 6
 
@@ -36,7 +36,8 @@ Inside a button group:
36 36
 {{ $id := .Get "id" }}
37 37
 {{ $action := .Get "action" }}
38 38
 {{ $onclick := .Get "onclick" }}
39
+{{ $disabled := .Get "disabled" }}
39 40
 {{ $tabindex := .Get "tabindex" }}
40 41
 {{ $target := .Get "target" }}
41 42
 {{ $method := .Get "method" }}
42
-{{ partial "components/button.html" (dict "type" $type "body" $body "isghost" $isghost "isblock" $isblock "action" $action "onclick" $onclick "tabindex" $tabindex "target" $target "method" $method) }}
43
+{{ partial "components/button.html" (dict "type" $type "body" $body "isghost" $isghost "isblock" $isblock "action" $action "onclick" $onclick "disabled" $disabled "tabindex" $tabindex "target" $target "method" $method) }}

Loading…
Cancel
Save