Skip to content

Commit

Permalink
Added WIP Block frontpage hero
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsilaghi committed Apr 1, 2020
1 parent 200ee77 commit d3f3100
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/components/Blocks/FrontpageHero/FrontpageHeroEdit.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';

import { SidebarPortal } from '@plone/volto/components'; // EditBlock
import { BlockEditForm } from 'volto-addons/BlockForm';

import schema from './schema';

class Edit extends Component {
componentDidMount() {
this.props.changeSidebarState(true);
}

componentDidUpdate(prevProps) {
this.props.changeSidebarState(true);
}

render() {
return (
<div className="block selected">
<div className="block-inner-wrapper" />

<FrontpageHero />

<SidebarPortal selected={this.props.selected}>
<BlockEditForm
schema={schema}
title={schema.title}
onChangeField={(id, value) => {
this.props.onChangeBlock(this.props.block, {
...this.props.data,
[id]: value,
});
}}
formData={this.props.data}
/>
</SidebarPortal>
</div>
);
}
}

export default connect(
null,
{},
)(Edit);
1 change: 1 addition & 0 deletions src/components/Blocks/FrontpageHero/FrontpageHeroView.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default Edit;
2 changes: 2 additions & 0 deletions src/components/Blocks/FrontpageHero/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export Edit from './EditFrontpageHero';
export View from './ViewFrontpageHero';
56 changes: 56 additions & 0 deletions src/components/Blocks/FrontpageHero/schema.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React from 'react';

const FrontpageHeroSchema = {
title: 'Edit hero',

fieldsets: [
{
id: 'default',
title: 'Default',
fields: ['lines', 'align'],
},
],

properties: {
lines: {
widget: 'objectlist',
title: 'Lines',
// this is an invention, should confront with dexterity serializer
schema: LineSchema,
},
align: {
title: 'Alignment',
widget: 'align',
type: 'string',
},
},

required: ['lines'],
};

export default ChartSchema;

const LineSchema = {
title: 'Line',

fieldsets: [
{
id: 'default',
title: 'Default',
fields: ['upper', 'lower'],
},
],

properties: {
upper: {
type: 'string',
title: 'Upper text',
},
lower: {
type: 'string',
title: 'Lower',
},
},

required: ['source'],
};

0 comments on commit d3f3100

Please sign in to comment.