Skip to content

Commit 44ac368

Browse files
authored
Google calendar component (#1367)
1 parent e1da437 commit 44ac368

File tree

4 files changed

+76
-6
lines changed

4 files changed

+76
-6
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
// GoogleCalendar.astro
3+
export interface Props {
4+
calendarId?: string;
5+
height?: string;
6+
width?: string;
7+
title?: string;
8+
showTitle?: boolean;
9+
showPrint?: boolean;
10+
showTabs?: boolean;
11+
showCalendars?: boolean;
12+
showTz?: boolean;
13+
mode?: 'WEEK' | 'MONTH' | 'AGENDA';
14+
backgroundColor?: string;
15+
dates?: string;
16+
}
17+
18+
const {
19+
calendarId = "c_b87075b29cf4a9dd4da3fe724fcba92a4b406aa3f91cb7e7ce50fede43215b17@group.calendar.google.com",
20+
height = "600",
21+
width = "800",
22+
title = "My Calendar",
23+
showTitle = true,
24+
showPrint = true,
25+
showTabs = true,
26+
showCalendars = true,
27+
showTz = false,
28+
mode = "MONTH",
29+
backgroundColor = "%23000000",
30+
dates = "20250714/20250720"
31+
} = Astro.props;
32+
33+
// Construct the embed URL
34+
const embedUrl = `https://calendar.google.com/calendar/embed?src=${encodeURIComponent(calendarId)}&dates=${dates}&ctz=Europe%2FPrague&mode=${mode}&height=${height}&wkst=2&bgcolor=${backgroundColor}&showTitle=${showTitle ? 1 : 0}&showPrint=${showPrint ? 1 : 0}&showTabs=${showTabs ? 1 : 0}&showCalendars=${showCalendars ? 1 : 0}&showTz=${showTz ? 1 : 0}`;
35+
36+
// Mobile-specific embed URL for agenda view
37+
const mobileEmbedUrl = `https://calendar.google.com/calendar/embed?src=${encodeURIComponent(calendarId)}&dates=${dates}&ctz=Europe%2FPrague&mode=AGENDA&height=400&wkst=2&bgcolor=${backgroundColor}&showTitle=0&showPrint=0&showTabs=0&showCalendars=0&showTz=0`;
38+
---
39+
40+
<div class="flex justify-center items-center my-4 max-w-full overflow-hidden">
41+
<!-- Desktop/Tablet Calendar -->
42+
<iframe
43+
src={embedUrl}
44+
class="hidden md:block w-full max-w-4xl rounded-lg shadow-lg border-0"
45+
style={`border: 0; width: ${width}px; height: ${height}px;`}
46+
frameborder="0"
47+
scrolling="no"
48+
title={title}
49+
loading="lazy"
50+
></iframe>
51+
52+
<!-- Mobile Calendar (Agenda View) -->
53+
<iframe
54+
src={mobileEmbedUrl}
55+
class="block md:hidden w-full rounded-lg shadow-lg border-0"
56+
style="height: 400px;"
57+
frameborder="0"
58+
scrolling="no"
59+
title={`${title} - Mobile View`}
60+
loading="lazy"
61+
></iframe>
62+
</div>

src/content/pages/open-spaces.md renamed to src/content/pages/open-spaces.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ serves to attract potential participants interested in joining.
2424
Check the
2525
[Open Spaces schedule ↗️!](https://calendar.google.com/calendar/u/0?cid=Y19iODcwNzViMjljZjRhOWRkNGRhM2ZlNzI0ZmNiYTkyYTRiNDA2YWEzZjkxY2I3ZTdjZTUwZmVkZTQzMjE1YjE3QGdyb3VwLmNhbGVuZGFyLmdvb2dsZS5jb20)
2626

27+
<GoogleCalendar
28+
height="800"
29+
width="1000"
30+
mode="WEEK"
31+
showTitle={false}
32+
showPrint={false}
33+
/>
34+
2735
## How to Organise an Open Space
2836

2937
To organise your own Open Space session, simply book a free time slot and room

src/pages/[...slug].astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Center from "@components/markdown/Center.astro";
1616
import EPSLogo from "@components/markdown/EPSLogo.astro";
1717
import ProfileCard from "@components/profile/ProfileCard.astro";
1818
import SpeakerCard from "@components/profile/SpeakerCard.astro";
19+
import GoogleCalendar from '@components/GoogleCalendar.astro';
1920
2021
import Prose from "@ui/Prose.astro";
2122
@@ -67,7 +68,8 @@ const description = post.data.subtitle;
6768
hr: Separator,
6869
Accordion,
6970
ProfileCard,
70-
SpeakerCard
71+
SpeakerCard,
72+
GoogleCalendar
7173
}}
7274
/>
7375
</Prose>

src/pages/_test_components.astro

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
---
3-
import Layout from "@layouts/Layout.astro";
3+
import Layout from "@layouts/SectionLayout.astro";
44
import Button from "@ui/Button.astro";
55
import Headline from "@ui/Headline.astro"
66
import Icon from "@ui/Icon.astro"
@@ -17,7 +17,8 @@ import Icon from "@ui/Icon.astro"
1717

1818

1919
<Headline as="h1" id="components" title="Example components" />
20-
<section class="prose-xl my-10">
20+
21+
Key Features
2122
<Headline id="button" title="Button" />
2223
<div class="grid gap-2 w-[200px]">
2324
<Button>Primary Button</Button>
@@ -28,9 +29,7 @@ import Icon from "@ui/Icon.astro"
2829
<Button url="/about">Internal Link</Button>
2930
<Button url="https://example.com">External Link</Button>
3031
</div>
31-
</section>
3232

33-
<section class="prose-xl my-10">
3433
<Headline id="button" title="Icons" />
3534
<div class="grid gap-2 w-[200px]">
3635
<Icon name="check" />
@@ -49,5 +48,4 @@ import Icon from "@ui/Icon.astro"
4948
<Button icon="clock" iconRight={false} iconSize="fa-2xl">Prev</Button>
5049

5150
</div>
52-
</section>
5351
</Layout>

0 commit comments

Comments
 (0)