scanfile/server/web/templui/components/checkbox/checkbox.templ

70 lines
1.5 KiB
Text

// templui component checkbox - version: v0.84.0 installed by templui v0.84.0
package checkbox
import (
"git.jmbit.de/jmb/scanfile/server/web/templui/components/icon"
"git.jmbit.de/jmb/scanfile/server/web/templui/utils"
)
type Props struct {
ID string
Class string
Attributes templ.Attributes
Name string
Value string
Disabled bool
Required bool
Checked bool
Icon templ.Component
}
templ Checkbox(props ...Props) {
{{ var p Props }}
if len(props) > 0 {
{{ p = props[0] }}
}
<div class="relative flex items-center">
<input
checked?={ p.Checked }
disabled?={ p.Disabled }
required?={ p.Required }
if p.ID != "" {
id={ p.ID }
}
if p.Name != "" {
name={ p.Name }
}
if p.Value != "" {
value={ p.Value }
}
type="checkbox"
class={
utils.TwMerge(
"relative size-4 overflow-hidden peer",
"before:absolute before:inset-0 before:content['']",
"appearance-none rounded-sm border-2 border-primary bg-background",
"cursor-pointer transition-colors",
"checked:before:bg-primary",
"disabled:cursor-not-allowed disabled:opacity-50",
p.Class,
),
}
{ p.Attributes... }
/>
<div
class={
utils.TwMerge(
"absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",
"size-3 text-primary-foreground pointer-events-none opacity-0",
"peer-checked:opacity-100",
),
}
>
if p.Icon != nil {
@p.Icon
} else {
@icon.Check(icon.Props{Size: 12})
}
</div>
</div>
}