generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb8fdee
commit 22995fd
Showing
8 changed files
with
186 additions
and
10 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
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
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,15 @@ | ||
import { StyleSchema } from './schema'; | ||
|
||
export function makeStyleSchema({ available_colors }) { | ||
const schema = StyleSchema(); | ||
schema.properties.backgroundColor.available_colors = available_colors; | ||
return schema; | ||
} | ||
|
||
export function getStyle(props) { | ||
return { | ||
style: { | ||
backgroundColor: props.backgroundColor, | ||
}, | ||
}; | ||
} |
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,48 @@ | ||
export const StyleSchema = () => ({ | ||
title: 'Styling', | ||
fieldsets: [ | ||
{ | ||
id: 'default', | ||
title: 'Style', | ||
fields: ['backgroundColor'], | ||
}, | ||
], | ||
properties: { | ||
backgroundColor: { | ||
title: 'Background color', | ||
type: 'color', | ||
widget: 'color_picker', | ||
}, | ||
// grid_vertical_align: { | ||
// title: 'Vertical align', | ||
// choices: [ | ||
// ['bottom', 'Bottom'], | ||
// ['middle', 'Middle'], | ||
// ['top', 'Top'], | ||
// ], | ||
// }, | ||
}, | ||
required: [], | ||
}); | ||
|
||
export const TextSettingsSchema = { | ||
title: 'Text settings', | ||
fieldsets: [ | ||
{ | ||
id: 'text_settings', | ||
title: 'Text settings', | ||
fields: ['grid_column_align_text', 'grid_column_text_color'], | ||
}, | ||
], | ||
properties: { | ||
grid_column_align_text: { | ||
title: 'Text align', | ||
widget: 'align', | ||
}, | ||
grid_column_text_color: { | ||
title: 'Text color', | ||
widget: 'color_picker', | ||
}, | ||
}, | ||
required: [], | ||
}; |
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,63 @@ | ||
import React from 'react'; | ||
import { FormFieldWrapper, Icon } from '@plone/volto/components'; | ||
import { Button } from 'semantic-ui-react'; | ||
import loadable from '@loadable/component'; | ||
import clearSVG from '@plone/volto/icons/clear.svg'; | ||
|
||
const ReactColor = loadable.lib(() => import('react-color')); | ||
|
||
export default (props) => { | ||
const { id, value, onChange, available_colors } = props; | ||
const [showPicker, setShowPicker] = React.useState(false); | ||
|
||
return ( | ||
<FormFieldWrapper | ||
{...props} | ||
draggable={false} | ||
className="simple-color-picker-widget" | ||
> | ||
<div> | ||
<Button.Group> | ||
<Button | ||
color={value} | ||
style={{ backgroundColor: value }} | ||
onClick={() => setShowPicker(true)} | ||
size="huge" | ||
title="Pick color" | ||
> | ||
{''} | ||
</Button> | ||
<Button | ||
compact | ||
style={{ paddingLeft: '8px', paddingRight: '0px' }} | ||
onClick={() => onChange(id, null)} | ||
> | ||
<Icon name={clearSVG} size="18px" color="red" /> | ||
</Button> | ||
</Button.Group> | ||
|
||
{showPicker ? ( | ||
<ReactColor> | ||
{({ GithubPicker }) => { | ||
return ( | ||
<GithubPicker | ||
width="220px" | ||
triangle="top" | ||
className="color-picker" | ||
colors={available_colors} | ||
color={value || '#000'} | ||
onChangeComplete={(value) => { | ||
setShowPicker(false); | ||
onChange(id, value.hex); | ||
}} | ||
></GithubPicker> | ||
); | ||
}} | ||
</ReactColor> | ||
) : ( | ||
'' | ||
)} | ||
</div> | ||
</FormFieldWrapper> | ||
); | ||
}; |
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