From 4ebecb581105515da1c12736ad98929f3260fd5e Mon Sep 17 00:00:00 2001 From: fnecas Date: Fri, 15 Dec 2023 12:11:50 +0100 Subject: [PATCH 1/2] feat: implement themable header --- configs/localConfig.json | 4 +++- js/plugins/Header.jsx | 12 ++++++++++-- web/src/main/resources/mapstore.properties | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/configs/localConfig.json b/configs/localConfig.json index 48445ce26..7fd5f50c3 100644 --- a/configs/localConfig.json +++ b/configs/localConfig.json @@ -22,7 +22,9 @@ "height": 90, "url": "/header/", "script": "https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js", - "legacy": false + "legacy": false, + "logoUrl": "https://www.georchestra.org/public/georchestra-logo.svg", + "stylesheet": "" }, "defaultMapOptions": { "cesium": { diff --git a/js/plugins/Header.jsx b/js/plugins/Header.jsx index d8e2e16bb..40af3b870 100644 --- a/js/plugins/Header.jsx +++ b/js/plugins/Header.jsx @@ -8,7 +8,11 @@ import {useEffect} from "react"; import { createPlugin, connect } from "@mapstore/utils/PluginsUtils"; -export const Header = ({url = "/header/", page = "mapstore", height = 90, ignoreIFrame = false, script = "https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js", legacy = false}) => { +export const Header = ({url = "/header/", page = "mapstore", height = 90, ignoreIFrame = false, + script = "https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js", + legacy = false, + logo= "https://www.georchestra.org/public/georchestra-logo.svg", + stylesheet= ""}) => { useEffect(() => { const header = document.getElementById("georchestra-header"); const headerScript = document.getElementById("georchestra-header-script"); @@ -24,6 +28,8 @@ export const Header = ({url = "/header/", page = "mapstore", height = 90, ignore header.setAttribute("legacy-url", url); header.setAttribute("legacy-header", legacy); header.setAttribute("style", `height:${height}px`); + header.setAttribute("logo-url", logo); + header.setAttribute("stylesheet", stylesheet); headerScript.src = script; if (container) { @@ -41,6 +47,8 @@ export default createPlugin('Header', { url: state.localConfig && state.localConfig.header && state.localConfig.header.url, height: state.localConfig && state.localConfig.header && state.localConfig.header.height, script: state.localConfig && state.localConfig.header && state.localConfig.header.script, - legacy: state.localConfig && state.localConfig.header && state.localConfig.header.legacy + legacy: state.localConfig && state.localConfig.header && state.localConfig.header.legacy, + logo: state.localConfig && state.localConfig.header && state.localConfig.header.logo, + stylesheet: state.localConfig && state.localConfig.header && state.localConfig.header.stylesheet }))(Header) }); diff --git a/web/src/main/resources/mapstore.properties b/web/src/main/resources/mapstore.properties index 9d834d6b3..402948b81 100644 --- a/web/src/main/resources/mapstore.properties +++ b/web/src/main/resources/mapstore.properties @@ -18,4 +18,4 @@ datadir.location=${georchestra.extensions:},${georchestra.datadir}/mapstore overrides.config=../default.properties -overrides.mappings=header.url=headerUrl,header.height=headerHeight,header.script=headerScript,header.legacy=useLegacyHeader +overrides.mappings=header.url=headerUrl,header.height=headerHeight,header.script=headerScript,header.legacy=useLegacyHeader,header.logoUrl=logoUrl,header.stylesheet=georchestraStylesheet From 50c78960e0767825ce6ce89814b2f9d2a60daf7a Mon Sep 17 00:00:00 2001 From: fnecas Date: Mon, 18 Dec 2023 22:39:15 +0100 Subject: [PATCH 2/2] fix: lint --- js/plugins/Header.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/plugins/Header.jsx b/js/plugins/Header.jsx index 40af3b870..fbbed2560 100644 --- a/js/plugins/Header.jsx +++ b/js/plugins/Header.jsx @@ -9,10 +9,10 @@ import {useEffect} from "react"; import { createPlugin, connect } from "@mapstore/utils/PluginsUtils"; export const Header = ({url = "/header/", page = "mapstore", height = 90, ignoreIFrame = false, - script = "https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js", - legacy = false, - logo= "https://www.georchestra.org/public/georchestra-logo.svg", - stylesheet= ""}) => { + script = "https://cdn.jsdelivr.net/gh/georchestra/header@dist/header.js", + legacy = false, + logo = "https://www.georchestra.org/public/georchestra-logo.svg", + stylesheet = ""}) => { useEffect(() => { const header = document.getElementById("georchestra-header"); const headerScript = document.getElementById("georchestra-header-script");