File tree Expand file tree Collapse file tree 4 files changed +48
-33
lines changed
Expand file tree Collapse file tree 4 files changed +48
-33
lines changed Original file line number Diff line number Diff line change 1+ <div id =" modal" class =" pointer-none fixed top-0 left-0 -z-50 flex h-full w-full items-center justify-center bg-black/20 px-4 py-8 opacity-0 backdrop-blur-xs transition-opacity duration-300" >
2+ <div class =" flex max-h-full max-w-lg min-w-80 translate-y-5 flex-col rounded-lg bg-white p-4 transition-transform duration-300" >
3+ <div class =" modal-header" ></div >
4+ <div class =" modal-body overflow-y-auto" ></div >
5+ </div >
6+ </div >
7+
8+ <script >
9+ import { hideModal } from '~/utils/client/modal'
10+
11+ const modalEl = document.querySelector('#modal')
12+
13+ modalEl?.addEventListener('click', e => {
14+ if (e.target !== e.currentTarget) return
15+ hideModal()
16+ })
17+ </script >
18+
19+ <style >
20+ #modal.show {
21+ opacity: 1;
22+ pointer-events: auto;
23+ z-index: 99999;
24+ }
25+
26+ #modal.show > div {
27+ translate: 0;
28+ }
29+ </style >
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import Navbar from '~/components/Navbar.astro'
55import Footer from ' ~/components/Footer.astro'
66import CookieNotice from ' ~/components/CookieNotice.astro'
77import StagingInfo from ' ~/components/StagingInfo.astro'
8+ import Modal from ' ~/components/Modal.astro'
89import { isStaging } from ' ~/utils/build/isStaging'
910import { getLocaleFromPath } from ' ~/i18n/utils'
1011
@@ -24,6 +25,7 @@ const { pageName } = Astro.props
2425 <CookieNotice />
2526 { isStaging () && <StagingInfo />}
2627 </div >
28+ <Modal />
2729
2830 <script is:inline src =" https://cdn.jsdelivr.net/npm/iconify-icon@3.0.0/dist/iconify-icon.min.js" ></script >
2931 </body >
Original file line number Diff line number Diff line change 213213 }
214214}
215215
216- body [lang = 'en-TW' ] .timeline-item-title {
217- @apply text-xl;
218- }
219-
220- # modal {
221- @apply fixed top-0 left-0 z-50 flex h-full w-full items-center justify-center p-4;
222- background-color : rgba (0 , 0 , 0 , 0.5 );
223- backdrop-filter : blur (2px );
224- transition : all 0.3s ease;
225- opacity : 0 ;
226- pointer-events : none;
227- > .inner-modal {
228- @apply flex max-w-lg min-w-80 flex-col bg-white;
229- max-height : 100% ;
230- transition : all 0.3s ease;
231- transform : translateY (20px );
232- }
233- .modal-body {
234- flex : 1 ;
235- overflow-y : auto;
236- hr {
237- margin : 1rem 0 ;
238- }
239- }
240- & .show {
241- opacity : 1 ;
242- pointer-events : auto;
243- > .inner-modal {
244- transform : translateY (0 );
245- }
246- }
247- }
248-
249216footer {
250217 .rolling-list a {
251218 @apply text-neutral-600;
Original file line number Diff line number Diff line change 1+ const modalEl = document . querySelector ( '#modal' )
2+ const modalHeaderEl = document . querySelector ( '#modal .modal-header' )
3+ const modalBodyEl = document . querySelector ( '#modal .modal-body' )
4+
5+ export function showModal ( ) {
6+ modalEl . classList . add ( 'show' )
7+ }
8+
9+ export function hideModal ( ) {
10+ modalEl . classList . remove ( 'show' )
11+ }
12+
13+ export function showModalWith ( { header, body } ) {
14+ modalHeaderEl . innerHTML = header
15+ modalBodyEl . innerHTML = body
16+ showModal ( )
17+ }
You can’t perform that action at this time.
0 commit comments