Last active
December 16, 2019 01:28
-
-
Save geofftech/903ff7d2ce99017552ab064a309f9e28 to your computer and use it in GitHub Desktop.
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
import SpeedDial from "@material-ui/lab/SpeedDial"; | |
import SpeedDialIcon from "@material-ui/lab/SpeedDialIcon"; | |
import SpeedDialAction from "@material-ui/lab/SpeedDialAction"; | |
import { useState } from "react"; | |
const FloatingSpeeddial = ({ actions }) => { | |
const [speeddialOpen, setSpeeddialOpen] = useState(false); | |
const handleCloseSpeeddial = () => { | |
setSpeeddialOpen(false); | |
}; | |
const handleOpenSpeeddial = () => { | |
setSpeeddialOpen(true); | |
}; | |
const handleClick = onClick => { | |
console.log("handleClick"); | |
onClick(); | |
setSpeeddialOpen(false); | |
}; | |
return ( | |
<SpeedDial | |
ariaLabel="Actions" | |
icon={<SpeedDialIcon />} | |
onClose={handleCloseSpeeddial} | |
onOpen={handleOpenSpeeddial} | |
open={speeddialOpen} | |
// direction={} | |
style={{ | |
position: "fixed", | |
right: 20, | |
bottom: 20 | |
}}> | |
{actions.map(({ name, icon, onClick }) => ( | |
<SpeedDialAction | |
key={name} | |
icon={icon} | |
tooltipTitle={name} | |
tooltipOpen | |
onClick={() => handleClick(onClick)} | |
/> | |
))} | |
</SpeedDial> | |
); | |
}; | |
export default FloatingSpeeddial; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment