scanfile/server/web/templui/components/checkboxcard/checkbox_card.templ
2025-06-03 15:44:56 +02:00

152 lines
2.5 KiB
Text

// templui component checkboxcard - version: main installed by templui v0.71.0
package checkboxcard
import "git.jmbit.de/jmb/scanfile/server/web/templui/utils"
type Props struct {
ID string
Class string
Attributes templ.Attributes
Checked bool
Disabled bool
Required bool
Name string
Value string
}
type HeaderProps struct {
ID string
Class string
Attributes templ.Attributes
}
type DescriptionProps struct {
ID string
Class string
Attributes templ.Attributes
}
type FooterProps struct {
ID string
Class string
Attributes templ.Attributes
}
templ CheckboxCard(props ...Props) {
{{ var p Props }}
if len(props) > 0 {
{{ p = props[0] }}
}
if p.ID == "" {
{{ p.ID = utils.RandomID() }}
}
{{ inputId := p.ID + "-input" }}
<div
if p.ID != "" {
id={ p.ID }
}
class={
utils.TwMerge(
"relative",
utils.If(p.Disabled, "opacity-60"),
p.Class,
),
}
{ p.Attributes... }
>
<input
type="checkbox"
id={ inputId }
if p.Name != "" {
name={ p.Name }
}
if p.Value != "" {
value={ p.Value }
}
checked?={ p.Checked }
disabled?={ p.Disabled }
required?={ p.Required }
class="peer sr-only"
/>
<label
for={ inputId }
class={
utils.TwMerge(
"block w-full rounded-lg border overflow-hidden h-full",
"bg-card text-card-foreground p-4 flex flex-col",
"cursor-pointer",
"hover:border-primary/50",
"peer-checked:ring-1 peer-checked:ring-primary peer-checked:border-primary",
utils.If(p.Disabled, "cursor-not-allowed"),
"transition-all duration-200",
p.Class,
),
}
>
{ children... }
</label>
</div>
}
templ Header(props ...HeaderProps) {
{{ var p HeaderProps }}
if len(props) > 0 {
{{ p = props[0] }}
}
<div
if p.ID != "" {
id={ p.ID }
}
class={
utils.TwMerge(
"flex items-center justify-between mb-2",
p.Class,
),
}
{ p.Attributes... }
>
{ children... }
</div>
}
templ Description(props ...DescriptionProps) {
{{ var p DescriptionProps }}
if len(props) > 0 {
{{ p = props[0] }}
}
<p
if p.ID != "" {
id={ p.ID }
}
class={
utils.TwMerge(
"text-sm text-muted-foreground",
p.Class,
),
}
{ p.Attributes... }
>
{ children... }
</p>
}
templ Footer(props ...FooterProps) {
{{ var p FooterProps }}
if len(props) > 0 {
{{ p = props[0] }}
}
<div
if p.ID != "" {
id={ p.ID }
}
class={
utils.TwMerge(
"mt-auto pt-4 w-full",
p.Class,
),
}
{ p.Attributes... }
>
{ children... }
</div>
}