2023-07-20 17:11:03 +03:00
|
|
|
import { TokenID } from '../../utils/models'
|
|
|
|
import { getRSButtonData } from '../../utils/staticUI'
|
|
|
|
|
2023-07-22 03:18:48 +03:00
|
|
|
interface RSTokenButtonProps {
|
2023-07-20 17:11:03 +03:00
|
|
|
id: TokenID
|
|
|
|
disabled?: boolean
|
2023-07-22 03:18:48 +03:00
|
|
|
onInsert: (token: TokenID, key?: string) => void
|
2023-07-20 17:11:03 +03:00
|
|
|
}
|
|
|
|
|
2023-07-22 03:18:48 +03:00
|
|
|
function RSTokenButton({id, disabled, onInsert}: RSTokenButtonProps) {
|
2023-07-20 17:11:03 +03:00
|
|
|
const data = getRSButtonData(id);
|
|
|
|
const width = data.text.length > 3 ? 'w-[4rem]' : 'w-[2rem]';
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
type='button'
|
|
|
|
disabled={disabled}
|
|
|
|
onClick={() => onInsert(id)}
|
|
|
|
title={data.tooltip}
|
|
|
|
tabIndex={-1}
|
2023-07-21 18:44:14 +03:00
|
|
|
className={`px-1 cursor-pointer border rounded-none h-7 ${width} clr-btn-clear`}
|
2023-07-20 17:11:03 +03:00
|
|
|
>
|
|
|
|
{data.text && <span className='whitespace-nowrap'>{data.text}</span>}
|
|
|
|
</button>
|
2023-07-22 03:18:48 +03:00
|
|
|
);
|
2023-07-20 17:11:03 +03:00
|
|
|
}
|
|
|
|
|
2023-07-22 03:18:48 +03:00
|
|
|
export default RSTokenButton;
|