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",
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/LabelWrapper.test.jsx b/src/editor/LabelWrapper.test.jsx
index 5aa5847..29e565b 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,29 @@ describe('LabelWrapper', () => {
tooltip_pointing: 'top center',
always_show: true,
tooltip_type: 'info',
+ tooltip_size: 'wide',
+ },
+ },
+ };
+ render(
+
+ Test
+ ,
+ );
+ });
+ 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,
},
},
};
@@ -84,6 +109,7 @@ describe('LabelWrapper', () => {
tooltip_pointing: 'top center',
always_show: true,
tooltip_type: 'info',
+ tooltip_size: 'wide',
},
},
};
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.',