-
Notifications
You must be signed in to change notification settings - Fork 2
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 #26 from ViktorSvertoka/productsPage
work in(css)
- Loading branch information
Showing
5 changed files
with
183 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { useEffect } from "react"; | ||
import { createPortal } from "react-dom"; | ||
import PropTypes from "prop-types"; | ||
|
||
import { BasicWindow, Modal, ButtonClouse, SvgClouse } from "./BasicModalWindow.styles"; | ||
|
||
import symbolDefs from "../../../src/images/sprite.svg"; | ||
|
||
|
||
|
||
const BasicModalWindow = ({ children, isOpenModalToggle }) => { | ||
|
||
|
||
useEffect(() => { | ||
const closeESC = (e) => { | ||
if (e.code === "Escape") { | ||
isOpenModalToggle(); | ||
} | ||
}; | ||
document.addEventListener("keydown", closeESC); | ||
return () => { | ||
document.removeEventListener("keydown", closeESC); | ||
}; | ||
}, [isOpenModalToggle]); | ||
|
||
const handleClickBackground = (e) => { | ||
if (e.currentTarget === e.target) { | ||
isOpenModalToggle(); | ||
} | ||
}; | ||
|
||
const modal = ( | ||
<BasicWindow onClick={handleClickBackground}> | ||
<Modal> | ||
<ButtonClouse onClick={() => isOpenModalToggle()}> | ||
<SvgClouse > | ||
<use href={symbolDefs + "#icon-x"}></use> | ||
</SvgClouse> | ||
</ButtonClouse> | ||
|
||
{children} | ||
</Modal> | ||
</BasicWindow> | ||
); | ||
|
||
return createPortal(modal, document.querySelector("#root_modal")); | ||
}; | ||
|
||
export default BasicModalWindow; | ||
|
||
BasicModalWindow.propTypes = { | ||
children: PropTypes.any, | ||
isOpenModaltoggle: PropTypes.func, | ||
}; |
37 changes: 37 additions & 0 deletions
37
src/components/BasicModalWindow/BasicModalWindow.styles.jsx
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,37 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const BasicWindow = styled.div` | ||
width: 100%; | ||
height: 100%; | ||
background: rgba(04, 04, 04, 0.4); | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
export const Modal = styled.div` | ||
border-radius: 12px; | ||
border: 1px solid rgba(239, 237, 232, 0.2); | ||
background: #10100f; | ||
position: relative; | ||
`; | ||
export const ButtonClouse = styled.button` | ||
width: 22px; | ||
height: 22px; | ||
border: none; | ||
background: inherit; | ||
position: absolute; | ||
top: 14px; | ||
right: 14px; | ||
`; | ||
|
||
export const SvgClouse = styled.button` | ||
width: 20px; | ||
height: 20px; | ||
stroke: var(--white-color); | ||
`; |
32 changes: 32 additions & 0 deletions
32
src/components/products/AddProductSuccess/AddProductSuccess.jsx
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,32 @@ | ||
// import { Link } from "react-router-dom"; | ||
|
||
// export const AddProductSuccess = ({ calories, closeModal }) => { | ||
// return ( | ||
// <div > | ||
// <div > | ||
// <div > | ||
// <img | ||
// src={avocado} | ||
// alt="avocado" | ||
// /> | ||
// <p >Well done</p> | ||
// <p > | ||
// Calories:{" "} | ||
// <span >{calories}</span> | ||
// </p> | ||
// </div> | ||
// <Link to="/products" onClick={closeModal}> | ||
// <button >Next product</button> | ||
// </Link> | ||
// <Link to="/diary" onClick={closeModal}> | ||
// <p > | ||
// To the diary | ||
// <svg > | ||
// <use > </use> | ||
// </svg> | ||
// </p> | ||
// </Link> | ||
// </div> | ||
// </div> | ||
// ); | ||
// }; |
Empty file.
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