File tree Expand file tree Collapse file tree 7 files changed +40
-65
lines changed
_shortcodes/golangci/items Expand file tree Collapse file tree 7 files changed +40
-65
lines changed Original file line number Diff line number Diff line change @@ -28,9 +28,9 @@ golangci-lint formatters
28
28
## All formatters
29
29
30
30
{{< golangci/items/filter >}}
31
- {{< golangci/items/clickable -badge class="gl-filter" id ="new-filter " icon="fire" content="New" type="warning" >}}
32
- {{< golangci/items/clickable -badge class="gl-filter" id ="deprecated-filter " icon="emoji-sad" content="Deprecated" type="info" >}}
33
- {{< golangci/items/clickable -badge class="gl-filter-reset gl-hidden" id="reset-filter " icon="trash" content="Reset" type="error" border=true >}}
31
+ {{< golangci/items/filter -badge class="gl-filter" data ="new" icon="fire" content="New" type="warning" >}}
32
+ {{< golangci/items/filter -badge class="gl-filter" data ="deprecated" icon="emoji-sad" content="Deprecated" type="info" >}}
33
+ {{< golangci/items/filter -badge class="gl-filter-reset gl-hidden" icon="trash" content="Reset" type="error" border=true >}}
34
34
{{< /golangci/items/filter >}}
35
35
36
36
{{< cards >}}
Original file line number Diff line number Diff line change @@ -28,13 +28,13 @@ golangci-lint linters
28
28
## All Linters
29
29
30
30
{{< golangci/items/filter >}}
31
- {{< golangci/items/clickable -badge class="gl-filter" id ="default-filter " icon="inbox" content="Default" type="info" >}}
32
- {{< golangci/items/clickable -badge class="gl-filter" id ="new-filter " icon="fire" content="New" type="warning" >}}
33
- {{< golangci/items/clickable -badge class="gl-filter" id ="autofix-filter " icon="sparkles" content="Autofix" type="info" >}}
34
- {{< golangci/items/clickable -badge class="gl-filter" id ="fast-filter " icon="fast-forward" content="Fast" >}}
35
- {{< golangci/items/clickable -badge class="gl-filter" id ="slow-filter " icon="play" content="Slow" >}}
36
- {{< golangci/items/clickable -badge class="gl-filter" id ="deprecated-filter " icon="emoji-sad" content="Deprecated" type="info" >}}
37
- {{< golangci/items/clickable -badge class="gl-filter-reset gl-hidden" icon="trash" id="reset-filter " content="Reset" type="error" border=true >}}
31
+ {{< golangci/items/filter -badge class="gl-filter" data ="default" icon="inbox" content="Default" type="info" >}}
32
+ {{< golangci/items/filter -badge class="gl-filter" data ="new" icon="fire" content="New" type="warning" >}}
33
+ {{< golangci/items/filter -badge class="gl-filter" data ="autofix" icon="sparkles" content="Autofix" type="info" >}}
34
+ {{< golangci/items/filter -badge class="gl-filter" data ="fast" icon="fast-forward" content="Fast" >}}
35
+ {{< golangci/items/filter -badge class="gl-filter" data ="slow" icon="play" content="Slow" >}}
36
+ {{< golangci/items/filter -badge class="gl-filter" data ="deprecated" icon="emoji-sad" content="Deprecated" type="info" >}}
37
+ {{< golangci/items/filter -badge class="gl-filter-reset gl-hidden" icon="trash" content="Reset" type="error" border=true >}}
38
38
{{< /golangci/items/filter >}}
39
39
40
40
{{< cards >}}
Original file line number Diff line number Diff line change 20
20
let clean = event . currentTarget . classList . contains ( borderClass )
21
21
22
22
document . querySelectorAll ( '.gl-item' ) . forEach ( element => element . classList . remove ( hiddenClass ) ) ;
23
- document . querySelectorAll ( '.gl-filter' ) . forEach ( element => element . classList . remove ( borderClass ) ) ;
23
+ document . querySelectorAll ( '.gl-filter > * ' ) . forEach ( element => element . classList . remove ( borderClass ) ) ;
24
24
25
25
if ( clean ) {
26
26
resetButton . classList . add ( hiddenClass ) ;
29
29
30
30
document . querySelectorAll ( '.gl-filter' ) . forEach ( element => element . classList . remove ( borderClass ) )
31
31
32
- event . currentTarget . classList . add ( borderClass ) ;
32
+ event . currentTarget . querySelector ( '*' ) . classList . add ( borderClass ) ;
33
33
34
34
let selector = ''
35
- switch ( event . currentTarget . id ) {
36
- case 'default-filter ' :
35
+ switch ( event . currentTarget . dataset . badge ) {
36
+ case 'default' :
37
37
selector = '.gl-item:not(.gl-default)'
38
38
break ;
39
- case 'new-filter ' :
39
+ case 'new' :
40
40
selector = '.gl-item:not(.gl-new)'
41
41
break ;
42
- case 'autofix-filter ' :
42
+ case 'autofix' :
43
43
selector = '.gl-item:not(.gl-autofix)'
44
44
break ;
45
- case 'fast-filter ' :
45
+ case 'fast' :
46
46
selector = '.gl-item:not(.gl-slow)'
47
47
break ;
48
- case 'slow-filter ' :
48
+ case 'slow' :
49
49
selector = '.gl-item:not(.gl-fast)'
50
50
break ;
51
- case 'deprecated-filter ' :
51
+ case 'deprecated' :
52
52
selector = '.gl-item:not(.gl-deprecated)'
53
53
break ;
54
54
}
64
64
event . currentTarget . classList . add ( hiddenClass ) ;
65
65
66
66
document . querySelectorAll ( '.gl-item' ) . forEach ( element => element . classList . remove ( hiddenClass ) ) ;
67
- document . querySelectorAll ( '.gl-filter' ) . forEach ( element => element . classList . remove ( borderClass ) ) ;
67
+ document . querySelectorAll ( '.gl-filter > * ' ) . forEach ( element => element . classList . remove ( borderClass ) ) ;
68
68
} ) ;
69
69
} ) ;
70
70
</ script >
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 6
6
{{- $class := .class | default "" -}}
7
7
{{- $border := .border | default false -}}
8
8
{{- $icon := .icon | default "" -}}
9
+ {{- $data := .data | default "" -}}
9
10
10
11
{{- $defaultClass := "hx:text-gray-600 hx:bg-gray-100 hx:dark:bg-neutral-800 hx:dark:text-neutral-200 hx:border-gray-200 hx:dark:border-neutral-700" -}}
11
12
17
18
{{- $borderClass := cond (eq $border true) "hx:border" "" -}}
18
19
{{- $badgeClass := or ($styleClass.Get $type) $defaultClass -}}
19
20
21
+ {{- /* Custom section to handle icon-only badges. */ -}}
20
22
{{- $iconOnly := hasPrefix $type "icon-only" -}}
21
23
{{- if $iconOnly -}}
22
24
{{- $icon = (strings.TrimPrefix "icon-only:" $type) -}}
25
27
{{- $badgeClass = "hx:p-2" -}}
26
28
{{- end -}}
27
29
28
- < div class ="hextra-badge {{ $class }} " {{- if $iconOnly -}}title ="{{ $content }} "{{- end -}} >
30
+ {{- /* Custom section to set attributes. */ -}}
31
+ {{- $attributes := slice -}}
32
+ {{- if $iconOnly -}}
33
+ {{- $attributes = $attributes | append (printf `title="%s"` $content) -}}
34
+ {{- end -}}
35
+ {{- if $data -}}
36
+ {{- $attributes = $attributes | append (printf `data-badge="%s"` $data) -}}
37
+ {{- end -}}
38
+
39
+ < div class ="hextra-badge {{ $class }} " {{ (delimit $attributes " ") | safeHTMLAttr }}>
29
40
< div class ="hx:inline-flex hx:gap-1 hx:items-center hx:rounded-full hx:px-2.5 hx:leading-6 hx:text-[.65rem] {{ $borderClass }} {{ $badgeClass }} ">
30
41
{{- with $icon -}}{{- partial "utils/icon" (dict "name" . "attributes" "height=12") -}}{{- end -}}
31
42
{{- if not $iconOnly -}}{{- $content -}}{{- end -}}
Original file line number Diff line number Diff line change 1
1
{{- /* Modified version of https://github.com/imfing/hextra/blob/v0.10.0/layouts/_shortcodes/badge.html */ -}}
2
2
{{- /*
3
- Creates a badge with the given id and class .
3
+ Creates a badge with the given "data-filter" value .
4
4
5
5
@param {string} content The content of the badge.
6
6
@param {string} type The type of the badge.
7
- @param {string} id The id of the badge.
7
+ @param {string} data The "data-filter" value for the badge.
8
8
@param {string} class The class of the badge.
9
9
@param {boolean} border Whether to render a border around the badge.
10
10
@param {string} icon The icon of the badge.
11
11
12
- @example {{< golangci /items/clickable -badge icon="inbox" id ="my-id " content="Text" class="my-class" type="info" border=true > }}
12
+ @example {{< golangci /items/filter -badge icon="inbox" data ="my-data " content="Text" class="my-class" type="info" border=true > }}
13
13
*/}}
14
14
15
15
{{- $content := .Get "content" -}}
16
16
{{- $type := .Get "type" | default "" -}}
17
- {{- $id := .Get "id " | default "" -}}
17
+ {{- $data := .Get "data " | default "" -}}
18
18
{{- $class := .Get "class" | default "" -}}
19
19
{{- $icon := .Get "icon" | default "" -}}
20
20
{{- $border := .Get "border" | default false -}}
21
21
22
- {{- partial "golangci/items/clickable- badge" (dict
23
- "id " $id
24
- "class" $class
22
+ {{- partial "shortcodes/ badge" (dict
23
+ "data " $data
24
+ "class" (printf "hx:mt-2 hx:mx-1 hx:cursor-pointer %s" $class)
25
25
"content" $content
26
26
"type" $type
27
27
"border" $border
Original file line number Diff line number Diff line change 1
1
{{- /*
2
2
This shortcode is used to create a filter bar.
3
3
4
- @example {{< golangci /items/filter > }}{{< golangci /items/clickable -badge content="Example"> }}{{< golangci /items/filter > }}
4
+ @example {{< golangci /items/filter > }}{{< golangci /items/filter -badge content="Example"> }}{{< golangci /items/filter > }}
5
5
*/ -}}
6
6
7
7
< div class ="hx:mt-6 ">
You can’t perform that action at this time.
0 commit comments