|
| 1 | +import classnames from 'classnames'; |
1 | 2 | import React from 'react';
|
2 | 3 | import MUIButton from '@mui/material/Button';
|
3 |
| -import { DialogButtonProps } from './DialogButton.types'; |
4 | 4 | import ChevronLeft from '@mui/icons-material/ChevronLeft';
|
5 | 5 | import ChevronRight from '@mui/icons-material/ChevronRight';
|
6 | 6 | import { styled } from '@mui/material/styles';
|
7 | 7 |
|
8 |
| -const Styled = styled(MUIButton)(({ theme }) => ({ |
9 |
| - ...theme.text.Subtitle_16_Med, |
10 |
| - minWidth: 120, |
11 |
| - color: '#FFF', |
12 |
| - paddingTop: 4, |
13 |
| - paddingBottom: 4, |
14 |
| - textTransform: 'none', |
15 |
| - boxShadow: 'none', |
16 |
| - '&:active, &:hover': { |
17 |
| - backgroundColor: theme.color.primary.$80, |
18 |
| - }, |
19 |
| - '&.MuiButton-containedSecondary': { |
20 |
| - color: theme.color.primary.$100, |
21 |
| - backgroundColor: '#FFF', |
22 |
| - '&:active, &:hover': { |
23 |
| - backgroundColor: 'rgba(0, 0, 0, .05)', |
24 |
| - }, |
25 |
| - }, |
26 |
| - '&.Mui-disabled': { |
27 |
| - opacity: '.3', |
| 8 | +import { Mode } from 'components/main.types'; |
| 9 | +import { DialogButtonProps } from './DialogButton.types'; |
| 10 | + |
| 11 | +interface ButtonProps { |
| 12 | + mode?: Mode; |
| 13 | +} |
| 14 | + |
| 15 | +const Button = styled(MUIButton)<ButtonProps>` |
| 16 | + min-width: 120px; |
| 17 | + color: white; |
| 18 | + font-weight: bold; |
| 19 | + padding: 4px 0; |
| 20 | + text-transform: none; |
| 21 | + box-shadow: none; |
| 22 | +
|
| 23 | + &:hover { |
| 24 | + box-shadow: none; |
| 25 | + } |
| 26 | +
|
| 27 | + &.Mui-disabled { |
| 28 | + opacity: 0.3; |
| 29 | + } |
| 30 | +
|
| 31 | + & .MuiButton-startIcon { |
| 32 | + margin-right: 10px; |
| 33 | + } |
| 34 | +
|
| 35 | + & .MuiButton-endIcon { |
| 36 | + margin-left: 10px; |
| 37 | + } |
| 38 | +
|
| 39 | + ${({ theme }) => ({ |
| 40 | + ...theme.typography.body2, |
28 | 41 | '&.MuiButton-containedPrimary': {
|
29 |
| - color: '#FFF', |
30 |
| - backgroundColor: theme.color.primary.$80, |
| 42 | + '&:hover': { |
| 43 | + backgroundColor: theme.color.primary.$80, |
| 44 | + }, |
| 45 | + '&.loading': { |
| 46 | + pointerEvents: 'none', |
| 47 | + border: `1px solid ${theme.color.primary.$100}`, |
| 48 | + backgroundColor: 'rgba(255, 255, 255, 0.1)', |
| 49 | + }, |
| 50 | + '&.Mui-disabled': { |
| 51 | + color: 'white', |
| 52 | + backgroundColor: theme.color.primary.$80, |
| 53 | + }, |
31 | 54 | },
|
32 |
| - }, |
33 |
| - '& .MuiButton-startIcon': { marginRight: '10px' }, |
34 |
| - '& .MuiButton-endIcon': { marginLeft: '10px' }, |
35 |
| -})); |
36 |
| - |
37 |
| -const DialogButton: React.VFC<DialogButtonProps> = (props) => { |
38 |
| - const { className, previousIcon, nextIcon, color, ...otherProps } = |
39 |
| - props ?? {}; |
| 55 | +
|
| 56 | + '&.MuiButton-containedSecondary': { |
| 57 | + backgroundColor: theme.color.secondary.$80, |
| 58 | + '&:hover': { |
| 59 | + backgroundColor: 'rgba(255, 255, 255, 0.1)', |
| 60 | + }, |
| 61 | + '&.Mui-disabled': { |
| 62 | + color: 'white', |
| 63 | + backgroundColor: theme.color.secondary.$80, |
| 64 | + }, |
| 65 | + }, |
| 66 | +
|
| 67 | + '&.MuiButton-containedSuccess': { |
| 68 | + border: `1px solid ${theme.color.green.$100}`, |
| 69 | + backgroundColor: 'rgba(255, 255, 255, 0.1)', |
| 70 | + '&:hover': { |
| 71 | + backgroundColor: 'rgba(255, 255, 255, 0.1)', |
| 72 | + }, |
| 73 | + '&.Mui-disabled': { |
| 74 | + color: 'white', |
| 75 | + backgroundColor: 'rgba(255, 255, 255, 0.1)', |
| 76 | + }, |
| 77 | + }, |
| 78 | +
|
| 79 | + '&.MuiButton-outlined': { |
| 80 | + '&[mode="light"]': { |
| 81 | + color: theme.color.secondary.$60, |
| 82 | + '&:hover': { |
| 83 | + color: theme.color.secondary.$100, |
| 84 | + }, |
| 85 | + }, |
| 86 | + }, |
| 87 | +
|
| 88 | + '&.MuiButton-outlinedSecondary': { |
| 89 | + borderColor: `1px solid ${theme.color.secondary.$60}`, |
| 90 | + '&:hover': { |
| 91 | + borderColor: theme.color.secondary.$100, |
| 92 | + }, |
| 93 | + }, |
| 94 | + })} |
| 95 | +`; |
| 96 | + |
| 97 | +const DialogButton: React.VFC<DialogButtonProps> = ({ |
| 98 | + className, |
| 99 | + mode = 'dark', |
| 100 | + previousIcon, |
| 101 | + nextIcon, |
| 102 | + isLoading = false, |
| 103 | + ...props |
| 104 | +}) => { |
40 | 105 | return (
|
41 |
| - <Styled |
42 |
| - className={className} |
43 |
| - color={color} |
| 106 | + <Button |
| 107 | + mode={mode} |
| 108 | + className={classnames({ |
| 109 | + className, |
| 110 | + loading: isLoading, |
| 111 | + })} |
44 | 112 | startIcon={previousIcon && <ChevronLeft />}
|
45 | 113 | endIcon={nextIcon && <ChevronRight />}
|
46 |
| - {...otherProps} |
| 114 | + {...props} |
47 | 115 | />
|
48 | 116 | );
|
49 | 117 | };
|
|
0 commit comments