|
1 | 1 | import React from 'react';
|
2 | 2 | import { styled } from '@material-ui/styles';
|
3 |
| -import Button, { ButtonProps as MuiButtonProps } from '@material-ui/core/Button'; |
| 3 | +import Button, { ButtonProps } from '@material-ui/core/Button'; |
| 4 | +import { Omit } from '@material-ui/types'; |
4 | 5 |
|
5 |
| -type Omit<T, K> = Pick<T, Exclude<keyof T, K>>; |
6 |
| - |
7 |
| -interface Props { |
| 6 | +interface MyButtonProps { |
8 | 7 | color: 'red' | 'blue';
|
9 | 8 | }
|
10 | 9 |
|
11 |
| -type MyButtonProps = Props & Omit<MuiButtonProps, keyof Props>; |
12 |
| - |
13 |
| -const MyButton = styled(({ color, ...other }: MyButtonProps) => <Button {...other} />)({ |
14 |
| - background: (props: Props) => |
| 10 | +const MyButton = styled( |
| 11 | + ({ color, ...other }: MyButtonProps & Omit<ButtonProps, keyof MyButtonProps>) => ( |
| 12 | + <Button {...other} /> |
| 13 | + ), |
| 14 | +)({ |
| 15 | + background: (props: MyButtonProps) => |
15 | 16 | props.color === 'red'
|
16 | 17 | ? 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)'
|
17 | 18 | : 'linear-gradient(45deg, #2196F3 30%, #21CBF3 90%)',
|
18 | 19 | border: 0,
|
19 | 20 | borderRadius: 3,
|
20 |
| - boxShadow: (props: Props) => |
| 21 | + boxShadow: (props: MyButtonProps) => |
21 | 22 | props.color === 'red'
|
22 | 23 | ? '0 3px 5px 2px rgba(255, 105, 135, .3)'
|
23 | 24 | : '0 3px 5px 2px rgba(33, 203, 243, .3)',
|
|
0 commit comments