Merge remote-tracking branch 'remotes/origin/Create-Badge-component' into Create-Badge-component
This commit is contained in:
commit
8b3779399b
51
src/components/Badge.tsx
Normal file
51
src/components/Badge.tsx
Normal file
@ -0,0 +1,51 @@
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Imports */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
import classNames from "classnames";
|
||||
import { StyleType } from "core/_variants";
|
||||
import React from "react";
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Component props */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
type Props = {
|
||||
emphasis?: StyleType;
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
iconed?: boolean;
|
||||
onClick?: () => void;
|
||||
} & Omit<React.MouseEventHandler<HTMLSpanElement>, "">;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Component implementation */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
function Badge({
|
||||
className,
|
||||
children,
|
||||
onClick,
|
||||
emphasis = "low",
|
||||
...props
|
||||
}: Props): JSX.Element {
|
||||
return (
|
||||
<span
|
||||
onClick={onClick}
|
||||
className={classNames(
|
||||
"border p-2 rounded-sm text-xs text-center",
|
||||
{
|
||||
"cursor-pointer": onClick,
|
||||
"border-transparent": emphasis == "low",
|
||||
"bg-blue-400 text-white": emphasis == "high",
|
||||
"border-gray-400 background-gray-200": emphasis == "medium",
|
||||
},
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
export default Badge;
|
Loading…
x
Reference in New Issue
Block a user