component Badge { props { label = "Badge" size = "md" color = "primary" variant = "solid" shape = "pill" class = "" icon = "" iconPosition = "start" dot = false dotOnly = false dotLabel = "Status" animated = false avatarSrc = "" avatarAlt = "" dismissible = false dismissLabel = "Remove badge" truncate = false maxWidth = "12rem" anchorLabel = "" anchorIcon = "" placement = "inline" anchorLabelText = "Badge anchor" @event dismiss = function } state visible = true functions { function dismissBadge(sourceEvent, root, customEvent) { visible = false root = sourceEvent.currentTarget.closest("[data-wrn-badge]") customEvent = document.createEvent("CustomEvent") customEvent.initCustomEvent("dismiss", true, false, { component: "Badge", label: label }) root.dispatchEvent(customEvent) } } view { {#if anchorLabel || anchorIcon} {/if} {#if animated} {/if} {#if avatarSrc} {avatarAlt} {/if} {#if dot || dotOnly} {/if} {#if icon && iconPosition === "start"} {/if} {#if !dotOnly} {label} {/if} {#if icon && iconPosition === "end"} {/if} {#if dismissible} {/if} } }