| 1 |
import { Button } from '@patternfly/react-core/dist/esm/components/Button'; |
| 2 |
|
| 3 |
export interface FavoritesCellProps { |
| 4 |
id?: string; |
| 5 |
className?: string; |
| 6 |
onFavorite?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void; |
| 7 |
isFavorited?: boolean; |
| 8 |
rowIndex?: number; |
| 9 |
} |
| 10 |
|
| 11 |
export const FavoritesCell: React.FunctionComponent<FavoritesCellProps> = ({ |
| 12 |
className = '' as string, |
| 13 |
onFavorite, |
| 14 |
isFavorited, |
| 15 |
rowIndex, |
| 16 |
...props |
| 17 |
}: FavoritesCellProps) => { |
| 18 |
const ariaProps = |
| 19 |
rowIndex === undefined |
| 20 |
? {} |
| 21 |
: { |
| 22 |
id: `favorites-button-${rowIndex}`, |
| 23 |
'aria-labelledby': `favorites-button-${rowIndex}` |
| 24 |
}; |
| 25 |
return ( |
| 26 |
<Button |
| 27 |
variant="plain" |
| 28 |
className={className} |
| 29 |
type="button" |
| 30 |
aria-label={isFavorited ? 'Starred' : 'Not starred'} |
| 31 |
onClick={onFavorite} |
| 32 |
isFavorite |
| 33 |
isFavorited={isFavorited} |
| 34 |
{...ariaProps} |
| 35 |
{...props} |
| 36 |
/> |
| 37 |
); |
| 38 |
}; |
| 39 |
FavoritesCell.displayName = 'FavoritesCell'; |