| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import * as React from "react";
- import styles from "./button.module.scss";
- import { CSSProperties } from "react";
- export type ButtonType = "primary" | "danger" | null;
- export function IconButton(props: {
- onClick?: () => void;
- icon?: JSX.Element;
- type?: ButtonType;
- text?: string;
- bordered?: boolean;
- shadow?: boolean;
- className?: string;
- title?: string;
- disabled?: boolean;
- tabIndex?: number;
- autoFocus?: boolean;
- style?: CSSProperties;
- aria?: string;
- }) {
- return (
- <button
- className={
- styles["icon-button"] +
- ` ${props.bordered && styles.border} ${props.shadow && styles.shadow} ${
- props.className ?? ""
- } clickable ${styles[props.type ?? ""]}`
- }
- onClick={props.onClick}
- title={props.title}
- disabled={props.disabled}
- role="button"
- tabIndex={props.tabIndex}
- autoFocus={props.autoFocus}
- style={props.style}
- aria-label={props.aria}
- >
- {props.icon && (
- <div
- aria-label={props.text || props.title}
- className={
- styles["icon-button-icon"] +
- ` ${props.type === "primary" && "no-dark"}`
- }
- >
- {props.icon}
- </div>
- )}
- {props.text && (
- <div
- aria-label={props.text || props.title}
- className={styles["icon-button-text"]}
- >
- {props.text}
- </div>
- )}
- </button>
- );
- }
|