ConceptPortal-public/rsconcept/frontend/src/pages/RSFormPage/elements/RSTokenButton.tsx

28 lines
796 B
TypeScript
Raw Normal View History

2023-09-11 20:31:54 +03:00
import { TokenID } from '../../../models/rslang';
2023-07-28 00:03:37 +03:00
import { getRSButtonData } from '../../../utils/staticUI'
2023-07-20 17:11:03 +03:00
2023-07-25 20:27:29 +03:00
interface RSTokenButtonProps {
2023-07-20 17:11:03 +03:00
id: TokenID
disabled?: boolean
onInsert: (token: TokenID, key?: string) => void
2023-07-20 17:11:03 +03:00
}
2023-07-25 20:27:29 +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}
2023-08-27 16:35:17 +03:00
onClick={() => onInsert(id)}
2023-07-20 17:11:03 +03:00
title={data.tooltip}
tabIndex={-1}
className={`px-1 cursor-pointer border rounded-none h-7 ${width} clr-outline clr-hover clr-btn-clear`}
2023-07-20 17:11:03 +03:00
>
{data.text && <span className='whitespace-nowrap'>{data.text}</span>}
</button>
);
2023-07-20 17:11:03 +03:00
}
2023-07-25 20:27:29 +03:00
export default RSTokenButton;