Skip to content

Commit 0a72158

Browse files
committed
images keep aspect ratio now and swapped map from google to osm
1 parent 99254b8 commit 0a72158

File tree

6 files changed

+107
-12
lines changed

6 files changed

+107
-12
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"canvas-confetti": "^1.9.3",
2626
"class-variance-authority": "^0.7.1",
2727
"clsx": "^2.1.1",
28+
"leaflet": "^1.9.4",
2829
"lucide-react": "^0.487.0",
2930
"react": "^19.1.0",
3031
"react-dom": "^19.1.0",
@@ -33,6 +34,7 @@
3334
"tw-animate-css": "^1.2.5"
3435
},
3536
"devDependencies": {
36-
"@tailwindcss/typography": "^0.5.16"
37+
"@tailwindcss/typography": "^0.5.16",
38+
"@types/leaflet": "^1.9.17"
3739
}
3840
}

pnpm-lock.yaml

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Map.tsx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { useEffect, useRef } from 'react';
2+
import L from 'leaflet';
3+
import 'leaflet/dist/leaflet.css';
4+
5+
interface MapProps {
6+
location: {
7+
latitude: number;
8+
longitude: number;
9+
};
10+
zoom?: number;
11+
markerMarkup?: string;
12+
}
13+
14+
export default function Map({ location, zoom = 17, markerMarkup = '' }: MapProps) {
15+
const mapRef = useRef<HTMLDivElement>(null);
16+
const mapInstance = useRef<L.Map | null>(null);
17+
18+
useEffect(() => {
19+
if (typeof window === 'undefined') return;
20+
21+
if (mapRef.current && !mapInstance.current) {
22+
// Initialize the map
23+
mapInstance.current = L.map(mapRef.current).setView(
24+
[location.latitude, location.longitude],
25+
zoom
26+
);
27+
28+
// Add OpenStreetMap tiles
29+
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
30+
attribution: '© OpenStreetMap contributors'
31+
}).addTo(mapInstance.current);
32+
33+
// Add marker
34+
const marker = L.marker([location.latitude, location.longitude]).addTo(mapInstance.current);
35+
36+
if (markerMarkup) {
37+
marker.bindPopup(markerMarkup);
38+
}
39+
}
40+
41+
return () => {
42+
if (mapInstance.current) {
43+
mapInstance.current.remove();
44+
mapInstance.current = null;
45+
}
46+
};
47+
}, [location, zoom, markerMarkup]);
48+
49+
return (
50+
<div
51+
ref={mapRef}
52+
className="w-full h-[15rem] shadow-md rounded-lg"
53+
/>
54+
);
55+
}

src/components/SoftwareCard.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ export default function SoftwareCard({
4545
<DialogTrigger asChild>
4646
<div className="flex flex-row items-center space-x-4 rounded-lg border p-4 cursor-pointer hover:bg-accent/50 transition-colors">
4747
<Avatar className="h-32 w-32">
48-
<AvatarImage src={`${getInternalLink('/software_images')}/${image}`} alt={name} />
48+
<AvatarImage
49+
src={`${getInternalLink('/software_images')}/${image}`}
50+
alt={name}
51+
className="object-contain object-center"
52+
/>
4953
<AvatarFallback>
5054
{name
5155
.split(" ")
@@ -65,7 +69,11 @@ export default function SoftwareCard({
6569
<DialogContent className="sm:max-w-[1024px] max-h-[85vh] overflow-y-auto p-6">
6670
<DialogHeader className="flex flex-col sm:flex-row sm:items-start gap-4 mb-6">
6771
<Avatar className="w-28 h-28 border">
68-
<AvatarImage src={`${getInternalLink('/software_images')}/${image}`} alt={name} />
72+
<AvatarImage
73+
src={`${getInternalLink('/software_images')}/${image}`}
74+
alt={name}
75+
className="object-contain object-center"
76+
/>
6977
<AvatarFallback>
7078
{name
7179
.split(" ")

src/components/TeamMemberCard.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ export default function TeamMemberCard({
5151
<DialogTrigger asChild>
5252
<div className="flex flex-col items-center space-y-4 rounded-lg border p-6 text-center cursor-pointer hover:bg-accent/50 transition-colors">
5353
<Avatar className="h-24 w-24">
54-
<AvatarImage src={`${getInternalLink('/team_images')}/${image}`} alt={name} />
54+
<AvatarImage
55+
src={`${getInternalLink('/team_images')}/${image}`}
56+
alt={name}
57+
className="object-contain object-center"
58+
/>
5559
<AvatarFallback>
5660
{name
5761
.split(" ")
@@ -68,7 +72,11 @@ export default function TeamMemberCard({
6872
<DialogContent className="sm:max-w-[1024px] max-h-[85vh] overflow-y-auto p-6">
6973
<DialogHeader className="flex flex-col sm:flex-row sm:items-start gap-4 mb-6">
7074
<Avatar className="w-28 h-28 border">
71-
<AvatarImage src={`${getInternalLink('/team_images')}/${image}`} alt={name} />
75+
<AvatarImage
76+
src={`${getInternalLink('/team_images')}/${image}`}
77+
alt={name}
78+
className="object-contain object-center"
79+
/>
7280
<AvatarFallback>
7381
{name
7482
.split(" ")

src/pages/contact.astro

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
---
22
import Layout from '../layouts/Layout.astro';
3+
import Map from '../components/Map';
4+
5+
const location = { latitude: 49.41297, longitude: 8.67068 };
6+
const markerMarkup = "We are on the 10th floor<br>of the Marsilius-Arkaden<br>West tower (INF130.3).<br>";
37
---
48

59
<Layout title="Contact">
610
<div class="mx-auto max-w-[980px] py-6 md:py-12">
711
<h2 class="mb-6 text-2xl font-bold">Find Us</h2>
8-
<div class="aspect-video w-full overflow-hidden rounded-lg">
9-
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d162.23684421613967!2d8.670751139034243!3d49.41288618943688!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x4797c12ec3026749%3A0x4536c5528bf53a97!2sBetriebs%C3%A4rztlicher%20Dienst%20des%20Universit%C3%A4tsklinikums%20Heidelberg!5e0!3m2!1sde!2sde!4v1744628032901!5m2!1sde!2sde" width="100%"
10-
height="100%"
11-
style="border:0;"
12-
allowfullscreen=""
13-
loading="lazy"
14-
referrerpolicy="no-referrer-when-downgrade"></iframe>
12+
<div class="w-full overflow-hidden rounded-lg">
13+
<Map client:only="react" {location} zoom={17} {markerMarkup} />
1514
</div>
1615
</div>
1716

0 commit comments

Comments
 (0)