Skip to content

Commit

Permalink
feat: implement themable header
Browse files Browse the repository at this point in the history
  • Loading branch information
f-necas committed Dec 15, 2023
1 parent 8220503 commit 4ebecb5
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",

Check failure on line 12 in js/plugins/Header.jsx

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 27

Check failure on line 12 in js/plugins/Header.jsx

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 27
legacy = false,

Check failure on line 13 in js/plugins/Header.jsx

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 27

Check failure on line 13 in js/plugins/Header.jsx

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 27
logo= "https://www.georchestra.org/public/georchestra-logo.svg",

Check failure on line 14 in js/plugins/Header.jsx

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 27

Check failure on line 14 in js/plugins/Header.jsx

View workflow job for this annotation

GitHub Actions / build

Operator '=' must be spaced

Check failure on line 14 in js/plugins/Header.jsx

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 27

Check failure on line 14 in js/plugins/Header.jsx

View workflow job for this annotation

GitHub Actions / build

Operator '=' must be spaced
stylesheet= ""}) => {

Check failure on line 15 in js/plugins/Header.jsx

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 27

Check failure on line 15 in js/plugins/Header.jsx

View workflow job for this annotation

GitHub Actions / build

Operator '=' must be spaced

Check failure on line 15 in js/plugins/Header.jsx

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 27

Check failure on line 15 in js/plugins/Header.jsx

View workflow job for this annotation

GitHub Actions / build

Operator '=' must be spaced
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 4ebecb5

Please sign in to comment.