Skip to content

Commit edfbc01

Browse files
author
Diyor Khaydarov
committed
fix: dropdown select
1 parent 9aec3fa commit edfbc01

File tree

4 files changed

+137
-110
lines changed

4 files changed

+137
-110
lines changed

Diff for: components/base/input/input.templ

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package input
22

33
import (
4+
"github.com/Oudwins/tailwind-merge-go/pkg/twmerge"
45
icons "github.com/iota-uz/icons/phosphor"
56
"github.com/iota-uz/utils/random"
67
)
@@ -85,7 +86,7 @@ type CheckboxProps struct {
8586
Error string
8687
Checked bool
8788
Attrs templ.Attributes
88-
Class string
89+
Class templ.CSSClasses
8990
ID string
9091
}
9192

@@ -97,16 +98,24 @@ func newCheckbox(p *CheckboxProps) *CheckboxProps {
9798
}
9899

99100
templ (p *CheckboxProps) render() {
100-
<div class="flex items-center gap-3">
101+
<label
102+
for={ p.ID }
103+
class={
104+
twmerge.Merge(
105+
"form-control-label flex items-center cursor-pointer gap-3",
106+
p.Class.String(),
107+
),
108+
}
109+
>
101110
<input
102111
type="checkbox"
103112
id={ p.ID }
104-
class={ "peer appearance-none sr-only", p.Class }
113+
class="peer appearance-none sr-only"
105114
checked?={ p.Checked }
106115
{ p.Attrs... }
107116
/>
108-
<label
109-
for={ p.ID }
117+
<!-- Visual checkbox box -->
118+
<div
110119
class="w-5 h-5 rounded-[5px] border border-gray-500 duration-200 flex items-center justify-center hover:border-brand-500 peer-indeterminate:bg-brand-500 peer-checked:bg-brand-500 peer-checked:text-white peer-indeterminate:text-white group"
111120
>
112121
@icons.Check(icons.Props{
@@ -117,14 +126,13 @@ templ (p *CheckboxProps) render() {
117126
Size: "16",
118127
Class: "scale-0 hidden peer-indeterminate:group-[]:inline peer-indeterminate:group-[]:scale-100",
119128
})
120-
</label>
129+
</div>
130+
<!-- Optional label text -->
121131
if len(p.Label) > 0 {
122-
<label for={ p.ID }>
123-
{ p.Label }
124-
</label>
132+
<span>{ p.Label }</span>
125133
}
126134
{ children... }
127-
</div>
135+
</label>
128136
}
129137

130138
templ Checkbox(p *CheckboxProps) {

Diff for: components/base/input/input_templ.go

+55-66
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: components/scaffold/filters/filters.templ

+6-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ templ Dropdown(props DropdownProps) {
6161
x-show="open"
6262
@click.away="open = false"
6363
x-transition
64-
class="absolute z-20 mt-2 w-full bg-white border border-gray-200 rounded-md shadow-lg max-h-80 overflow-y-auto"
64+
class={
65+
"absolute z-20 mt-2 bg-white max-h-80 overflow-y-auto min-w-fit",
66+
"border border-gray-200 rounded-md shadow-lg",
67+
}
6568
>
6669
{ children... }
6770
</ul>
@@ -80,14 +83,15 @@ templ DropdownItem(props DropdownItemProps) {
8083
<li
8184
class={
8285
twmerge.Merge(
83-
"hover:bg-gray-100 p-2",
86+
"hover:bg-gray-100",
8487
props.Class.String(),
8588
),
8689
}
8790
>
8891
@input.Checkbox(&input.CheckboxProps{
8992
Label: props.Label,
9093
Checked: props.Checked,
94+
Class: templ.Classes("p-2"),
9195
Attrs: templ.Attributes{
9296
"value": props.Value,
9397
"name": props.Name,

0 commit comments

Comments
 (0)