-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created a new TutorialColorPicker file, that is the exact same as Col…
…orPicker except with a Save button
- Loading branch information
Jasmine Tran
committed
Oct 4, 2023
1 parent
958bacc
commit 7b95657
Showing
2 changed files
with
87 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { Box, Button, ButtonGroup, ListItem, Popover, TextField } from '@mui/material'; | ||
import { Colorful } from '@uiw/react-color'; | ||
|
||
import { ColorIndicatorBox, StyledButtonContainer } from '../../styles/ControlStyles'; | ||
import styled from '@emotion/styled'; | ||
|
||
const BoxStyle = styled(Box)` | ||
padding-bottom: 20px | ||
` | ||
const TutorialColorPicker: React.FC<any> = ({ | ||
color, | ||
setColor, | ||
colorPickerAnchorEl, | ||
handleOpenColorPicker, | ||
handleCloseColorPicker, | ||
handleSaveNewTutorialColor, | ||
}) => { | ||
// Whether the colour picker popover is shown | ||
const openColorPickerPopover = Boolean(colorPickerAnchorEl); | ||
const colorPickerPopoverId = openColorPickerPopover ? 'simple-popover' : undefined; | ||
|
||
return ( | ||
<BoxStyle m={1} display="flex" justifyContent="center" alignItems="center"> | ||
<ColorIndicatorBox backgroundColor={color} onClick={handleOpenColorPicker} /> | ||
<StyledButtonContainer> | ||
<ButtonGroup> | ||
<Button | ||
disableElevation | ||
variant="contained" | ||
size="small" | ||
aria-describedby={colorPickerPopoverId} | ||
onClick={handleOpenColorPicker} | ||
> | ||
Choose Colour | ||
</Button> | ||
<Button | ||
variant="outlined" | ||
size="small" | ||
onClick={handleSaveNewTutorialColor} | ||
> | ||
Save | ||
</Button> | ||
</ButtonGroup> | ||
</StyledButtonContainer> | ||
<Popover | ||
id={colorPickerPopoverId} | ||
open={openColorPickerPopover} | ||
anchorEl={colorPickerAnchorEl} | ||
onClose={handleCloseColorPicker} | ||
anchorOrigin={{ | ||
vertical: 'bottom', | ||
horizontal: 'left', | ||
}} | ||
transformOrigin={{ | ||
vertical: 'top', | ||
horizontal: 'left', | ||
}} | ||
> | ||
<ListItem alignItems="flex-start"> | ||
<Colorful onChange={(e) => setColor(e.hex)} color={color} /> | ||
</ListItem> | ||
<ListItem alignItems="flex-start"> | ||
<TextField | ||
id="outlined-required" | ||
label="Hex" | ||
variant="outlined" | ||
value={color} | ||
onChange={(e) => { | ||
setColor(e.target.value); | ||
}} | ||
/> | ||
</ListItem> | ||
</Popover> | ||
</BoxStyle> | ||
); | ||
}; | ||
|
||
export default TutorialColorPicker; |
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