-
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.
- Loading branch information
1 parent
ccb8252
commit 7686289
Showing
6 changed files
with
98 additions
and
9 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import styled from "@emotion/styled"; | ||
import { useState } from "react"; | ||
import { POP_UP_WIDTH } from "../style"; | ||
import { Group, Text, Button } from "./base"; | ||
|
||
export type ModalProps = { | ||
title?: string, | ||
description?: string, | ||
opened: boolean, | ||
onSubmit: (response: "Ok" | "Ignore") => void | ||
} | ||
|
||
export const Modal = (props: ModalProps) => { | ||
const { title, description, opened, onSubmit } = props; | ||
const ModalBackground = styled.div` | ||
position: absolute; | ||
top: 0px; | ||
height: 100%; | ||
left: 0px; | ||
min-width: 100%; | ||
background-color: gray; | ||
opacity: 0.4; | ||
`; | ||
const ModalContainer = styled.div` | ||
position: absolute; | ||
top: 120px; | ||
min-height: 120px; | ||
left: ${(POP_UP_WIDTH - 380) / 2}px; | ||
min-width: 380px; | ||
padding: 10px; | ||
z-index: 999; | ||
border: 2px black solid; | ||
border-radius: 4px; | ||
background-color: white; | ||
`; | ||
return <> | ||
<ModalBackground hidden={!opened} /> | ||
<ModalContainer hidden={!opened}> | ||
<Group> | ||
<Text size='l'>{title}</Text> | ||
</Group> | ||
<Group margin='5px 0 0 0' style={{ minHeight: "60px" }}> | ||
<Text size='s'>{description}</Text> | ||
</Group> | ||
<Group margin='0px 30px' justifyContent='space-between'> | ||
<Button onClick={() => props.onSubmit("Ignore")} color='green'>Ignore</Button> | ||
<Button onClick={() => props.onSubmit("Ok")} color='red'>Ok</Button> | ||
</Group> | ||
</ModalContainer> | ||
</> | ||
} |
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,2 +1,3 @@ | ||
export * from "./use-content-script"; | ||
export * from "./use-storage"; | ||
export * from "./use-modal"; |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { useState } from "react"; | ||
import { ModalProps } from "../components"; | ||
|
||
export const useModal = () => { | ||
const CLOSED_MODAL_PROPS = { | ||
title: "", | ||
description: "", | ||
opened: false, | ||
onSubmit: () => {}, | ||
}; | ||
const [modalState, setModalState] = useState<ModalProps>(CLOSED_MODAL_PROPS); | ||
const closeModal = () => setModalState(CLOSED_MODAL_PROPS); | ||
const openModal = (props: ModalProps) => setModalState(props); | ||
return { | ||
/**Props to use in the modal */ | ||
modalProps: modalState, | ||
closeModal, | ||
openModal, | ||
}; | ||
}; |
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