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

Blog Entry 2 #2

Merged
merged 10 commits into from
Mar 14, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Deploy
name: PR Builds

on:
pull_request:
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"prettier.documentSelectors": ["**/*.astro"],
"[astro]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
12 changes: 12 additions & 0 deletions web-canada/.prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import("prettier").Config} */
export default {
plugins: ['prettier-plugin-astro'],
overrides: [
{
files: '*.astro',
options: {
parser: 'astro',
},
},
],
};
11 changes: 7 additions & 4 deletions web-canada/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { defineConfig } from 'astro/config';

import mdx from "@astrojs/mdx";
import mdx from '@astrojs/mdx';

// https://astro.build/config
export default defineConfig({
integrations: [mdx()],
site: 'https://canada.aaronczichon.de'
});
integrations: [mdx()],
site: 'https://canada.aaronczichon.de',
image: {
domains: ['api.mapbox.com'],
},
});
47 changes: 46 additions & 1 deletion web-canada/package-lock.json

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

5 changes: 3 additions & 2 deletions web-canada/package.json
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
"build": "npm run copy:styles && astro check && astro build",
"preview": "astro preview",
"astro": "astro",
"prettier": "prettier --write .",
"prettier": "prettier --config ./.prettierrc.mjs --write \"**{.mdx,.css,.md,.html,.astro}\"",
"copy:canada-colors": "cp ../design/src/styles/variants/colors-canada.css ./src/styles/common/colors.css",
"copy:styles": "cp -R ../design/src/styles ./src/styles && npm run copy:canada-colors",
"copy:assets": "cp -R ../design/src/assets ./public/assets"
@@ -24,6 +24,7 @@
"typescript": "^5.3.3"
},
"devDependencies": {
"prettier": "^3.2.5"
"prettier": "^3.2.5",
"prettier-plugin-astro": "^0.13.0"
}
}
77 changes: 39 additions & 38 deletions web-canada/public/assets/scripts/map.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
const element = document.getElementById("map");
const element = document.getElementById('map');

mapboxgl.accessToken = "pk.eyJ1Ijoid2ViYXRsYXMiLCJhIjoiY2xrdHB6dHg0MGVqbTNnbzR4Z3pvbTBvNCJ9.jSswMTOvnmDuLu9v9mdp9w";
const map = new mapboxgl.Map({
container: element,
style: "mapbox://styles/mapbox/streets-v12",
center: [-63.582687, 44.651070],
zoom: 10,
});
mapboxgl.accessToken =
'pk.eyJ1Ijoid2ViYXRsYXMiLCJhIjoiY2xrdHB6dHg0MGVqbTNnbzR4Z3pvbTBvNCJ9.jSswMTOvnmDuLu9v9mdp9w';
const map = new mapboxgl.Map({
container: element,
style: 'mapbox://styles/mapbox/streets-v12',
center: [-63.582687, 44.65107],
zoom: 10,
});

map.on("load", async () => {
// Add zoom controls
map.addControl(new mapboxgl.NavigationControl());
map.on('load', async () => {
// Add zoom controls
map.addControl(new mapboxgl.NavigationControl());

map.addLayer({
'id': 'circleLayer',
'type': 'circle',
'source': {
'type': 'geojson',
'data': {
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [-63.582687, 44.651070]
}
}
},
'paint': {
'circle-radius': {
'base': 1.75,
'stops': [[48, 40], [88, 720]]
}, // in pixels
'circle-color': 'blue',
'circle-opacity': 0.5
}
});
document
.getElementsByClassName("mapboxgl-control-container")
.item(0)
.remove();
});
map.addLayer({
id: 'circleLayer',
type: 'circle',
source: {
type: 'geojson',
data: {
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [-63.582687, 44.65107],
},
},
},
paint: {
'circle-radius': {
base: 1.75,
stops: [
[48, 40],
[88, 720],
],
}, // in pixels
'circle-color': 'blue',
'circle-opacity': 0.5,
},
});
document.getElementsByClassName('mapboxgl-control-container').item(0).remove();
});
52,070 changes: 52,021 additions & 49 deletions web-canada/public/assets/scripts/mapbox-gl-3.2.0.js

