idillon | 847b464 | 2022-12-29 14:28:38 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 Savoir-faire Linux Inc. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU Affero General Public License as |
| 6 | * published by the Free Software Foundation; either version 3 of the |
| 7 | * License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU Affero General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Affero General Public |
| 15 | * License along with this program. If not, see |
| 16 | * <https://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | import { ListItemButton, ListItemButtonProps, Stack } from '@mui/material'; |
| 19 | import { ReactNode } from 'react'; |
| 20 | |
| 21 | type CustomListItemButtonProps = ListItemButtonProps & { |
| 22 | icon: ReactNode; |
| 23 | primaryText: ReactNode; |
| 24 | secondaryText?: ReactNode; |
| 25 | }; |
| 26 | |
| 27 | // The spacings between the elements of ListItemButton have been too hard to customize in the theme, |
| 28 | // plus 'primary' and 'secondary' props on ListItemText do not accept block elements such as div. |
| 29 | // This component exists in order to keep consistency in lists nevertheless |
| 30 | export const CustomListItemButton = ({ icon, primaryText, secondaryText, ...props }: CustomListItemButtonProps) => { |
| 31 | return ( |
| 32 | <ListItemButton alignItems="flex-start" {...props}> |
| 33 | <Stack direction="row" spacing="10px"> |
| 34 | {icon} |
| 35 | <Stack justifyContent="center"> |
| 36 | {primaryText} |
| 37 | {secondaryText} |
| 38 | </Stack> |
| 39 | </Stack> |
| 40 | </ListItemButton> |
| 41 | ); |
| 42 | }; |