ConceptPortal-public/rsconcept/frontend/src/pages/RSFormPage/RSEditButton.tsx

27 lines
744 B
TypeScript
Raw Normal View History

2023-07-20 17:11:03 +03:00
import { TokenID } from '../../utils/models'
import { getRSButtonData } from '../../utils/staticUI'
interface RSEditButtonProps {
id: TokenID
disabled?: boolean
onInsert: (token: TokenID) => void
}
function RSEditButton({id, disabled, onInsert}: RSEditButtonProps) {
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}
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>
)
}
export default RSEditButton;