index.tsx
38 lines
| 1 | import styles from './RowAction.module.scss'; |
| 2 | import cx from 'classnames'; |
| 3 | |
| 4 | export default function RowAction({ |
| 5 | onClick = null, |
| 6 | className = '', |
| 7 | actionId = null, |
| 8 | displayText, |
| 9 | hiddenText = '', |
| 10 | disabled = false, |
| 11 | highlight = false, |
| 12 | href = '', |
| 13 | }) { |
| 14 | if (href) { |
| 15 | return ( |
| 16 | <a href={href} className={cx(styles.action, {[styles.delete]: highlight}, className)}> |
| 17 | {displayText} {hiddenText && <span className="give-visually-hidden">{hiddenText}</span>} |
| 18 | </a> |
| 19 | ); |
| 20 | } |
| 21 | |
| 22 | if (!onClick) { |
| 23 | return null; |
| 24 | } |
| 25 | |
| 26 | return ( |
| 27 | <button |
| 28 | type="button" |
| 29 | onClick={onClick} |
| 30 | data-actionid={actionId} |
| 31 | className={cx(styles.action, {[styles.delete]: highlight}, className)} |
| 32 | disabled={disabled} |
| 33 | > |
| 34 | {displayText} {hiddenText && <span className="give-visually-hidden">{hiddenText}</span>} |
| 35 | </button> |
| 36 | ); |
| 37 | } |
| 38 |