// Code generated by templ - DO NOT EDIT. // templ: version: v0.3.865 // templui component button - version: main installed by templui v0.71.0 package button //lint:file-ignore SA4006 This context is only used if a nested component is present. import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" import ( "git.jmbit.de/jmb/scanfile/server/web/templui/utils" "strings" ) type Variant string type Size string type Type string const ( VariantDefault Variant = "default" VariantDestructive Variant = "destructive" VariantOutline Variant = "outline" VariantSecondary Variant = "secondary" VariantGhost Variant = "ghost" VariantLink Variant = "link" ) const ( TypeButton Type = "button" TypeReset Type = "reset" TypeSubmit Type = "submit" ) const ( SizeIcon Size = "icon" ) type Props struct { ID string Class string Attributes templ.Attributes Variant Variant Size Size FullWidth bool Href string Target string Disabled bool Type Type HxGet string HxPost string HxPut string HxDelete string HxTrigger string HxTarget string HxSwap string HxReplaceUrl string } func Button(props ...Props) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { return templ_7745c5c3_CtxErr } templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { defer func() { templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) if templ_7745c5c3_Err == nil { templ_7745c5c3_Err = templ_7745c5c3_BufErr } }() } ctx = templ.InitializeContext(ctx) templ_7745c5c3_Var1 := templ.GetChildren(ctx) if templ_7745c5c3_Var1 == nil { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) var p Props if len(props) > 0 { p = props[0] } if p.Type == "" { p.Type = TypeButton } if p.Href != "" && !p.Disabled { var templ_7745c5c3_Var2 = []any{ utils.TwMerge( "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors", "focus-visible:outline-hidden focus-visible:ring-2 focus:ring-ring focus-visible:ring-offset-2", "cursor-pointer", p.variantClasses(), p.sizeClasses(), p.modifierClasses(), p.Class, ), } templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var2...) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { var templ_7745c5c3_Var7 = []any{ utils.TwMerge( "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors", "focus-visible:outline-hidden focus-visible:ring-2 focus:ring-ring focus-visible:ring-offset-2", "disabled:opacity-50 disabled:cursor-not-allowed", "cursor-pointer", p.variantClasses(), p.sizeClasses(), p.modifierClasses(), p.Class, ), } templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var7...) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } return nil }) } func (b Props) variantClasses() string { switch b.Variant { case VariantDestructive: return "bg-destructive text-destructive-foreground hover:bg-destructive/90" case VariantOutline: return "border border-input bg-background hover:bg-accent hover:text-accent-foreground" case VariantSecondary: return "bg-secondary text-secondary-foreground hover:bg-secondary/80" case VariantGhost: return "hover:bg-accent hover:text-accent-foreground" case VariantLink: return "text-primary underline-offset-4 hover:underline" default: return "bg-primary text-primary-foreground hover:bg-primary/90" } } func (b Props) sizeClasses() string { switch b.Size { case SizeIcon: return "h-10 w-10" default: return "h-10 px-4 py-2 rounded-md" } } func (b Props) modifierClasses() string { classes := []string{} if b.FullWidth { classes = append(classes, "w-full") } return strings.Join(classes, " ") } var _ = templruntime.GeneratedTemplate