-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from shoonia/Use-dialog-element-instead-react…
…-modal Use dialog element instead react modal
- Loading branch information
Showing
10 changed files
with
240 additions
and
348 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,9 @@ | ||
import s from './styles.css'; | ||
import { useStoreon } from '../../store'; | ||
import { ROUTER } from '../../constants'; | ||
import { Editor } from '../Editor'; | ||
import { Preview } from '../Preview'; | ||
import { UploadModal } from '../UploadModal'; | ||
|
||
export const Builder: FC = () => { | ||
const { path } = useStoreon('path'); | ||
|
||
const uploadModal = path === ROUTER.UPLOAD && ( | ||
<UploadModal /> | ||
); | ||
|
||
return ( | ||
<div className={s.box}> | ||
<Editor /> | ||
<Preview /> | ||
{uploadModal} | ||
</div> | ||
); | ||
}; | ||
export const Builder: FC = () => | ||
<div className={s.box}> | ||
<Editor /> | ||
<Preview /> | ||
</div>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
import type { ComponentClass } from 'preact'; | ||
import ReactModal from 'react-modal'; | ||
|
||
import { useEffect, useRef } from 'preact/hooks'; | ||
import s from './styles.css'; | ||
|
||
interface Props { | ||
label: string; | ||
close: () => void; | ||
open: boolean; | ||
} | ||
|
||
ReactModal.setAppElement('#app'); | ||
export const Modal: FC<Props> = ({ open, children }) => { | ||
const ref = useRef<HTMLDialogElement>(null); | ||
|
||
// @ts-expect-error @typescript-eslint/ban-ts-comment | ||
const ReactModalPreactTyped: ComponentClass<ReactModal.Props> = ReactModal; | ||
useEffect(() => { | ||
if (open) { | ||
ref.current?.showModal(); | ||
} else { | ||
ref.current?.close(); | ||
} | ||
}, [open]); | ||
|
||
export const Modal: FC<Props> = ({ close, label, children }) => ( | ||
<ReactModalPreactTyped | ||
isOpen | ||
onRequestClose={close} | ||
contentLabel={label} | ||
overlayClassName={s.overlay} | ||
className={s.modal} | ||
bodyOpenClassName={s.bodyOpen} | ||
htmlOpenClassName={s.rootOpen} | ||
> | ||
{children as []} | ||
</ReactModalPreactTyped> | ||
); | ||
return ( | ||
<dialog | ||
ref={ref} | ||
className={s.modal} | ||
> | ||
{children} | ||
</dialog> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,15 @@ | ||
.overlay { | ||
background-color: rgb(22 45 61 / 66%); | ||
position: fixed; | ||
inset: 0; | ||
width: 100%; | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: center; | ||
z-index: 10; | ||
} | ||
|
||
.bodyOpen, | ||
.rootOpen { | ||
overflow: hidden; | ||
} | ||
@import url('../../styles/vars.css'); | ||
|
||
.modal { | ||
outline: none; | ||
border-radius: 8px; | ||
max-height: 100%; | ||
padding: 0; | ||
border: none; | ||
color: $color-font; | ||
overflow-x: hidden; | ||
} | ||
|
||
.modal::backdrop { | ||
background-color: rgb(22 45 61 / 66%); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters