Skip to content

Commit

Permalink
Merge pull request #19 from aaronczichon/feature/visited-countries
Browse files Browse the repository at this point in the history
feat: added country map to the website
  • Loading branch information
aaronczichon authored Apr 26, 2024
2 parents 61be75d + 44b81d0 commit f9d35c0
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 10 deletions.
2 changes: 1 addition & 1 deletion design/src/styles/layout/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ a {
}

.container {
width: calc(100%-16px);
width: calc(100% - 16px);
/* height: 100vh; */
margin-left: auto;
margin-right: auto;
Expand Down
20 changes: 18 additions & 2 deletions personal/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion personal/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "aaronczichon.de",
"type": "module",
"version": "1.0.0",
"version": "1.0.1",
"description": "Personal website of Aaron Czichon",
"scripts": {
"dev": "astro dev",
Expand All @@ -28,6 +28,7 @@
"typescript": "^5.3.3"
},
"devDependencies": {
"@types/mapbox-gl": "^3.1.0",
"prettier": "^3.2.5",
"prettier-plugin-astro": "^0.13.0"
}
Expand Down
1 change: 0 additions & 1 deletion personal/src/components/BlogEntryList.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
import { getCollection } from "astro:content";
import { Image } from "astro:assets";
const allPosts = await getCollection("blog");
const dateOptions: object = {
Expand Down
1 change: 0 additions & 1 deletion personal/src/components/CVList.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
import { getCollection } from "astro:content";
import SkillList from "./SkillList.astro";
import SkillBand from "./SkillBand.astro";
const allCvEntries = await getCollection("cv");
Expand Down
5 changes: 5 additions & 0 deletions personal/src/components/Nav.astro
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ import { Image } from "astro:assets";
class={currentPath.indexOf("cv") > -1 ? "active" : ""}>CV</a
> -->
<a href="/cv/" class={currentPath.indexOf("cv") > -1 ? "active" : ""}>CV</a>
<a
href="/visited-countries/"
class={currentPath.indexOf("visited-countries") > -1 ? "active" : ""}
>Visited Countries</a
>
<!-- <a
href="/pengiun"
class={currentPath.indexOf("pengiun") > -1 ? "active" : ""}
Expand Down
26 changes: 26 additions & 0 deletions personal/src/components/dynamic/CountryMap.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useState, useEffect } from 'preact/hooks';

import BasicMap from './BasicMap';
import { addMapLayer } from './map.func';

export default function CountryDynamicMap({zoom, center}) {
const [map, setMap] = useState(null);
useEffect(() => {
// Add route to map
if (map) {
map.on('load', () => {
addMapLayer(map);
});
}
}, [map]);

useEffect(() => {
if (map) {
map.setCenter(center);
}
})

return (
<BasicMap zoom={zoom} setMap={setMap} />
);
}
2 changes: 1 addition & 1 deletion personal/src/components/dynamic/PathMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function parseGPX(gpxData) {

export default function PathDynamicMap({gpxUrl, zoom, tooltip}) {
const [map, setMap] = useState(null);
const [popup, setPopup] = useState(null);
const [popup, _setPopup] = useState(null);
const [routeCoordinates, setRouteCoordinates] = useState(null);

useEffect(() => {
Expand Down
45 changes: 45 additions & 0 deletions personal/src/components/dynamic/map.func.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import * as mapboxgl from 'mapbox-gl';

export const addMapLayer = (map: mapboxgl.Map) => {
map.addSource('countries', {
type: 'vector',
url: 'mapbox://mapbox.country-boundaries-v1'
});

map.addLayer(
{
id: 'country-boundaries',
source: 'countries',
'source-layer': 'country_boundaries',
type: 'fill',
paint: {
'fill-color': '#19bf32',
'fill-opacity': 0.7,
},
},
'country-label'
);

// ISO List: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
map.setFilter('country-boundaries', [
"in",
"iso_3166_1_alpha_3",
'ITA',
'CAN',
'DEU',
'ESP',
'SVK',
'SVN',
'CZE',
'HRV',
'BEL',
'NOR',
'AUT',
'LTU',
'FIN',
'EST',
'USA',
'CHE',
'FRA'
]);
}
2 changes: 1 addition & 1 deletion personal/src/content/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const blogCollection = defineCollection({

const cvCollection = defineCollection({
type: 'content', // v2.5.0 and later
schema: ({ image }) =>
schema: () =>
z.object({
title: z.string(),
position: z.string(),
Expand Down
2 changes: 0 additions & 2 deletions personal/src/pages/cv.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---
import Layout from "../layouts/Layout.astro";
import CVList from "../components/CVList.astro";
const { frontmatter } = Astro.props;
---

<Layout title="Aaron Czichon - CV">
Expand Down
17 changes: 17 additions & 0 deletions personal/src/pages/visited-countries.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
import Layout from "../layouts/Layout.astro";
import CountryMap from "../components/dynamic/CountryMap";
---

<Layout title="Aaron Czichon - Visited Countries">
<main class="container">
<h1>Visited Countries</h1>
<p>
I've already visited a bunch of countries in my life. I love to keep track
of such things.
</p>
</main>

<!-- Map Component here -->
<CountryMap client:visible zoom="3" center={[10.451526, 51.165691]} />
</Layout>

0 comments on commit f9d35c0

Please sign in to comment.