From a10c75a6654d5ccf076a0f61ee43512c65a7e6d4 Mon Sep 17 00:00:00 2001 From: omsaggau Date: Mon, 12 Feb 2024 14:04:52 +0100 Subject: [PATCH] Mim 1753 highmap wrapper (#2514) * Dont use relative imports to XP files * fix factbox * Make wrapper around highmap more like highchart * Rename part class to wrapper --- .../resources/assets/styles/_highchart.scss | 2 +- .../resources/site/macros/highmap/highmap.ts | 7 ++++ .../site/parts/highchart/highchart.html | 2 +- .../site/parts/highchart/highchart.ts | 2 +- .../parts/highchartExpert/highchartExpert.ts | 4 +-- .../resources/site/parts/highmap/Highmap.jsx | 32 ++++++++----------- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/main/resources/assets/styles/_highchart.scss b/src/main/resources/assets/styles/_highchart.scss index 5602f78c5..9cdef2f1d 100644 --- a/src/main/resources/assets/styles/_highchart.scss +++ b/src/main/resources/assets/styles/_highchart.scss @@ -1,4 +1,4 @@ -.part-highchart { +.highchart-wrapper { .highcharts-credits { display: none; } diff --git a/src/main/resources/site/macros/highmap/highmap.ts b/src/main/resources/site/macros/highmap/highmap.ts index 7b3341054..98e6210d5 100644 --- a/src/main/resources/site/macros/highmap/highmap.ts +++ b/src/main/resources/site/macros/highmap/highmap.ts @@ -1,12 +1,19 @@ import { renderError } from '/lib/ssb/error/error' + import { preview } from '/site/parts/highmap/highmap' +import { preview as dividerControllerPreview } from '/site/parts/divider/divider' import { Highmap } from '.' export function macro(context: XP.MacroContext) { try { + const divider: XP.Response = dividerControllerPreview(context.request, { + dark: false, + }) + const highmap = preview(context.request, context.params.highmap) if (highmap.status && highmap.status !== 200) throw new Error(`Highmap with id ${context.params.highmap} missing`) + highmap.body = (divider.body as string) + highmap.body + divider.body return highmap } catch (e) { diff --git a/src/main/resources/site/parts/highchart/highchart.html b/src/main/resources/site/parts/highchart/highchart.html index 9074e5649..65475257e 100644 --- a/src/main/resources/site/parts/highchart/highchart.html +++ b/src/main/resources/site/parts/highchart/highchart.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/main/resources/site/parts/highchart/highchart.ts b/src/main/resources/site/parts/highchart/highchart.ts index 29ac55d61..c9d19dfad 100644 --- a/src/main/resources/site/parts/highchart/highchart.ts +++ b/src/main/resources/site/parts/highchart/highchart.ts @@ -107,7 +107,7 @@ function renderPart(req: XP.Request, highchartIds: Array): XP.Response { if (req.mode === 'edit') _req.mode = 'preview' return r4XpRender('site/parts/highchart/Highchart', HighchartProps, _req, { - body: '
', + body: '
', }) } else { return { diff --git a/src/main/resources/site/parts/highchartExpert/highchartExpert.ts b/src/main/resources/site/parts/highchartExpert/highchartExpert.ts index dec0730ed..dd150e5cf 100644 --- a/src/main/resources/site/parts/highchartExpert/highchartExpert.ts +++ b/src/main/resources/site/parts/highchartExpert/highchartExpert.ts @@ -45,7 +45,7 @@ function renderPart(req: XP.Request): XP.Response { } return r4XpRender('site/parts/highchartExpert/HighchartExpert', { config: component.config.config }, _req, { - body: '
', + body: '
', }) } @@ -60,7 +60,7 @@ function errorConfig(title = 'Feil i JSON konfigurasjon', message = '') { Det må begynne med { og slutte med }` return { - body: `
+ body: `

Highchart Ekspert - ${title}

${_message} diff --git a/src/main/resources/site/parts/highmap/Highmap.jsx b/src/main/resources/site/parts/highmap/Highmap.jsx index 9e5046c9c..4da2127a1 100644 --- a/src/main/resources/site/parts/highmap/Highmap.jsx +++ b/src/main/resources/site/parts/highmap/Highmap.jsx @@ -16,21 +16,6 @@ if (typeof Highcharts === 'object') { require('highcharts/modules/map')(Highcharts) } -function renderFootnotes(footnotes) { - if (footnotes.length) { - return ( - - {footnotes.map((footnote) => ( - - {footnote && {footnote}} - - ))} - - ) - } - return -} - function Highmap(props) { useEffect(() => { if (props.language !== 'en') { @@ -168,13 +153,22 @@ function Highmap(props) { } return ( -

+
- - + +
+ {mapOptions.title?.text &&
{mapOptions.title.text}
} + {mapOptions.subtitle?.text &&

{mapOptions.subtitle.text}

} + +
+ {props.footnoteText && + props.footnoteText.map((footnote) => ( + + {footnote && {footnote}} + + ))}
- {renderFootnotes(props.footnoteText)}
) }