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

Update of the navbar as a component #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions components/addComponents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {NavBar} from "./navBar";

document.querySelector("body").append(new NavBar());
41 changes: 41 additions & 0 deletions components/navBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Class used to create a navbar to navigate between demo pages
* @extends HTMLElement
*/
export class NavBar extends HTMLElement {
constructor() {
super();

const pathname = window.location.pathname.split("/");
const page = pathname[pathname.length - 1];

this.innerHTML = ``;

const demoPages = {
"../index.html": "Home",
"wms-image-custom-proj.html": "Single Image WMS",
"reprojection-image.html": "Image reprojection",
"reprojection.html": "Raster reprojection",
"sphere-mollweide.html": "Sphere Mollweide",
"vector-projections.html": "Vector projections",
"bundeslander-3044.html": "Bundeslander EPSG:3044"
};

let i = 0;

for (const [key, value] of Object.entries(demoPages)) {

let tag = `<a `;
if (page === key) {
tag += `id="navLabelActive"`;
}

tag += ` class="navLabel" href="${key}">${value}</a>${i === Object.keys(demoPages).length - 1 ? `` : `<br>`}`;
this.innerHTML += tag;

i++;
}
}
}

customElements.define("nav-bar", NavBar);
1 change: 1 addition & 0 deletions demo-pages/bundeslander-3044.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ <h3>proj4rs</h3>

<!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/elm-pep.js"></script>
<script type="module" src="../components/addComponents.js"></script>
<script type="module" src="../bundeslander-3044.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions demo-pages/reprojection-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ <h3>proj4rs</h3>

<!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/elm-pep.js"></script>
<script type="module" src="../components/addComponents.js"></script>
<script type="module" src="../reprojection-image.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions demo-pages/reprojection.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ <h3>proj4rs</h3>

<!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/elm-pep.js"></script>
<script type="module" src="../components/addComponents.js"></script>
<script type="module" src="../reprojection.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions demo-pages/sphere-mollweide.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ <h3>proj4rs</h3>

<!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/elm-pep.js"></script>
<script type="module" src="../components/addComponents.js"></script>
<script type="module" src="../sphere-mollweide.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions demo-pages/vector-projections.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ <h3>proj4rs</h3>

<!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/elm-pep.js"></script>
<script type="module" src="../components/addComponents.js"></script>
<script type="module" src="../vector-projections.js"></script>
</body>
</html>
11 changes: 1 addition & 10 deletions demo-pages/wms-image-custom-proj.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,9 @@ <h3>proj4rs</h3>
</pre>
</div>

<nav>
<a class="navLabel" href="../index.html">Home</a><br>
<a id="navLabelActive" class="navLabel" href="wms-image-custom-proj.html">Single Image WMS</a><br>
<a class="navLabel" href="reprojection-image.html">Image reprojection</a><br>
<a class="navLabel" href="reprojection.html">Raster reprojection</a><br>
<a class="navLabel" href="sphere-mollweide.html">Sphere Mollweide</a><br>
<a class="navLabel" href="vector-projections.html">Vector projections</a><br>
<a class="navLabel" href="bundeslander-3044.html">Bundeslander EPSG:3044</a>
</nav>

<!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/elm-pep.js"></script>
<script type="module" src="../components/addComponents.js"></script>
<script type="module" src="../wms-image-custom-proj.js"></script>
</body>
</html>
8 changes: 4 additions & 4 deletions ressources/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ container > div {

/* Nav bar */

nav {
nav-bar {
background-color: white;
border-radius: 0 7px 7px 0;
position: fixed;
Expand All @@ -178,18 +178,18 @@ nav {
transition: ease 200ms;
}

nav > a:first-child {
nav-bar > a:first-child {
border-radius: 0 10px 0 0;
border-top: solid 2px #000000;
font-weight: bold;
}

nav > a:last-child {
nav-bar > a:last-child {
border-radius: 0 0 10px 0;
border-bottom: solid 2px #000000;
}

nav:hover {
nav-bar:hover {
width: 200px;
text-indent: 0;
.navLabel {
Expand Down
1 change: 1 addition & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default {
copy({
targets: [
{ src: 'fgb/axis_orientation_neu_3044.fgb', dest: './dist/fgb' },
{ src: 'components', dest: './dist' },
]
})
]
Expand Down