You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.4 KiB
TypeScript
65 lines
1.4 KiB
TypeScript
2 years ago
|
import React, { forwardRef } from "react";
|
||
|
import clsx from "clsx";
|
||
|
|
||
|
import "./FilledButton.scss";
|
||
|
|
||
|
export type ButtonVariant = "filled" | "outlined" | "icon";
|
||
2 years ago
|
export type ButtonColor = "primary" | "danger" | "warning" | "muted";
|
||
2 years ago
|
export type ButtonSize = "medium" | "large";
|
||
|
|
||
|
export type FilledButtonProps = {
|
||
|
label: string;
|
||
|
|
||
|
children?: React.ReactNode;
|
||
|
onClick?: () => void;
|
||
|
|
||
|
variant?: ButtonVariant;
|
||
|
color?: ButtonColor;
|
||
|
size?: ButtonSize;
|
||
|
className?: string;
|
||
2 years ago
|
fullWidth?: boolean;
|
||
2 years ago
|
|
||
|
startIcon?: React.ReactNode;
|
||
|
};
|
||
|
|
||
|
export const FilledButton = forwardRef<HTMLButtonElement, FilledButtonProps>(
|
||
|
(
|
||
|
{
|
||
|
children,
|
||
|
startIcon,
|
||
|
onClick,
|
||
|
label,
|
||
|
variant = "filled",
|
||
|
color = "primary",
|
||
|
size = "medium",
|
||
2 years ago
|
fullWidth,
|
||
2 years ago
|
className,
|
||
|
},
|
||
|
ref,
|
||
|
) => {
|
||
|
return (
|
||
|
<button
|
||
|
className={clsx(
|
||
|
"ExcButton",
|
||
|
`ExcButton--color-${color}`,
|
||
|
`ExcButton--variant-${variant}`,
|
||
|
`ExcButton--size-${size}`,
|
||
2 years ago
|
{ "ExcButton--fullWidth": fullWidth },
|
||
2 years ago
|
className,
|
||
|
)}
|
||
|
onClick={onClick}
|
||
|
type="button"
|
||
|
aria-label={label}
|
||
|
ref={ref}
|
||
|
>
|
||
|
{startIcon && (
|
||
|
<div className="ExcButton__icon" aria-hidden>
|
||
|
{startIcon}
|
||
|
</div>
|
||
|
)}
|
||
|
{variant !== "icon" && (children ?? label)}
|
||
|
</button>
|
||
|
);
|
||
|
},
|
||
|
);
|