generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 4
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
fa1e2f5
commit b3a5321
Showing
11 changed files
with
265 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,20 @@ | ||
import React from 'react'; | ||
import { Segment, Card } from 'semantic-ui-react'; | ||
import { Icon } from '@plone/volto/components'; | ||
import { isEqual } from 'lodash'; | ||
|
||
export default React.memo( | ||
({ data, onChange, children, variants }) => { | ||
// data by default is like { '@type': 'columns } | ||
const mounted = React.useRef(); | ||
React.useEffect(() => { | ||
if (!mounted.current) console.log('mount column variations'); | ||
mounted.current = true; | ||
}); | ||
|
||
return Object.keys(data).length === 1 ? ( | ||
<Segment> | ||
<Card.Group> | ||
{variants.map(({ icon, defaultData, title }, index) => ( | ||
<Card key={index} onClick={() => onChange(defaultData)}> | ||
<Card.Content> | ||
<Icon name={icon} /> | ||
{title ? <Card.Header>{title}</Card.Header> : ''} | ||
</Card.Content> | ||
</Card> | ||
))} | ||
</Card.Group> | ||
</Segment> | ||
) : ( | ||
children | ||
); | ||
}, | ||
(p, n) => { | ||
const res = | ||
isEqual(p.data, n.data) && | ||
p.selected === n.selected && | ||
isEqual(n.colSelections, p.colSelections); | ||
console.log('variantions', res); | ||
return res; | ||
}, | ||
); | ||
export default ({ data, onChange, children, variants }) => { | ||
return ( | ||
<Segment> | ||
<Card.Group> | ||
{variants.map(({ icon, defaultData, title }, index) => ( | ||
<Card key={index} onClick={() => onChange(defaultData)}> | ||
<Card.Content> | ||
<Icon name={icon} /> | ||
{title ? <Card.Header>{title}</Card.Header> : ''} | ||
</Card.Content> | ||
</Card> | ||
))} | ||
</Card.Group> | ||
</Segment> | ||
); | ||
}; |
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,13 @@ | ||
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 { | ||
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,70 @@ | ||
export const StyleSchema = () => ({ | ||
title: 'Styling', | ||
fieldsets: [ | ||
{ | ||
id: 'default', | ||
title: 'Style', | ||
fields: ['backgroundColor'], | ||
}, | ||
], | ||
properties: { | ||
backgroundColor: { | ||
title: 'Background color', | ||
type: 'color', | ||
widget: 'simple_color_picker', | ||
}, | ||
}, | ||
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: [], | ||
}; | ||
|
||
export const AdvancedSettingsSchema = { | ||
title: 'Advanced settings', | ||
fieldsets: [ | ||
{ | ||
id: 'advanced_fullcontrol', | ||
title: 'Advanced settings', | ||
fields: [ | ||
'grid_column_margin', | ||
'grid_column_padding', | ||
// 'grid_column_inline_style', | ||
], | ||
}, | ||
], | ||
properties: { | ||
grid_column_margin: { | ||
title: 'Margin', | ||
widget: 'textarea', | ||
}, | ||
grid_column_padding: { | ||
title: 'Padding', | ||
widget: 'textarea', | ||
}, | ||
// grid_column_inline_style: { | ||
// title: 'Inline style', | ||
// widget: 'json_text', | ||
// }, | ||
}, | ||
required: [], | ||
}; |
File renamed without changes.
Oops, something went wrong.