mm
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import {
|
||||
type CSSProperties,
|
||||
} from "react";
|
||||
import { mergeClass } from "../../styles/utils/merge-class";
|
||||
import { displayRecipe } from "../../styles/recipes/display-recipe";
|
||||
import { dotSizeRecipe } from "../../styles/recipes/dot-size-recipe";
|
||||
import type { CommonProps } from "../../utils/CommonProps";
|
||||
import { brandRecipe } from "../../styles/recipes/brand-recipe";
|
||||
|
||||
export type BadgeProps = CommonProps & {
|
||||
size?: "xs" | "sm" | "md" | "lg";
|
||||
} & {
|
||||
isDot?: boolean;
|
||||
indicatorContent?: string;
|
||||
};
|
||||
|
||||
export const Badge = (props: BadgeProps) => {
|
||||
const {
|
||||
indicatorContent = "",
|
||||
isDot = false,
|
||||
size = "md",
|
||||
children,
|
||||
className = "",
|
||||
ref,
|
||||
...rest
|
||||
} = props;
|
||||
|
||||
const wrapperStyle: CSSProperties = {
|
||||
position: "relative",
|
||||
height: "fit",
|
||||
width: "fit",
|
||||
};
|
||||
|
||||
const indicatorStyle: CSSProperties = {
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
right: 0,
|
||||
transform: "translate(50%,-50%)",
|
||||
borderRadius: "9999px",
|
||||
};
|
||||
|
||||
|
||||
|
||||
const indicatorClass = mergeClass(displayRecipe(), dotSizeRecipe({ size }), brandRecipe({ brand: "danger" }), "pointer-events--none", className);
|
||||
|
||||
return (
|
||||
<div {...rest} ref={ref} style={wrapperStyle}>
|
||||
{children}
|
||||
<div className={indicatorClass} style={indicatorStyle}>
|
||||
{indicatorContent}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user