Large diffs are not rendered by default.

100 changes: 50 additions & 50 deletions web-canada/src/components/Card.astro
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
---
interface Props {
title: string;
body: string;
href: string;
title: string;
body: string;
href: string;
}

const { href, title, body } = Astro.props;
---

<li class="link-card">
<a href={href}>
<h2>
{title}
<span>&rarr;</span>
</h2>
<p>
{body}
</p>
</a>
<a href={href}>
<h2>
{title}
<span>&rarr;</span>
</h2>
<p>
{body}
</p>
</a>
</li>
<style>
.link-card {
list-style: none;
display: flex;
padding: 1px;
background-color: #23262d;
background-image: none;
background-size: 400%;
border-radius: 7px;
background-position: 100%;
transition: background-position 0.6s cubic-bezier(0.22, 1, 0.36, 1);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.link-card > a {
width: 100%;
text-decoration: none;
line-height: 1.4;
padding: calc(1.5rem - 1px);
border-radius: 8px;
color: white;
background-color: #23262d;
opacity: 0.8;
}
h2 {
margin: 0;
font-size: 1.25rem;
transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
p {
margin-top: 0.5rem;
margin-bottom: 0;
}
.link-card:is(:hover, :focus-within) {
background-position: 0;
background-image: var(--accent-gradient);
}
.link-card:is(:hover, :focus-within) h2 {
color: rgb(var(--accent-light));
}
.link-card {
list-style: none;
display: flex;
padding: 1px;
background-color: #23262d;
background-image: none;
background-size: 400%;
border-radius: 7px;
background-position: 100%;
transition: background-position 0.6s cubic-bezier(0.22, 1, 0.36, 1);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.link-card > a {
width: 100%;
text-decoration: none;
line-height: 1.4;
padding: calc(1.5rem - 1px);
border-radius: 8px;
color: white;
background-color: #23262d;
opacity: 0.8;
}
h2 {
margin: 0;
font-size: 1.25rem;
transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
p {
margin-top: 0.5rem;
margin-bottom: 0;
}
.link-card:is(:hover, :focus-within) {
background-position: 0;
background-image: var(--accent-gradient);
}
.link-card:is(:hover, :focus-within) h2 {
color: rgb(var(--accent-light));
}
</style>
25 changes: 25 additions & 0 deletions web-canada/src/components/ContentImage.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
import { Picture } from "astro:assets";

const { src, externalSrc, alt, width, height } = Astro.props;

const widths = [240, 540, 720];
let sizes = `(max-width: 360px) 240px, (max-width: 720px) 540px, (max-width: 1600px) 720px`;
if (src) {
widths.push(src.width);
sizes += `, ${src.width}px`;
}
---

<Picture
src={src || externalSrc}
alt={alt}
widths={widths}
sizes={sizes}
width={width}
height={height}
formats={["avif", "webp"]}
fallbackFormat="jpg"
loading="lazy"
fetchpriority="auto"
/>
27 changes: 13 additions & 14 deletions web-canada/src/components/Hero.astro
Original file line number Diff line number Diff line change
@@ -2,20 +2,19 @@
import { Image } from "astro:assets";
const { url, alt, image } = Astro.props;
---

<div class="hero">
{
image ?
<Image
src={image}
alt={alt}
widths={[240, 540, 720, image.width]}
sizes={`(max-width: 360px) 240px, (max-width: 720px) 540px, (max-width: 1600px) 720px, ${image.width}px`}
style="height: 100%; width: 100%; object-fit: cover;"
/>
:
<img
src={url} alt={alt}
decoding="async"
loading="lazy"/>
image ? (
<Image
src={image}
alt={alt}
widths={[240, 540, 720, image.width]}
sizes={`(max-width: 360px) 240px, (max-width: 720px) 540px, (max-width: 1600px) 720px, ${image.width}px`}
style="height: 100%; width: 100%; object-fit: cover;"
/>
) : (
<img src={url} alt={alt} decoding="async" loading="lazy" />
)
}
</div>
</div>
Loading