11import styles from 'app/App.module.css'
22import { DaySelector } from 'app/DaySelector'
33import { Editor } from 'app/Editor'
4- import { EyeIcon , EyeOffIcon , LockIcon , UnLockIcon } from 'app/FeatherIcons'
4+ import {
5+ CalendarIcon ,
6+ EyeIcon ,
7+ EyeOffIcon ,
8+ LockIcon ,
9+ UnLockIcon ,
10+ } from 'app/FeatherIcons'
511import { Footer } from 'app/Footer'
612import formStyles from 'app/Form.module.css'
7- import { Schedule } from 'app/Schedule'
13+ import { Schedule as ScheduleComponent } from 'app/Schedule'
814import { Theme , ThemeSwitcher } from 'app/ThemeSwitcher'
915import { TimeZoneSelector } from 'app/timezones'
16+ import { useIcalExport } from 'app/useIcalExport'
1017import { format } from 'date-fns'
1118import { useEffect , useState } from 'react'
1219
@@ -16,8 +23,16 @@ if (typeof window.matchMedia === 'function') {
1623 defaultTheme = match . matches ? Theme . dark : Theme . light
1724}
1825
26+ export type Schedule = {
27+ name : string
28+ day : string
29+ tz : string
30+ sessions : Record < number , string >
31+ hidePastSessions : boolean
32+ }
33+
1934export const App = ( ) => {
20- let cfg = {
35+ let cfg : Schedule = {
2136 name : 'ExampleConf' ,
2237 day : format ( new Date ( ) , 'yyyy-MM-dd' ) ,
2338 tz : 'Europe/Oslo' ,
@@ -70,6 +85,8 @@ export const App = () => {
7085 hidePastSessionsDefault ,
7186 )
7287
88+ const downloadIcal = useIcalExport ( cfg )
89+
7390 useEffect ( ( ) => {
7491 document . documentElement . setAttribute ( 'data-theme' , theme )
7592 } , [ theme ] )
@@ -153,6 +170,15 @@ export const App = () => {
153170 { updatedName } : { updatedDay }
154171 </ h1 >
155172 < div className = "actions" >
173+ < button
174+ className = { formStyles . Button }
175+ title = "Export as calendar (.ics)"
176+ onClick = { ( ) => {
177+ downloadIcal ( )
178+ } }
179+ >
180+ < CalendarIcon />
181+ </ button >
156182 < button
157183 className = { formStyles . Button }
158184 title = "Hide past sessions"
@@ -164,7 +190,7 @@ export const App = () => {
164190 < ThemeSwitcher currentTheme = { theme } onSwitch = { updateTheme } />
165191 </ div >
166192 </ div >
167- < Schedule
193+ < ScheduleComponent
168194 sessions = { cfg . sessions }
169195 eventTimezoneName = { cfg . tz }
170196 conferenceDate = { cfg . day }
0 commit comments