-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Announcement block to the project
- Loading branch information
1 parent
49f5db1
commit dc18545
Showing
7 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
frontend/src/components/blocks/Announcement/AnnouncementEdit.jsx
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,32 @@ | ||
import React from 'react'; | ||
import { BlockDataForm, SidebarPortal } from '@plone/volto/components'; | ||
|
||
import ButtonBlockSchema from './schema'; | ||
import AnnouncementView from './AnnouncementView'; | ||
|
||
const ButtonEdit = (props) => { | ||
const { block, onChangeBlock, data = {}, selected } = props; | ||
const schema = ButtonBlockSchema(props); | ||
|
||
return ( | ||
<> | ||
<AnnouncementView {...props} mode="edit" /> | ||
|
||
<SidebarPortal selected={selected}> | ||
<BlockDataForm | ||
key={Object.keys(data?.cards || {}).length} | ||
schema={schema} | ||
onChangeField={(id, value) => { | ||
onChangeBlock(block, { | ||
...data, | ||
[id]: value, | ||
}); | ||
}} | ||
formData={data} | ||
/> | ||
</SidebarPortal> | ||
</> | ||
); | ||
}; | ||
|
||
export default ButtonEdit; |
14 changes: 14 additions & 0 deletions
14
frontend/src/components/blocks/Announcement/AnnouncementView.jsx
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,14 @@ | ||
import React from 'react'; | ||
import './less/Announcement.less'; | ||
|
||
const ButtonView = ({ data, mode = 'view' }) => { | ||
return ( | ||
<div className="AnnouncementBlock"> | ||
<div className="message"> | ||
{data.Title && <h3>{data.Title}</h3>} | ||
{data.Text && <p>{data.Text}</p>} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
export default ButtonView; |
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,26 @@ | ||
import aheadSVG from '@plone/volto/icons/ahead.svg'; | ||
|
||
import AnnouncementView from './AnnouncementView'; | ||
import AnnouncementEdit from './AnnouncementEdit'; | ||
|
||
const installAnnouncementBlock = (config) => { | ||
config.blocks.blocksConfig.announcementBlock = { | ||
id: 'announcementBlock', | ||
title: 'Announcement', | ||
icon: aheadSVG, | ||
group: 'common', | ||
view: AnnouncementView, | ||
edit: AnnouncementEdit, | ||
restricted: false, | ||
mostUsed: false, | ||
sidebarTab: 1, | ||
security: { | ||
addPermission: [], | ||
view: [], | ||
}, | ||
}; | ||
|
||
return config; | ||
}; | ||
|
||
export default installAnnouncementBlock; |
26 changes: 26 additions & 0 deletions
26
frontend/src/components/blocks/Announcement/less/Announcement.less
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,26 @@ | ||
.AnnouncementBlock { | ||
background-color: yellow; | ||
position: relative; | ||
width: 100vw; | ||
left: 50%; | ||
right: 50%; | ||
margin-right: -50vw; | ||
margin-left: -50vw; | ||
text-align: center; | ||
height: 150px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
|
||
.message{ | ||
margin-left: 40px !important; | ||
margin-right: 40px !important; | ||
|
||
h3, p { | ||
margin: 0 !important; | ||
} | ||
p:nth-child(2) { | ||
margin-top: 15px !important; | ||
} | ||
} | ||
} |
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,43 @@ | ||
import { defineMessages } from 'react-intl'; | ||
|
||
const messages = defineMessages({ | ||
Announcement: { | ||
id: 'Announcement', | ||
defaultMessage: 'Announcement', | ||
}, | ||
}); | ||
|
||
const AnnouncementSchema = ({ | ||
onChangeBlock, | ||
intl, | ||
data, | ||
openObjectBrowser, | ||
}) => ({ | ||
title: intl.formatMessage(messages.Announcement), | ||
fieldsets: [ | ||
{ | ||
id: 'default', | ||
fields: ['Title', 'Text'], | ||
title: 'Default', | ||
}, | ||
], | ||
|
||
properties: { | ||
Title: { | ||
title: 'Announcement title', | ||
}, | ||
Text: { | ||
title: 'Announcement text', | ||
}, | ||
// linkHref: { | ||
// title: 'Call to action', | ||
// widget: 'object_browser', | ||
// mode: 'link', | ||
// selectedItemAttrs: ['Title', 'Description'], | ||
// allowExternals: true, | ||
// }, | ||
}, | ||
required: [], | ||
}); | ||
|
||
export default AnnouncementSchema; |
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