idillon | 2ef2be9 | 2022-12-30 10:59:06 -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 { TabPanelUnstyled, TabsListUnstyled, TabsUnstyled, TabUnstyled, TabUnstyledProps } from '@mui/base'; |
| 19 | import { Theme } from '@mui/material/styles'; |
| 20 | import { styled } from '@mui/system'; |
| 21 | |
| 22 | type TabProps = TabUnstyledProps & { |
| 23 | theme?: Theme; |
| 24 | }; |
| 25 | |
| 26 | export const Tab = styled(TabUnstyled)<TabProps>(({ theme }) => ({ |
| 27 | fontFamily: theme.typography.fontFamily, |
| 28 | ...theme.typography.body1, |
| 29 | color: '#666666', |
| 30 | cursor: 'pointer', |
| 31 | border: 'none', |
| 32 | display: 'flex', |
| 33 | justifyContent: 'center', |
| 34 | borderBottom: '4px solid white', |
| 35 | backgroundColor: 'white', |
| 36 | padding: '9px 0', |
| 37 | '&:hover': { |
| 38 | color: 'black', |
| 39 | borderColor: theme.palette.primary.light, |
| 40 | // Attempt to change boldess while keeping same container size |
| 41 | // https://stackoverflow.com/a/14978871 |
| 42 | textShadow: '0 0 .01px black', |
| 43 | }, |
| 44 | '&.Mui-selected': { |
| 45 | color: theme.palette.primary.dark, |
| 46 | borderColor: theme.palette.primary.dark, |
| 47 | // https://stackoverflow.com/a/14978871 |
| 48 | textShadow: `0 0 .01px ${theme.palette.primary.dark}`, |
| 49 | }, |
| 50 | '&:before': { |
| 51 | display: 'block', |
| 52 | content: 'attr(content)', |
| 53 | fontWeight: 'bold', |
| 54 | height: '15px', |
| 55 | color: 'transparent', |
| 56 | overflow: 'hidden', |
| 57 | visibility: 'hidden', |
| 58 | }, |
| 59 | })); |
| 60 | |
| 61 | export const TabPanel = styled(TabPanelUnstyled)(() => ({ |
| 62 | width: '100%', |
| 63 | })); |
| 64 | |
| 65 | export const TabsList = styled(TabsListUnstyled)(() => ({ |
| 66 | display: 'flex', |
| 67 | alignItems: 'center', |
| 68 | placeContent: 'space-evenly', |
| 69 | borderBottom: '1px solid #bfbfbf', |
| 70 | })); |
| 71 | |
| 72 | export const Tabs = TabsUnstyled; |