Browse Source

refactor(snippets): urlize id attributes

ensures id attr values are valid, adds id to button
Josh Habdas 1 year ago
parent
commit
14c2b37bd9
Signed by: Josh Habdas <jhabdas@protonmail.com> GPG Key ID: B148B31154C75A74

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

@@ -1,4 +1,5 @@
1 1
 <button
2
+  {{ with .id }}id="{{ . | urlize }}" {{ end }}
2 3
   {{ with .action }}formaction="{{ . | safeURL }}" {{ end }}
3 4
   {{ with .target }}formtarget="{{ . }}" {{ end }}
4 5
   {{ with .tabindex }}tabindex="{{ . }}" {{ end }}

+ 5
- 1
layouts/partials/components/common/textattrs.html View File

@@ -11,7 +11,11 @@
11 11
           {{ $name }}="{{ $value }}"
12 12
         {{ end }}
13 13
       {{ else }}
14
-        {{ $name }}="{{ $value }}"
14
+        {{ if eq $name "id" }}
15
+          {{ $name }}="{{ $value | urlize }}"
16
+        {{ else }}
17
+          {{ $name }}="{{ $value }}"
18
+        {{ end }}
15 19
       {{ end }}
16 20
     {{ end }}
17 21
   {{ end }}

+ 1
- 1
layouts/partials/components/select.html View File

@@ -1,4 +1,4 @@
1
-<select{{ with .id }} id="{{ . }}"{{ end }} class="form-control">
1
+<select{{ with .id }} id="{{ . | urlize }}"{{ end }} class="form-control">
2 2
   {{ range .options }}
3 3
     <option>{{ . }}</option>
4 4
   {{ end }}

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

@@ -1,5 +1,7 @@
1 1
 <!-- {{/*
2
-Permitted attributes: "type", "text", "isghost", "isblock", "action", "onclick", "tabindex", "target", "method"
2
+HTML attributes: "id", "action", "onclick", "tabindex", "target", "method"
3
+Custom attributes: "type", "text", "isghost", "isblock"
4
+
3 5
 Available types: [default], "primary", "success", "info", "warning", "error"
4 6
 
5 7
 Basic usage:
@@ -20,7 +22,7 @@ With loading indicator:
20 22
 
21 23
 Inside a button group:
22 24
 {{< hackcss-buttongroup >}}
23
-  {{< hackcss-button text="Default Action" isghost="true" />}}
25
+  {{< hackcss-button id="" text="Default Action" isghost="true" />}}
24 26
   {{< hackcss-button text="Custom Action" action="/go/elsewhere" />}}
25 27
   {{< hackcss-button text="Custom Target" target="_blank" tabindex="-1" />}}
26 28
   {{< hackcss-button text="Custom Method" method="get" />}}
@@ -31,6 +33,7 @@ Inside a button group:
31 33
 {{ $body := .Get "text" | default .Inner }}
32 34
 {{ $isghost := .Get "isghost" }}
33 35
 {{ $isblock := .Get "isblock" }}
36
+{{ $id := .Get "id" }}
34 37
 {{ $action := .Get "action" }}
35 38
 {{ $onclick := .Get "onclick" }}
36 39
 {{ $tabindex := .Get "tabindex" }}

Loading…
Cancel
Save