-
-
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.
[docs] Migrate SpeedDial to emotion (#25367)
- Loading branch information
Showing
11 changed files
with
244 additions
and
290 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
108 changes: 17 additions & 91 deletions
108
docs/src/pages/components/speed-dial/BasicSpeedDial.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 |
---|---|---|
@@ -1,110 +1,36 @@ | ||
import * as React from 'react'; | ||
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles'; | ||
import FormControlLabel from '@material-ui/core/FormControlLabel'; | ||
import FormLabel from '@material-ui/core/FormLabel'; | ||
import Radio from '@material-ui/core/Radio'; | ||
import RadioGroup from '@material-ui/core/RadioGroup'; | ||
import Switch from '@material-ui/core/Switch'; | ||
import SpeedDial, { SpeedDialProps } from '@material-ui/core/SpeedDial'; | ||
import Box from '@material-ui/core/Box'; | ||
import SpeedDial from '@material-ui/core/SpeedDial'; | ||
import SpeedDialIcon from '@material-ui/core/SpeedDialIcon'; | ||
import SpeedDialAction from '@material-ui/core/SpeedDialAction'; | ||
import FileCopyIcon from '@material-ui/icons/FileCopyOutlined'; | ||
import SaveIcon from '@material-ui/icons/Save'; | ||
import PrintIcon from '@material-ui/icons/Print'; | ||
import ShareIcon from '@material-ui/icons/Share'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => | ||
createStyles({ | ||
root: { | ||
transform: 'translateZ(0px)', | ||
flexGrow: 1, | ||
}, | ||
exampleWrapper: { | ||
position: 'relative', | ||
marginTop: theme.spacing(3), | ||
height: 320, | ||
}, | ||
radioGroup: { | ||
margin: theme.spacing(1, 0), | ||
}, | ||
speedDial: { | ||
position: 'absolute', | ||
'&.MuiSpeedDial-directionUp, &.MuiSpeedDial-directionLeft': { | ||
bottom: theme.spacing(2), | ||
right: theme.spacing(2), | ||
}, | ||
'&.MuiSpeedDial-directionDown, &.MuiSpeedDial-directionRight': { | ||
top: theme.spacing(2), | ||
left: theme.spacing(2), | ||
}, | ||
}, | ||
}), | ||
); | ||
|
||
const actions = [ | ||
{ icon: <FileCopyIcon />, name: 'Copy' }, | ||
{ icon: <SaveIcon />, name: 'Save' }, | ||
{ icon: <PrintIcon />, name: 'Print' }, | ||
{ icon: <ShareIcon />, name: 'Share' }, | ||
]; | ||
|
||
export default function SpeedDials() { | ||
const classes = useStyles(); | ||
const [direction, setDirection] = React.useState<SpeedDialProps['direction']>( | ||
'up', | ||
); | ||
const [hidden, setHidden] = React.useState(false); | ||
|
||
const handleDirectionChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
setDirection( | ||
(event.target as HTMLInputElement).value as SpeedDialProps['direction'], | ||
); | ||
}; | ||
|
||
const handleHiddenChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
setHidden(event.target.checked); | ||
}; | ||
|
||
export default function BasicSpeedDial() { | ||
return ( | ||
<div className={classes.root}> | ||
<FormControlLabel | ||
control={ | ||
<Switch checked={hidden} onChange={handleHiddenChange} color="primary" /> | ||
} | ||
label="Hidden" | ||
/> | ||
<FormLabel className={classes.radioGroup} component="legend"> | ||
Direction | ||
</FormLabel> | ||
<RadioGroup | ||
aria-label="direction" | ||
name="direction" | ||
value={direction} | ||
onChange={handleDirectionChange} | ||
row | ||
<Box sx={{ height: 320, transform: 'translateZ(0px)', flexGrow: 1 }}> | ||
<SpeedDial | ||
ariaLabel="SpeedDial basic example" | ||
sx={{ position: 'absolute', bottom: 16, right: 16 }} | ||
icon={<SpeedDialIcon />} | ||
> | ||
<FormControlLabel value="up" control={<Radio />} label="Up" /> | ||
<FormControlLabel value="right" control={<Radio />} label="Right" /> | ||
<FormControlLabel value="down" control={<Radio />} label="Down" /> | ||
<FormControlLabel value="left" control={<Radio />} label="Left" /> | ||
</RadioGroup> | ||
<div className={classes.exampleWrapper}> | ||
<SpeedDial | ||
ariaLabel="SpeedDial example" | ||
className={classes.speedDial} | ||
hidden={hidden} | ||
icon={<SpeedDialIcon />} | ||
direction={direction} | ||
> | ||
{actions.map((action) => ( | ||
<SpeedDialAction | ||
key={action.name} | ||
icon={action.icon} | ||
tooltipTitle={action.name} | ||
/> | ||
))} | ||
</SpeedDial> | ||
</div> | ||
</div> | ||
{actions.map((action) => ( | ||
<SpeedDialAction | ||
key={action.name} | ||
icon={action.icon} | ||
tooltipTitle={action.name} | ||
/> | ||
))} | ||
</SpeedDial> | ||
</Box> | ||
); | ||
} |
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
Oops, something went wrong.