Skip to content

Commit f7bf687

Browse files
committed
[docs] Update duplicate demo
1 parent 75d089e commit f7bf687

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

docs/src/pages/css-in-js/basics/AdaptingStyledComponents.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
import React from 'react';
22
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';
45

5-
type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
6-
7-
interface Props {
6+
interface MyButtonProps {
87
color: 'red' | 'blue';
98
}
109

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) =>
1516
props.color === 'red'
1617
? 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)'
1718
: 'linear-gradient(45deg, #2196F3 30%, #21CBF3 90%)',
1819
border: 0,
1920
borderRadius: 3,
20-
boxShadow: (props: Props) =>
21+
boxShadow: (props: MyButtonProps) =>
2122
props.color === 'red'
2223
? '0 3px 5px 2px rgba(255, 105, 135, .3)'
2324
: '0 3px 5px 2px rgba(33, 203, 243, .3)',

0 commit comments

Comments
 (0)