-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Estrutura do bloco de calendário
- Loading branch information
Showing
8 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
frontend/packages/portalbrasil-intranet/src/components/Blocks/Calendario/Data.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,34 @@ | ||
import React from 'react'; | ||
import { BlockDataForm } from '@plone/volto/components'; | ||
import { calendarioSchema } from './schema'; | ||
import { useIntl } from 'react-intl'; | ||
|
||
const CalendarioBlockData = (props) => { | ||
const { data, block, onChangeBlock, blocksConfig, navRoot, contentType } = | ||
props; | ||
|
||
const intl = useIntl(); | ||
const schema = calendarioSchema({ ...props, intl }); | ||
const onChangeField = (id, value) => { | ||
onChangeBlock(block, { | ||
...data, | ||
[id]: value, | ||
}); | ||
}; | ||
|
||
return ( | ||
<BlockDataForm | ||
schema={schema} | ||
title={schema.title} | ||
onChangeField={onChangeField} | ||
onChangeBlock={onChangeBlock} | ||
formData={data} | ||
block={block} | ||
blocksConfig={blocksConfig} | ||
navRoot={navRoot} | ||
contentType={contentType} | ||
/> | ||
); | ||
}; | ||
|
||
export default CalendarioBlockData; |
34 changes: 34 additions & 0 deletions
34
frontend/packages/portalbrasil-intranet/src/components/Blocks/Calendario/DefaultView.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,34 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Calendar } from '@plone/components'; | ||
import '@plone/components/src/styles/basic/Calendar.css'; | ||
|
||
const CalendarioView = (props) => { | ||
const { heading, className } = props; | ||
return ( | ||
<div className={`block calendarioBlock ${className}`}> | ||
<h2>{heading}</h2> | ||
<Calendar /> | ||
</div> | ||
); | ||
}; | ||
|
||
/** | ||
* Property types. | ||
* @property {Object} propTypes Property types. | ||
* @static | ||
*/ | ||
CalendarioView.propTypes = { | ||
heading: PropTypes.string, | ||
}; | ||
|
||
/** | ||
* Default properties. | ||
* @property {Object} defaultProps Default properties. | ||
* @static | ||
*/ | ||
CalendarioView.defaultProps = { | ||
heading: 'Eventos', | ||
}; | ||
|
||
export default CalendarioView; |
24 changes: 24 additions & 0 deletions
24
frontend/packages/portalbrasil-intranet/src/components/Blocks/Calendario/Edit.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,24 @@ | ||
import React from 'react'; | ||
import { withBlockExtensions } from '@plone/volto/helpers'; | ||
import { SidebarPortal } from '@plone/volto/components'; | ||
|
||
import CalendarioBlockData from './Data'; | ||
import CalendarioBlockView from './View'; | ||
|
||
const CalendarioBlockEdit = (props) => { | ||
const { data, onChangeBlock, block, selected } = props; | ||
return ( | ||
<> | ||
<CalendarioBlockView {...props} isEditMode /> | ||
<SidebarPortal selected={selected}> | ||
<CalendarioBlockData | ||
data={data} | ||
block={block} | ||
onChangeBlock={onChangeBlock} | ||
/> | ||
</SidebarPortal> | ||
</> | ||
); | ||
}; | ||
|
||
export default withBlockExtensions(CalendarioBlockEdit); |
12 changes: 12 additions & 0 deletions
12
frontend/packages/portalbrasil-intranet/src/components/Blocks/Calendario/View.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,12 @@ | ||
import React from 'react'; | ||
import { withBlockExtensions } from '@plone/volto/helpers'; | ||
import CalendarioView from './DefaultView'; | ||
|
||
const CalendarioBlockView = (props) => { | ||
const { data, isEditMode, className } = props; | ||
return ( | ||
<CalendarioView {...data} isEditMode={isEditMode} className={className} /> | ||
); | ||
}; | ||
|
||
export default withBlockExtensions(CalendarioBlockView); |
32 changes: 32 additions & 0 deletions
32
frontend/packages/portalbrasil-intranet/src/components/Blocks/Calendario/schema.js
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 { defineMessages } from 'react-intl'; | ||
|
||
const messages = defineMessages({ | ||
blockTitle: { | ||
id: 'Calendário', | ||
defaultMessage: 'Calendário', | ||
}, | ||
heading: { | ||
id: 'Título', | ||
defaultMessage: 'Título', | ||
}, | ||
}); | ||
|
||
export const calendarioSchema = (props) => { | ||
return { | ||
title: props.intl.formatMessage(messages.blockTitle), | ||
fieldsets: [ | ||
{ | ||
id: 'default', | ||
title: 'Default', | ||
fields: ['heading'], | ||
}, | ||
], | ||
properties: { | ||
heading: { | ||
title: props.intl.formatMessage(messages.heading), | ||
default: 'Eventos', | ||
}, | ||
}, | ||
required: ['heading'], | ||
}; | ||
}; |
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
4 changes: 4 additions & 0 deletions
4
frontend/packages/portalbrasil-intranet/src/theme/blocks/_calendario.scss
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,4 @@ | ||
// Estilos do bloco de calendário | ||
.block.calendarioBlock { | ||
padding: $spacing-small; | ||
} |