Skip to content

Commit

Permalink
[docs] Add typescript version of AdaptingStyledComponents
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Jun 9, 2019
1 parent 06ea15d commit 2c646e5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
4 changes: 1 addition & 3 deletions docs/src/pages/styles/basics/AdaptingStyledComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ const MyButton = styled(({ color, ...other }) => <Button {...other} />)({
margin: 8,
});

function AdaptingStyledComponents() {
export default function AdaptingStyledComponents() {
return (
<React.Fragment>
<MyButton color="red">Red</MyButton>
<MyButton color="blue">Blue</MyButton>
</React.Fragment>
);
}

export default AdaptingStyledComponents;
33 changes: 33 additions & 0 deletions docs/src/pages/styles/basics/AdaptingStyledComponents.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import { styled } from '@material-ui/styles';
import Button from '@material-ui/core/Button';

interface MyButtonProps {
color: 'red' | 'blue';
}

const MyButton = styled(({ color, ...other }: MyButtonProps) => <Button {...other} />)({
background: (props: MyButtonProps) =>
props.color === 'red'
? 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)'
: 'linear-gradient(45deg, #2196F3 30%, #21CBF3 90%)',
border: 0,
borderRadius: 3,
boxShadow: (props: MyButtonProps) =>
props.color === 'red'
? '0 3px 5px 2px rgba(255, 105, 135, .3)'
: '0 3px 5px 2px rgba(33, 203, 243, .3)',
color: 'white',
height: 48,
padding: '0 30px',
margin: 8,
});

export default function AdaptingStyledComponents() {
return (
<React.Fragment>
<MyButton color="red">Red</MyButton>
<MyButton color="blue">Blue</MyButton>
</React.Fragment>
);
}
4 changes: 1 addition & 3 deletions docs/src/pages/system/basics/JSS.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ const Box = styled('div')(
),
);

function JSS() {
export default function JSS() {
return (
<Box color="white" bgcolor="palevioletred" p={1}>
JSS
</Box>
);
}

export default JSS;
4 changes: 1 addition & 3 deletions docs/src/pages/system/basics/JSS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ const Box = styled('div')(
),
);

function JSS() {
export default function JSS() {
return (
<Box color="white" bgcolor="palevioletred" p={1}>
JSS
</Box>
);
}

export default JSS;

0 comments on commit 2c646e5

Please sign in to comment.