File tree Expand file tree Collapse file tree 2 files changed +73
-5
lines changed Expand file tree Collapse file tree 2 files changed +73
-5
lines changed Original file line number Diff line number Diff line change 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+ }
16+
17+ const {
18+ calendarId = " c_b87075b29cf4a9dd4da3fe724fcba92a4b406aa3f91cb7e7ce50fede43215b17@group.calendar.google.com" ,
19+ height = " 600" ,
20+ width = " 800" ,
21+ title = " My Calendar" ,
22+ showTitle = true ,
23+ showPrint = true ,
24+ showTabs = true ,
25+ showCalendars = true ,
26+ showTz = false ,
27+ mode = " MONTH" ,
28+ backgroundColor = " %23ffffff"
29+ } = Astro .props ;
30+
31+ // Construct the embed URL
32+ const embedUrl = ` https://calendar.google.com/calendar/embed?src=${encodeURIComponent (calendarId )}&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 } ` ;
33+
34+ // Mobile-specific embed URL for agenda view
35+ const mobileEmbedUrl = ` https://calendar.google.com/calendar/embed?src=${encodeURIComponent (calendarId )}&ctz=Europe%2FPrague&mode=AGENDA&height=400&wkst=2&bgcolor=${backgroundColor }&showTitle=0&showPrint=0&showTabs=0&showCalendars=0&showTz=0 ` ;
36+ ---
37+
38+ <div class =" flex justify-center items-center my-4 max-w-full overflow-hidden" >
39+ <!-- Desktop/Tablet Calendar -->
40+ <iframe
41+ src ={ embedUrl }
42+ class =" hidden md:block w-full max-w-4xl rounded-lg shadow-lg border-0"
43+ style ={ ` border: 0; width: ${width }px; height: ${height }px; ` }
44+ frameborder =" 0"
45+ scrolling =" no"
46+ title ={ title }
47+ loading =" lazy"
48+ ></iframe >
49+
50+ <!-- Mobile Calendar (Agenda View) -->
51+ <iframe
52+ src ={ mobileEmbedUrl }
53+ class =" block md:hidden w-full rounded-lg shadow-lg border-0"
54+ style =" height: 400px;"
55+ frameborder =" 0"
56+ scrolling =" no"
57+ title ={ ` ${title } - Mobile View ` }
58+ loading =" lazy"
59+ ></iframe >
60+ </div >
Original file line number Diff line number Diff line change 11
22---
3- import Layout from "@layouts/Layout .astro";
3+ import Layout from "@layouts/SectionLayout .astro";
44import Button from "@ui/Button.astro";
55import Headline from "@ui/Headline.astro"
66import Icon from "@ui/Icon.astro"
7+ import GoogleCalendar from '@components/GoogleCalendar.astro';
78---
89
910<Layout
@@ -17,7 +18,17 @@ import Icon from "@ui/Icon.astro"
1718
1819
1920<Headline as =" h1" id =" components" title =" Example components" />
20- <section class =" prose-xl my-10" >
21+
22+ <GoogleCalendar
23+ height =" 800"
24+ width =" 1000"
25+ mode =" WEEK"
26+ showTitle ={ false }
27+ showPrint ={ false }
28+ backgroundColor =" %23f0f0f0"
29+ />
30+
31+ Key Features
2132 <Headline id =" button" title =" Button" />
2233 <div class =" grid gap-2 w-[200px]" >
2334 <Button >Primary Button</Button >
@@ -28,9 +39,7 @@ import Icon from "@ui/Icon.astro"
2839 <Button url =" /about" >Internal Link</Button >
2940 <Button url =" https://example.com" >External Link</Button >
3041 </div >
31- </section >
3242
33- <section class =" prose-xl my-10" >
3443 <Headline id =" button" title =" Icons" />
3544 <div class =" grid gap-2 w-[200px]" >
3645 <Icon name =" check" />
@@ -49,5 +58,4 @@ import Icon from "@ui/Icon.astro"
4958 <Button icon =" clock" iconRight ={ false } iconSize =" fa-2xl" >Prev</Button >
5059
5160 </div >
52- </section >
5361</Layout >
You can’t perform that action at this time.
0 commit comments