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

135 lines
2.4 KiB
Text

// templui component radiocard - version: v0.84.0 installed by templui v0.84.0
package radiocard
import "git.jmbit.de/jmb/scanfile/server/web/templui/utils"
type Props struct {
ID string
Class string
Attributes templ.Attributes
Name string
Value string
Checked bool
Disabled bool
Required bool
}
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 RadioCard(props ...Props) {
{{ var p Props }}
if len(props) > 0 {
{{ p = props[0] }}
}
if p.ID == "" {
{{ p.ID = utils.RandomID() }}
}
<div
id={ p.ID + "-container" }
class={
utils.TwMerge(
"relative",
utils.If(p.Disabled, "opacity-60"),
p.Class,
),
}
{ p.Attributes... }
>
<input
type="radio"
id={ p.ID }
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={ p.ID }
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,
),
}
{ p.Attributes... }
>
{ 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>
}