-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve usability of the theme color picker widget. Rename the name o…
…f the widget. Fix error when removing a logo.
- Loading branch information
Showing
6 changed files
with
80 additions
and
6 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
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
File renamed without changes.
53 changes: 53 additions & 0 deletions
53
packages/volto-light-theme/src/components/Widgets/ThemeColorPicker.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 FormFieldWrapper from '@plone/volto/components/manage/Widgets/FormFieldWrapper'; | ||
import { HexColorPicker, HexColorInput } from 'react-colorful'; | ||
import { Button, Dialog, DialogTrigger, Popover } from 'react-aria-components'; | ||
import { ColorSwatch, CloseIcon } from '@plone/components'; | ||
|
||
const ColorPickerWidget = (props: { | ||
id: string; | ||
title: string; | ||
value: string; | ||
default: string; | ||
onChange: (id: string, value: any) => void; | ||
}) => { | ||
const { id, onChange, value } = props; | ||
|
||
return ( | ||
<FormFieldWrapper {...props} className="theme-color-picker"> | ||
<DialogTrigger> | ||
<Button className="theme-color-picker-button"> | ||
<ColorSwatch color={value || '#fff'} /> | ||
</Button> | ||
|
||
<Popover placement="bottom start"> | ||
<Dialog className="theme-color-picker-dialog"> | ||
<HexColorPicker | ||
color={value || ''} | ||
onChange={(value) => { | ||
// edge case for Batman value | ||
if (value !== '#NaNNaNNaN') { | ||
onChange(id, value); | ||
} | ||
}} | ||
/> | ||
</Dialog> | ||
</Popover> | ||
</DialogTrigger> | ||
<HexColorInput | ||
color={value || ''} | ||
onChange={(value) => onChange(id, value)} | ||
prefixed | ||
/> | ||
<Button | ||
className="theme-color-picker-reset react-aria-Button" | ||
onPress={() => { | ||
onChange(id, ''); | ||
}} | ||
> | ||
<CloseIcon size="S" /> | ||
</Button> | ||
</FormFieldWrapper> | ||
); | ||
}; | ||
|
||
export default ColorPickerWidget; |
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