|
1 | | -import MuiButton, { ButtonProps } from '@mui/material/Button'; |
| 1 | +import React from 'react'; |
| 2 | +import MuiButton, { ButtonProps as MuiButtonProps } from '@mui/material/Button'; |
2 | 3 | import { styled } from '@mui/material/styles'; |
3 | 4 |
|
4 | | -const StyledButton = styled(MuiButton)<ButtonProps>(({ theme }) => ({ |
| 5 | +import { Mode } from '../main.types'; |
| 6 | + |
| 7 | +interface StyledButtonProps { |
| 8 | + mode?: Mode; |
| 9 | +} |
| 10 | + |
| 11 | +const StyledButton = styled(MuiButton)<StyledButtonProps>(({ theme }) => ({ |
5 | 12 | ...theme.text.Subtitle_16_Med, |
6 | 13 | padding: '4px 32px', |
7 | 14 | borderRadius: 90000, |
8 | 15 | textTransform: 'none', |
9 | 16 | minHeight: 32, |
| 17 | + |
| 18 | + '&.Mui-disabled': { |
| 19 | + opacity: 0.3, |
| 20 | + }, |
| 21 | + |
| 22 | + '&.MuiButton-textPrimary': { |
| 23 | + color: theme.palette.primary.main, |
| 24 | + }, |
| 25 | + |
| 26 | + '&.MuiButton-textSecondary': { |
| 27 | + '&[mode="dark"]': { |
| 28 | + color: 'white', |
| 29 | + '&:hover': { |
| 30 | + backgroundColor: 'rgba(101, 101, 101, 0.1)', |
| 31 | + }, |
| 32 | + }, |
| 33 | + }, |
| 34 | + |
| 35 | + '&.MuiButton-textSuccess': { |
| 36 | + color: theme.palette.success.main, |
| 37 | + }, |
| 38 | + |
| 39 | + '&.MuiButton-textWarning': { |
| 40 | + color: theme.palette.warning.main, |
| 41 | + }, |
| 42 | + |
| 43 | + '&.MuiButton-textInfo': { |
| 44 | + color: theme.palette.info.main, |
| 45 | + }, |
| 46 | + |
| 47 | + '&.MuiButton-textError': { |
| 48 | + color: theme.palette.error.main, |
| 49 | + }, |
| 50 | + |
10 | 51 | '&.MuiButton-contained': { |
| 52 | + color: '#FFFFFF', |
11 | 53 | boxShadow: '0px 2px 4px rgba(0, 0, 0, 0.1)', |
12 | 54 | '&:hover': { |
13 | 55 | boxShadow: '0px 2px 4px rgba(0, 0, 0, 0.1)', |
14 | 56 | }, |
15 | | - '&:active': { |
16 | | - boxShadow: '0px 2px 4px rgba(0, 0, 0, 0.1)', |
17 | | - }, |
18 | | - '&:disabled': { |
19 | | - color: '#FFFFFF', |
20 | | - }, |
21 | 57 | }, |
| 58 | + |
22 | 59 | '&.MuiButton-containedPrimary': { |
23 | | - color: '#FFFFFF', |
| 60 | + backgroundColor: theme.palette.primary.main, |
24 | 61 | '&:hover': { |
25 | 62 | backgroundColor: theme.color.primary.$80, |
26 | 63 | }, |
27 | | - '&:active': { |
28 | | - backgroundColor: theme.color.primary.$100, |
29 | | - }, |
30 | | - '&:disabled': { |
31 | | - backgroundColor: '#E6D2A1', |
32 | | - }, |
33 | 64 | }, |
| 65 | + |
34 | 66 | '&.MuiButton-containedSecondary': { |
35 | | - color: '#FFFFFF', |
| 67 | + backgroundColor: theme.color.secondary.$80, |
36 | 68 | '&:hover': { |
37 | | - backgroundColor: theme.color.secondary.$80, |
| 69 | + backgroundColor: 'rgba(255, 255, 255, 0.1)', |
| 70 | + }, |
| 71 | + }, |
| 72 | + |
| 73 | + '&.MuiButton-containedSuccess': { |
| 74 | + '&.Mui-disabled': { |
| 75 | + backgroundColor: theme.palette.success.main, |
| 76 | + }, |
| 77 | + }, |
| 78 | + |
| 79 | + '&.MuiButton-containedWarning': { |
| 80 | + '&.Mui-disabled': { |
| 81 | + backgroundColor: theme.palette.warning.main, |
38 | 82 | }, |
39 | | - '&:active': { |
40 | | - backgroundColor: theme.color.secondary.$80, |
| 83 | + }, |
| 84 | + |
| 85 | + '&.MuiButton-containedInfo': { |
| 86 | + '&.Mui-disabled': { |
| 87 | + backgroundColor: theme.palette.info.main, |
41 | 88 | }, |
42 | | - '&:disabled': { |
43 | | - backgroundColor: '#B3B3B3', |
| 89 | + }, |
| 90 | + |
| 91 | + '&.MuiButton-containedError': { |
| 92 | + '&.Mui-disabled': { |
| 93 | + backgroundColor: theme.palette.error.main, |
| 94 | + }, |
| 95 | + }, |
| 96 | + |
| 97 | + '&.MuiButton-outlinedPrimary': { |
| 98 | + '&.Mui-disabled': { |
| 99 | + color: theme.palette.primary.main, |
| 100 | + border: `1px solid ${theme.palette.primary.main}`, |
| 101 | + }, |
| 102 | + }, |
| 103 | + |
| 104 | + '&.MuiButton-outlinedSecondary': { |
| 105 | + '&[mode="dark"]': { |
| 106 | + color: 'white', |
| 107 | + borderColor: 'rgba(255, 255, 255, 0.5)', |
| 108 | + '&:hover': { |
| 109 | + borderColor: 'rgba(255, 255, 255, 1)', |
| 110 | + }, |
| 111 | + }, |
| 112 | + }, |
| 113 | + |
| 114 | + '&.MuiButton-outlinedSuccess': { |
| 115 | + '&.Mui-disabled': { |
| 116 | + color: theme.palette.success.main, |
| 117 | + border: `1px solid ${theme.palette.success.main}`, |
| 118 | + }, |
| 119 | + }, |
| 120 | + |
| 121 | + '&.MuiButton-outlinedWarning': { |
| 122 | + '&.Mui-disabled': { |
| 123 | + color: theme.palette.warning.main, |
| 124 | + border: `1px solid ${theme.palette.warning.main}`, |
| 125 | + }, |
| 126 | + }, |
| 127 | + |
| 128 | + '&.MuiButton-outlinedInfo': { |
| 129 | + '&.Mui-disabled': { |
| 130 | + color: theme.palette.info.main, |
| 131 | + border: `1px solid ${theme.palette.info.main}`, |
| 132 | + }, |
| 133 | + }, |
| 134 | + |
| 135 | + '&.MuiButton-outlinedError': { |
| 136 | + '&.Mui-disabled': { |
| 137 | + color: theme.palette.error.main, |
| 138 | + border: `1px solid ${theme.palette.error.main}`, |
44 | 139 | }, |
45 | 140 | }, |
46 | 141 | })); |
47 | 142 |
|
48 | | -export default StyledButton; |
| 143 | +export interface ButtonProps extends MuiButtonProps { |
| 144 | + mode?: Mode; |
| 145 | +} |
| 146 | + |
| 147 | +const Button: React.VFC<ButtonProps> = ({ mode = 'dark', ...props }) => { |
| 148 | + return <StyledButton mode={mode} {...props} />; |
| 149 | +}; |
| 150 | + |
| 151 | +export default Button; |
0 commit comments