File tree Expand file tree Collapse file tree 7 files changed +410
-2
lines changed
Expand file tree Collapse file tree 7 files changed +410
-2
lines changed Original file line number Diff line number Diff line change 1+ import Button from './Button'
2+ import Modal from './Modal'
3+
4+ type CalendarSubscribeModalProps = {
5+ url : string
6+ onClose : ( ) => void
7+ background ?: string
8+ }
9+
10+ const CalendarSubscribeModal = ( props : CalendarSubscribeModalProps ) => {
11+ return (
12+ < Modal onClose = { props . onClose } background = { props . background } >
13+ < h2 className = "text-2xl mb-4 pr-8" > Lägg till i kalender</ h2 >
14+
15+ < div className = "flex flex-col gap-2" >
16+ < CalendarLink
17+ href = { `https://calendar.google.com/calendar/r?cid=${ encodeURIComponent (
18+ props . url
19+ ) } `}
20+ >
21+ Google Kalender
22+ </ CalendarLink >
23+ < CalendarLink href = { props . url } > Apple Kalender</ CalendarLink >
24+ < CalendarLink
25+ href = { `https://outlook.office.com/owa/?path=/calendar/action/compose&rru=addsubscription&url=${ encodeURIComponent (
26+ props . url
27+ ) } `}
28+ >
29+ Outlook
30+ </ CalendarLink >
31+ </ div >
32+
33+ < div className = "mt-8" >
34+ < p > Eller kopiera länken nedan:</ p >
35+ < input
36+ type = "text"
37+ id = "calendarLink"
38+ disabled
39+ aria-disabled = "true"
40+ value = { props . url }
41+ className = "w-full px-1 rounded-sm bg-white text-black mt-2 mb-4"
42+ />
43+
44+ < div className = "w-full flex" >
45+ < span className = "ml-auto" >
46+ < Button
47+ action = { ( ) => {
48+ console . log ( 'Copying calendar link' )
49+
50+ const inputElement = document . getElementById (
51+ 'calendarLink'
52+ ) as HTMLInputElement
53+
54+ inputElement . select ( )
55+ inputElement . setSelectionRange ( 0 , 99999 )
56+
57+ navigator . clipboard . writeText ( props . url )
58+
59+ alert ( 'Kopierat!' )
60+ } }
61+ >
62+ Kopiera
63+ </ Button >
64+ </ span >
65+ </ div >
66+ </ div >
67+ </ Modal >
68+ )
69+ }
70+
71+ export default CalendarSubscribeModal
72+
73+ interface CalendarLinkProps {
74+ href : string
75+ children ?: string
76+ }
77+
78+ const CalendarLink = ( props : CalendarLinkProps ) => {
79+ return (
80+ < a
81+ className = "text-cyan-600 underline"
82+ href = { props . href }
83+ target = "_blank"
84+ >
85+ { props . children }
86+ </ a >
87+ )
88+ }
Original file line number Diff line number Diff line change 1+ interface ModalProps {
2+ children ?: React . ReactNode
3+ onClose : ( ) => void
4+ background ?: string
5+ }
6+
7+ const Modal = ( props : ModalProps ) => {
8+ return (
9+ < div className = "fixed inset-0 z-40 flex justify-center items-center" >
10+ < button
11+ className = "absolute inset-0 bg-black/60"
12+ onClick = { e => {
13+ e . preventDefault ( )
14+ props . onClose ( )
15+ } }
16+ />
17+
18+ < div
19+ className = {
20+ 'absolute rounded-lg shadow-lg px-8 pt-4 pb-6 border border-white ' +
21+ ( props . background ?? 'bg-black' )
22+ }
23+ >
24+ < div className = "flex justify-end" >
25+ < button
26+ className = "r-1 t-0 -mr-4 aspect-square"
27+ onClick = { e => {
28+ e . preventDefault ( )
29+ props . onClose ( )
30+ } }
31+ >
32+ < span className = "h-4 p-2 text-xl" > ×</ span >
33+ </ button >
34+ </ div >
35+ { props . children }
36+ </ div >
37+ </ div >
38+ )
39+ }
40+
41+ export default Modal
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ export default function Page(props: PageProps) {
4646 ) }
4747
4848 { /* Header */ }
49- < div className = "fixed flex flex-col items-center w-screen top-0 z-50 pointer-events-none" >
49+ < div className = "fixed flex flex-col items-center w-screen top-0 z-20 pointer-events-none" >
5050 < Header year = { props . currentYear } blackout = { props . blackout ?? false } />
5151 </ div >
5252 </ >
Original file line number Diff line number Diff line change 1919 "@types/multer" : " ^1.4.7" ,
2020 "cookie" : " ^0.5.0" ,
2121 "formidable" : " ^2.1.1" ,
22+ "iamcal" : " ^2.1.2" ,
2223 "jose" : " ^4.10.0" ,
2324 "multer" : " ^1.4.5-lts.1" ,
2425 "next" : " ^12.3.4" ,
You can’t perform that action at this time.
0 commit comments