Skip to content

Commit

Permalink
Merge pull request #684 from georchestra/themable-header
Browse files Browse the repository at this point in the history
Themable Webcomponent header
  • Loading branch information
f-necas authored Dec 19, 2023
2 parents 8220503 + 50c7896 commit 7ea5ff0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion configs/localConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
12 changes: 10 additions & 2 deletions js/plugins/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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) {
Expand All @@ -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)
});
2 changes: 1 addition & 1 deletion web/src/main/resources/mapstore.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7ea5ff0

Please sign in to comment.