From 91bb2e8a0ad0d3bd99165751f319bceb99e181e0 Mon Sep 17 00:00:00 2001 From: Alin Voinea Date: Thu, 10 Mar 2022 12:41:20 +0200 Subject: [PATCH 1/4] Fix package.json --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index c25127d..069af3a 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,3 @@ "cypress:open": "if [ -d ./project ]; then NODE_ENV=development ./project/node_modules/cypress/bin/cypress open; else NODE_ENV=development ../../../node_modules/cypress/bin/cypress open; fi" } } -s/cypress/bin/cypress open; else NODE_ENV=development ../../../node_modules/cypress/bin/cypress open; fi" - } -} From 2ecde424229d79e12d2c91223d56117255f33cfc Mon Sep 17 00:00:00 2001 From: Alexandru Ghica Date: Thu, 10 Mar 2022 15:42:48 +0200 Subject: [PATCH 2/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac5d21c..40881c4 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ ## Features -Demo GIF +https://eea.github.io/volto-kitkat-frontend/?path=/story/components-statistic--default ## Getting started From df367cbf7912d99ae7fbd0c5f20f1c9f590d1512 Mon Sep 17 00:00:00 2001 From: Miu Razvan Date: Thu, 10 Mar 2022 17:20:03 +0200 Subject: [PATCH 3/4] add statistic block --- src/StatisticBlock/Edit.jsx | 31 +++++++++++++++++ src/StatisticBlock/View.jsx | 38 +++++++++++++++++++++ src/StatisticBlock/index.js | 22 +++++++++++++ src/StatisticBlock/schema.js | 64 ++++++++++++++++++++++++++++++++++++ src/index.js | 4 ++- 5 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 src/StatisticBlock/Edit.jsx create mode 100644 src/StatisticBlock/View.jsx create mode 100644 src/StatisticBlock/index.js create mode 100644 src/StatisticBlock/schema.js diff --git a/src/StatisticBlock/Edit.jsx b/src/StatisticBlock/Edit.jsx new file mode 100644 index 0000000..89fa4bf --- /dev/null +++ b/src/StatisticBlock/Edit.jsx @@ -0,0 +1,31 @@ +import React from 'react'; +import { SidebarPortal } from '@plone/volto/components'; +import InlineForm from '@plone/volto/components/manage/Form/InlineForm'; +import View from './View'; +import schema from './schema'; + +const Edit = (props) => { + const { data = {}, block = null, selected = false, onChangeBlock } = props; + + return ( + <> + + + + { + onChangeBlock(block, { + ...data, + [id]: value, + }); + }} + formData={data} + /> + + + ); +}; + +export default Edit; diff --git a/src/StatisticBlock/View.jsx b/src/StatisticBlock/View.jsx new file mode 100644 index 0000000..891e444 --- /dev/null +++ b/src/StatisticBlock/View.jsx @@ -0,0 +1,38 @@ +import React from 'react'; +import { Statistic } from 'semantic-ui-react'; + +const View = ({ data, mode }) => { + const { + horizontal = false, + inverted = false, + size = 'small', + widths = 'one', + items = [], + } = data; + + if (!items.length && mode === 'edit') return

Add statistic items

; + return ( +
+ + {items.map((item, index) => { + return ( + + {item.value} + {item.label} + + ); + })} + +
+ ); +}; + +export default View; diff --git a/src/StatisticBlock/index.js b/src/StatisticBlock/index.js new file mode 100644 index 0000000..bb5d897 --- /dev/null +++ b/src/StatisticBlock/index.js @@ -0,0 +1,22 @@ +import worldSVG from '@plone/volto/icons/world.svg'; +import StatisticBlockEdit from './Edit'; +import StatisticBlockView from './View'; + +export default (config) => { + config.blocks.blocksConfig.statistic_block = { + id: 'statistic_block', + title: 'Statistic block', + icon: worldSVG, + group: 'text', + view: StatisticBlockView, + edit: StatisticBlockEdit, + restricted: false, + mostUsed: false, + sidebarTab: 1, + security: { + addPermission: [], + view: [], + }, + }; + return config; +}; diff --git a/src/StatisticBlock/schema.js b/src/StatisticBlock/schema.js new file mode 100644 index 0000000..632be9a --- /dev/null +++ b/src/StatisticBlock/schema.js @@ -0,0 +1,64 @@ +const statisticSchema = { + title: 'Statistic item', + fieldsets: [{ id: 'default', title: 'Default', fields: ['value', 'label'] }], + properties: { + value: { + title: 'Value', + }, + label: { + title: 'Label', + }, + }, + required: [], +}; + +export default { + title: 'Statistic block', + + fieldsets: [ + { + id: 'default', + title: 'Default', + fields: ['horizontal', 'inverted', 'size', 'widths', 'items'], + }, + ], + + properties: { + horizontal: { + title: 'Horizontal', + description: 'Can present its measurement horizontally', + type: 'boolean', + }, + inverted: { + title: 'Inverted', + description: 'Can be formatted to fit on a dark background.', + type: 'boolean', + }, + size: { + title: 'Size', + choices: [ + ['mini', 'Mini'], + ['tiny', 'Tiny'], + ['small', 'Small'], + ['large', 'Large'], + ['huge', 'Huge'], + ], + }, + widths: { + title: 'Columns', + choices: [ + ['one', 'One'], + ['two', 'Two'], + ['three', 'Three'], + ['four', 'Four'], + ], + }, + items: { + title: 'Statistic items', + widget: 'object_list', + schema: statisticSchema, + }, + }, + + required: [], +}; diff --git a/src/index.js b/src/index.js index cb042f0..64b7997 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,7 @@ +import installStatisticBlock from './StatisticBlock'; + const applyConfig = (config) => { - return config; + return [installStatisticBlock].reduce((acc, apply) => apply(acc), config); }; export default applyConfig; From 9ae112901488222f2add0b9b61623dcb62a2a39c Mon Sep 17 00:00:00 2001 From: EEA Jenkins <@users.noreply.github.com> Date: Thu, 10 Mar 2022 15:29:03 +0000 Subject: [PATCH 4/4] Automated release 0.1.1 --- CHANGELOG.md | 18 +++++++++++++++--- package.json | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3742d31..435d59f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ -# Changelog +### Changelog -## 0.1.0 +All notable changes to this project will be documented in this file. Dates are displayed in UTC. -- Initial release +Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). + +#### [0.1.1](https://github.com/eea/volto-statistic-block/compare/0.1.0...0.1.1) + +- add statistic block [`df367cb`](https://github.com/eea/volto-statistic-block/commit/df367cbf7912d99ae7fbd0c5f20f1c9f590d1512) +- Update README.md [`2ecde42`](https://github.com/eea/volto-statistic-block/commit/2ecde424229d79e12d2c91223d56117255f33cfc) +- Fix package.json [`91bb2e8`](https://github.com/eea/volto-statistic-block/commit/91bb2e8a0ad0d3bd99165751f319bceb99e181e0) + +#### 0.1.0 + +> 9 March 2022 + +- Initial commit [`2e19fe2`](https://github.com/eea/volto-statistic-block/commit/2e19fe2708f89887d2d79f88696e197643ea10f4) diff --git a/package.json b/package.json index 069af3a..ac2b5de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-statistic-block", - "version": "0.1.0", + "version": "0.1.1", "description": "@eeacms/volto-statistic-block: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team",