generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 3
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
911be87
commit 361f74e
Showing
13 changed files
with
329 additions
and
128 deletions.
There are no files selected for viewing
Empty file.
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
import React from 'react'; | ||
import { Segment, Card } from 'semantic-ui-react'; | ||
import { Icon } from '@plone/volto/components'; | ||
|
||
export default ({ data, onChange, children, variants }) => { | ||
// data by default is like { '@type': 'columns } | ||
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 | ||
); | ||
}; |
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 was deleted.
Oops, something went wrong.
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,77 @@ | ||
import React from 'react'; | ||
import { Icon } from '@plone/volto/components'; | ||
import { blockHasValue } from '@plone/volto/helpers'; | ||
import dragSVG from '@plone/volto/icons/drag.svg'; | ||
import { blocks } from '~/config'; | ||
import { Button } from 'semantic-ui-react'; | ||
import includes from 'lodash/includes'; | ||
import isBoolean from 'lodash/isBoolean'; | ||
import { defineMessages, injectIntl } from 'react-intl'; | ||
|
||
import trashSVG from '@plone/volto/icons/delete.svg'; | ||
|
||
const messages = defineMessages({ | ||
unknownBlock: { | ||
id: 'Unknown Block', | ||
defaultMessage: 'Unknown Block {block}', | ||
}, | ||
delete: { | ||
id: 'delete', | ||
defaultMessage: 'delete', | ||
}, | ||
}); | ||
|
||
const EditBlockWrapper = (props) => { | ||
const { | ||
draginfo, | ||
block, | ||
selected, | ||
children, | ||
blockId, | ||
onDeleteBlock, | ||
intl, | ||
} = props; | ||
console.log('block', block); | ||
const type = block['@type']; | ||
const visible = selected && blockHasValue(block) && !block.fixed; | ||
|
||
const required = isBoolean(block.required) | ||
? block.required | ||
: includes(blocks.requiredBlocks, type); | ||
|
||
return ( | ||
<div | ||
ref={draginfo.innerRef} | ||
{...draginfo.draggableProps} | ||
className={`block-editor-${block['@type']}`} | ||
> | ||
<div style={{ position: 'relative' }}> | ||
<div | ||
style={{ | ||
visibility: visible ? 'visible' : 'hidden', | ||
display: 'inline-block', | ||
}} | ||
{...draginfo.dragHandleProps} | ||
className="drag handle wrapper" | ||
> | ||
<Icon name={dragSVG} size="18px" /> | ||
</div> | ||
|
||
{selected && !required && ( | ||
<Button | ||
icon | ||
basic | ||
onClick={() => onDeleteBlock(blockId)} | ||
className="delete-button" | ||
aria-label={intl.formatMessage(messages.delete)} | ||
> | ||
<Icon name={trashSVG} size="18px" /> | ||
</Button> | ||
)} | ||
</div> | ||
<div className={`ui drag block inner ${type}`}>{children}</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default injectIntl(EditBlockWrapper); |
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
Oops, something went wrong.