11import { badgeBaseStyles , badgeVariantStyles } from "@twilio-paste/badge" ;
2- import type { BadgeBaseProps , BadgeSpanProps } from "@twilio-paste/badge" ;
3- import { Box , safelySpreadBoxProps } from "@twilio-paste/box" ;
2+ import type { BadgeBaseProps , BadgeSizes , BadgeSpanProps } from "@twilio-paste/badge" ;
3+ import { Box , BoxStyleProps , safelySpreadBoxProps } from "@twilio-paste/box" ;
4+ import { Space } from "@twilio-paste/style-props" ;
45import * as React from "react" ;
56
67import { StatusObject } from "./constants" ;
78import type { StatusBadgeVariants } from "./types" ;
89
9- export type StatusBadgeProps = Omit < BadgeBaseProps , "variant" > &
10+ export type StatusBadgeProps = Omit < BadgeBaseProps , "variant" | "size" > &
1011 BadgeSpanProps & {
1112 /**
1213 * Overrides the default element name to apply unique styles with the Customization Provider
@@ -21,10 +22,43 @@ export type StatusBadgeProps = Omit<BadgeBaseProps, "variant"> &
2122 * @type {StatusBadgeVariants }
2223 */
2324 variant : StatusBadgeVariants ;
25+ /**
26+ * Sets the size of the Status Badge
27+ *
28+ * @default "default"
29+ * @type {"default" | "small" | "borderless" }
30+ */
31+ size ?: BadgeSizes | "borderless" ;
2432 } ;
2533
34+ const paddingX = ( size : StatusBadgeProps [ "size" ] ) : Space => {
35+ switch ( size ) {
36+ case "small" :
37+ return "space20" ;
38+ case "borderless" :
39+ return "space0" ;
40+ default :
41+ return "space30" ;
42+ }
43+ } ;
44+ const paddingY = ( size : StatusBadgeProps [ "size" ] ) : Space => {
45+ switch ( size ) {
46+ case "small" :
47+ return "space10" ;
48+ case "borderless" :
49+ return "space0" ;
50+ default :
51+ return "space20" ;
52+ }
53+ } ;
54+
2655const badgeStyles = { ...badgeBaseStyles , ...badgeVariantStyles . default } ;
2756
57+ const badgeBorderlessStyles : BoxStyleProps = {
58+ boxShadow : "none" ,
59+ backgroundColor : "transparent" ,
60+ } ;
61+
2862const StatusBadge = React . forwardRef < HTMLElement , StatusBadgeProps > (
2963 ( { children, element = "STATUS_BADGE" , size, variant, ...props } , ref ) => {
3064 return (
@@ -35,12 +69,13 @@ const StatusBadge = React.forwardRef<HTMLElement, StatusBadgeProps>(
3569 variant = { variant }
3670 { ...badgeStyles }
3771 color = { StatusObject [ variant ] . color }
38- paddingX = { size === "small" ? "space20" : "space30" }
39- paddingY = { size === "small" ? "space10" : "space20" }
72+ paddingX = { paddingX ( size ) }
73+ paddingY = { paddingY ( size ) }
4074 display = "flex"
4175 flexDirection = "row"
4276 columnGap = "space20"
4377 alignItems = "center"
78+ { ...( size === "borderless" && badgeBorderlessStyles ) }
4479 ref = { ref }
4580 >
4681 { StatusObject [ variant ] . icon }
0 commit comments