blob: be605328722852a9feb70719cacf0f2bd10c297e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
import { ComponentPropsWithoutRef, Ref } from "react";
import classNames from "classnames";
import { I18nText, useC } from "@/common";
import { PaletteColorType } from "@/palette";
import "./Button.css";
interface ButtonProps extends ComponentPropsWithoutRef<"button"> {
color?: PaletteColorType;
text?: I18nText;
outline?: boolean;
buttonRef?: Ref<HTMLButtonElement> | null;
}
export default function Button(props: ButtonProps) {
const {
buttonRef,
color,
text,
outline,
className,
children,
...otherProps
} = props;
if (text != null && children != null) {
console.warn("You can't set both text and children props.");
}
const c = useC();
return (
<button
ref={buttonRef}
className={classNames(
"cru-" + (color ?? "primary"),
"cru-button",
outline && "outline",
className,
)}
{...otherProps}
>
{text != null ? c(text) : children}
</button>
);
}
|