Created
May 5, 2019 13:55
-
-
Save zprima/4af4f65d39edf0ba24cc2e54490dabfa to your computer and use it in GitHub Desktop.
medium_p7_c4
This file contains hidden or 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 React from "react"; | |
| import { PainterContext } from "../contexts/PainterContext"; | |
| function ColorPicker(_) { | |
| const { colors, setColor } = React.useContext(PainterContext); | |
| const colorOption = color => { | |
| return ( | |
| <div | |
| key={color.name} | |
| className="color" | |
| style={{ backgroundColor: color.hex }} | |
| onClick={() => setColor(color)} | |
| /> | |
| ); | |
| }; | |
| const colorOptions = () => { | |
| return colors.map(color => { | |
| return colorOption(color); | |
| }); | |
| }; | |
| return <div className="colorpicker">{colorOptions()}</div>; | |
| } | |
| export default ColorPicker; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment