From 12a01abae8a2457578e7c44b7e55a4d8aaebe032 Mon Sep 17 00:00:00 2001 From: kreafox Date: Tue, 19 Sep 2023 10:52:36 +0300 Subject: [PATCH 1/4] Add tooltip size option --- src/editor/LabelWrapper.jsx | 88 +++++++++++++++++++++---------------- src/editor/schema.js | 11 +++++ 2 files changed, 61 insertions(+), 38 deletions(-) diff --git a/src/editor/LabelWrapper.jsx b/src/editor/LabelWrapper.jsx index ec118dd..bf50dbd 100644 --- a/src/editor/LabelWrapper.jsx +++ b/src/editor/LabelWrapper.jsx @@ -9,46 +9,58 @@ import { const LabelWrapper = (props) => { const { attributes, children, element } = props; const { data = {} } = element; - const { uid, label_type, label_pointing } = data; + const { + uid, + always_show, + label_type, + label_pointing, + tooltip_type, + tooltip_size, + tooltip_content, + tooltip_pointing, + } = data; + const isTooltipText = - data.tooltip_content && - serializeNodesToText(data.tooltip_content).trim().length > 0; + tooltip_content && serializeNodesToText(tooltip_content).trim().length > 0; - if (isTooltipText) { - return ( - - {children} - - ) : ( - - {children} - - ) - } - className={data.tooltip_type} - > - {serializeNodes(data.tooltip_content)} - - ); - } else { - return ( - - ); - } + return isTooltipText ? ( + + {children} + + ) : ( + + {children} + + ) + } + className={tooltip_type} + > + {serializeNodes(tooltip_content)} + + ) : ( + + ); }; export default LabelWrapper; diff --git a/src/editor/schema.js b/src/editor/schema.js index e9c61b2..c3eaf8b 100644 --- a/src/editor/schema.js +++ b/src/editor/schema.js @@ -13,6 +13,7 @@ export const LabelEditorSchema = { 'tooltip_content', 'tooltip_pointing', 'tooltip_type', + 'tooltip_size', 'always_show', ], }, @@ -77,6 +78,16 @@ export const LabelEditorSchema = { ], default: '', }, + tooltip_size: { + title: 'Tooltip size', + type: 'string', + factory: 'Choice', + choices: [ + ['wide', 'Wide'], + ['extra', 'Extra wide'], + ], + default: '', + }, always_show: { title: 'Always show tooltip', description: 'Always show the content label tooltip.', From 68ebc3005202f96e58a77a4beb930621d50f2887 Mon Sep 17 00:00:00 2001 From: kreafox Date: Tue, 19 Sep 2023 11:38:19 +0300 Subject: [PATCH 2/4] Update tests --- src/editor/LabelWrapper.test.jsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/editor/LabelWrapper.test.jsx b/src/editor/LabelWrapper.test.jsx index 5aa5847..0f66f8a 100644 --- a/src/editor/LabelWrapper.test.jsx +++ b/src/editor/LabelWrapper.test.jsx @@ -19,6 +19,7 @@ describe('LabelWrapper', () => { tooltip_pointing: 'top center', always_show: false, tooltip_type: 'info', + tooltip_size: 'wide', }, }, }; @@ -41,6 +42,7 @@ describe('LabelWrapper', () => { tooltip_pointing: 'top center', always_show: true, tooltip_type: 'info', + tooltip_size: 'wide', }, }, }; @@ -62,6 +64,7 @@ describe('LabelWrapper', () => { tooltip_pointing: 'top center', always_show: true, tooltip_type: 'info', + tooltip_size: 'wide', }, }, }; @@ -84,6 +87,7 @@ describe('LabelWrapper', () => { tooltip_pointing: 'top center', always_show: true, tooltip_type: 'info', + tooltip_size: 'wide', }, }, }; From f04ad03cf50abffde59e6c086846bedac641a4d5 Mon Sep 17 00:00:00 2001 From: kreafox Date: Tue, 19 Sep 2023 12:33:52 +0300 Subject: [PATCH 3/4] Add more tests --- src/editor/LabelWrapper.test.jsx | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/editor/LabelWrapper.test.jsx b/src/editor/LabelWrapper.test.jsx index 0f66f8a..29e565b 100644 --- a/src/editor/LabelWrapper.test.jsx +++ b/src/editor/LabelWrapper.test.jsx @@ -74,6 +74,28 @@ describe('LabelWrapper', () => { , ); }); + it('renders without crashing with no tooltip_size', () => { + const props = { + attributes: {}, + element: { + data: { + uid: '123', + label_type: 'type', + label_pointing: 'pointing', + tooltip_content: [{ text: 'Tooltip Content' }], + tooltip_pointing: 'top center', + always_show: true, + tooltip_type: 'info', + tooltip_size: undefined, + }, + }, + }; + render( + +
Test
+
, + ); + }); it('renders without crashing with no tooltip _content', () => { const props = { From 4fe81f70570664f39f19a7ba3c3f1f498add03a3 Mon Sep 17 00:00:00 2001 From: EEA Jenkins <@users.noreply.github.com> Date: Tue, 19 Sep 2023 09:47:37 +0000 Subject: [PATCH 4/4] Automated release 0.5.5 --- CHANGELOG.md | 8 ++++++-- package.json | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df7a70e..734f628 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,15 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). -### [0.5.4](https://github.com/eea/volto-slate-label/compare/0.5.3...0.5.4) - 18 September 2023 +### [0.5.5](https://github.com/eea/volto-slate-label/compare/0.5.4...0.5.5) - 19 September 2023 #### :hammer_and_wrench: Others -- Refs #257521 - Restore style for simple labels with tooltip. [GhitaB - [`d4a39b5`](https://github.com/eea/volto-slate-label/commit/d4a39b5e22c13e221165a7e14bf98b40f6a26e50)] +- Add more tests [kreafox - [`f04ad03`](https://github.com/eea/volto-slate-label/commit/f04ad03cf50abffde59e6c086846bedac641a4d5)] +- Update tests [kreafox - [`68ebc30`](https://github.com/eea/volto-slate-label/commit/68ebc3005202f96e58a77a4beb930621d50f2887)] +- Add tooltip size option [kreafox - [`12a01ab`](https://github.com/eea/volto-slate-label/commit/12a01abae8a2457578e7c44b7e55a4d8aaebe032)] +### [0.5.4](https://github.com/eea/volto-slate-label/compare/0.5.3...0.5.4) - 18 September 2023 + ### [0.5.3](https://github.com/eea/volto-slate-label/compare/0.5.2...0.5.3) - 15 September 2023 #### :house: Internal changes diff --git a/package.json b/package.json index 293c94b..bb6399a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-slate-label", - "version": "0.5.4", + "version": "0.5.5", "description": "@eeacms/volto-slate-label: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team",