-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[styles] Make StyleRules backwards compatible (#16200)
* Refactor needed types to @material-ui/types * Revert to old types if there are no props * Add typescript version of DynamicInlineStyle * docs:typescript:formatted
- Loading branch information
Showing
7 changed files
with
148 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
docs/src/pages/customization/components/DynamicInlineStyle.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
import Button from '@material-ui/core/Button'; | ||
import FormControlLabel from '@material-ui/core/FormControlLabel'; | ||
import Switch from '@material-ui/core/Switch'; | ||
import { createStyles } from '@material-ui/core/styles'; | ||
|
||
const styles = createStyles({ | ||
button: { | ||
background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)', | ||
borderRadius: 3, | ||
border: 0, | ||
color: 'white', | ||
height: 48, | ||
padding: '0 30px', | ||
boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)', | ||
}, | ||
buttonBlue: { | ||
background: 'linear-gradient(45deg, #2196f3 30%, #21cbf3 90%)', | ||
boxShadow: '0 3px 5px 2px rgba(33, 203, 243, .30)', | ||
}, | ||
}); | ||
|
||
export default function DynamicInlineStyle() { | ||
const [color, setColor] = React.useState('default'); | ||
|
||
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
setColor(event.target.checked ? 'blue' : 'default'); | ||
}; | ||
|
||
return ( | ||
<React.Fragment> | ||
<FormControlLabel | ||
control={ | ||
<Switch | ||
checked={color === 'blue'} | ||
onChange={handleChange} | ||
color="primary" | ||
value="dynamic-class-name" | ||
/> | ||
} | ||
label="Blue" | ||
/> | ||
<Button | ||
style={{ | ||
...styles.button, | ||
...(color === 'blue' ? styles.buttonBlue : {}), | ||
}} | ||
> | ||
{'dynamic inline-style'} | ||
</Button> | ||
</React.Fragment> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters