2023-03-10 02:01:40 +09:00
|
|
|
import * as React from "react";
|
|
|
|
|
2023-03-13 04:06:21 +09:00
|
|
|
import styles from "./button.module.scss";
|
2023-03-10 02:01:40 +09:00
|
|
|
|
|
|
|
export function IconButton(props: {
|
|
|
|
onClick?: () => void;
|
2023-04-25 01:49:27 +09:00
|
|
|
icon?: JSX.Element;
|
2023-04-28 01:34:37 +09:00
|
|
|
type?: "primary" | "danger";
|
2023-03-10 02:01:40 +09:00
|
|
|
text?: string;
|
|
|
|
bordered?: boolean;
|
2023-04-03 02:48:43 +09:00
|
|
|
shadow?: boolean;
|
2023-03-10 02:01:40 +09:00
|
|
|
className?: string;
|
2023-03-13 04:06:21 +09:00
|
|
|
title?: string;
|
2023-04-06 22:02:48 +09:00
|
|
|
disabled?: boolean;
|
2023-03-10 02:01:40 +09:00
|
|
|
}) {
|
|
|
|
return (
|
2023-04-06 22:02:48 +09:00
|
|
|
<button
|
2023-03-10 02:01:40 +09:00
|
|
|
className={
|
|
|
|
styles["icon-button"] +
|
2023-04-03 02:48:43 +09:00
|
|
|
` ${props.bordered && styles.border} ${props.shadow && styles.shadow} ${
|
|
|
|
props.className ?? ""
|
2023-04-28 01:34:37 +09:00
|
|
|
} clickable ${styles[props.type ?? ""]}`
|
2023-03-10 02:01:40 +09:00
|
|
|
}
|
2023-03-11 03:25:33 +09:00
|
|
|
onClick={props.onClick}
|
2023-03-13 04:06:21 +09:00
|
|
|
title={props.title}
|
2023-04-06 22:02:48 +09:00
|
|
|
disabled={props.disabled}
|
2023-04-03 02:48:43 +09:00
|
|
|
role="button"
|
2023-03-10 02:01:40 +09:00
|
|
|
>
|
2023-04-25 01:49:27 +09:00
|
|
|
{props.icon && (
|
|
|
|
<div
|
|
|
|
className={
|
2023-04-28 01:34:37 +09:00
|
|
|
styles["icon-button-icon"] +
|
|
|
|
` ${props.type === "primary" && "no-dark"}`
|
2023-04-25 01:49:27 +09:00
|
|
|
}
|
|
|
|
>
|
|
|
|
{props.icon}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
2023-03-10 02:01:40 +09:00
|
|
|
{props.text && (
|
|
|
|
<div className={styles["icon-button-text"]}>{props.text}</div>
|
|
|
|
)}
|
2023-04-06 22:02:48 +09:00
|
|
|
</button>
|
2023-03-10 02:01:40 +09:00
|
|
|
);
|
|
|
|
}
|