2022-05-10 13:52:06 +00:00
|
|
|
import { h, JSX } from 'preact';
|
2022-06-09 19:22:59 +00:00
|
|
|
import cs from 'classnames';
|
|
|
|
|
2023-01-12 02:14:44 +00:00
|
|
|
import styles from './css/ControlButton.module.scss';
|
2022-05-10 13:52:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface for ControlButton.
|
|
|
|
*/
|
|
|
|
export interface ControlButtonProps {
|
|
|
|
icon: string;
|
|
|
|
title: string;
|
2022-05-15 21:57:21 +00:00
|
|
|
disabled?: boolean;
|
2022-06-09 19:22:59 +00:00
|
|
|
active?: boolean;
|
2022-05-10 13:52:06 +00:00
|
|
|
onClick: JSX.MouseEventHandler<HTMLButtonElement>;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Simple button with an icon, tooltip text and a callback.
|
|
|
|
*
|
|
|
|
* @param icon FontAwesome icon name
|
|
|
|
* @param title Tooltip text
|
|
|
|
* @param onClick Click callback
|
|
|
|
* @returns Control Button component
|
|
|
|
*/
|
2022-06-09 19:22:59 +00:00
|
|
|
export const ControlButton = ({ active, icon, title, onClick, ...props }: ControlButtonProps) => (
|
2023-01-12 02:14:44 +00:00
|
|
|
<button className={styles.iconButton} onClick={onClick} title={title} {...props} >
|
2022-06-09 19:22:59 +00:00
|
|
|
<i className={cs('fas', `fa-${icon}`, { [styles.active]: active })}></i>
|
2022-05-10 13:52:06 +00:00
|
|
|
</button>
|
|
|
|
);
|