Browse Source

feat($shortcodes): make button shortcode clickable

adds form actions to button groups and buttons for clickability

closes #40
Josh Habdas 2 years ago
parent
commit
fa24f4a21e
Signed by: Josh Habdas <jhabdas@protonmail.com> GPG Key ID: B148B31154C75A74

+ 2
- 1
layouts/shortcodes/hackcss-button.html View File

@@ -21,4 +21,5 @@ Available types: "default", "primary", "success", "info", "warning", "error"
21 21
 {{ $body := .Get "text" | default .Inner }}
22 22
 {{ $isghost := .Get "isghost" }}
23 23
 {{ $isblock := .Get "isblock" }}
24
-<button class="btn btn-{{ $type }} {{ if eq $isghost "true" }}btn-ghost{{ end }} {{ if eq $isblock "true" }}btn-block{{ end }}">{{ $body }}</button>
24
+{{ $action := .Get "action" }}
25
+<button {{ if $action }}formaction="{{ $action | safeURL }}" {{ end }}class="btn btn-{{ $type }}{{ if eq $isghost "true" }} btn-ghost{{ end }}{{ if eq $isblock "true" }} btn-block{{ end }}">{{ $body }}</button>

+ 18
- 2
layouts/shortcodes/hackcss-buttongroup.html View File

@@ -6,7 +6,23 @@ Basic usage:
6 6
   {{< hackcss-button text="Right" isghost="true" />}}
7 7
 {{< /hackcss-buttongroup >}}
8 8
 
9
+{{< hackcss-buttongroup >}}
10
+  {{< hackcss-button text="Left" action="/go/somewhere" />}}
11
+{{< /hackcss-buttongroup >}}
12
+
13
+Advanced usage:
14
+{{< hackcss-buttongroup action="#action" >}}
15
+  {{< hackcss-button text="Left" />}}
16
+  {{< hackcss-button text="Right" isghost="true" />}}
17
+{{< /hackcss-buttongroup >}}
18
+
19
+{{< hackcss-buttongroup action="#" >}}
20
+  {{< hackcss-button text="Left" action="#override" />}}
21
+  {{< hackcss-button text="Right" isghost="true" />}}
22
+{{< /hackcss-buttongroup >}}
23
+
9 24
 */}} -->
10
-<div class="btn-group">
25
+{{ $action := .Get "action" }}
26
+<form {{if $action }}action="{{ $action | safeURL }}" {{ end }}class="btn-group">
11 27
   {{- .Inner -}}
12
-</div>
28
+</form>

Loading…
Cancel
Save