Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Themable Webcomponent header #684

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading