57 lines
1.3 KiB
Text
57 lines
1.3 KiB
Text
// templui component badge - version: main installed by templui v0.71.0
|
|
package badge
|
|
|
|
import "git.jmbit.de/jmb/scanfile/server/web/templui/utils"
|
|
|
|
type Variant string
|
|
|
|
const (
|
|
VariantDefault Variant = "default"
|
|
VariantSecondary Variant = "secondary"
|
|
VariantDestructive Variant = "destructive"
|
|
VariantOutline Variant = "outline"
|
|
)
|
|
|
|
type Props struct {
|
|
ID string
|
|
Class string
|
|
Attributes templ.Attributes
|
|
Variant Variant
|
|
}
|
|
|
|
templ Badge(props ...Props) {
|
|
{{ var p Props }}
|
|
if len(props) > 0 {
|
|
{{ p = props[0] }}
|
|
}
|
|
<div
|
|
if p.ID != "" {
|
|
id={ p.ID }
|
|
}
|
|
class={
|
|
utils.TwMerge(
|
|
"inline-flex items-center gap-2",
|
|
"rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors",
|
|
"focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
p.variantClasses(),
|
|
p.Class,
|
|
),
|
|
}
|
|
{ p.Attributes... }
|
|
>
|
|
{ children... }
|
|
</div>
|
|
}
|
|
|
|
func (p Props) variantClasses() string {
|
|
switch p.Variant {
|
|
case VariantDestructive:
|
|
return "border-transparent bg-destructive text-destructive-foreground"
|
|
case VariantOutline:
|
|
return "text-foreground border-border"
|
|
case VariantSecondary:
|
|
return "border-transparent bg-secondary text-secondary-foreground"
|
|
default:
|
|
return "border-transparent bg-primary text-primary-foreground"
|
|
}
|
|
}
|