forked from infoshareacademy/jfdzr12-project-react
-
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 #37 from infoshareacademy/halyna-riabokonenko/type…
…-script Halyna riabokonenko/type script
- Loading branch information
Showing
26 changed files
with
326 additions
and
161 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface LandingPageProps { | ||
quotes: string[]; | ||
} |
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,42 +1,53 @@ | ||
import styles from "./Portfolio.module.css"; | ||
import portfolioData from "../../../public/photos.json"; | ||
import { useContext, useState } from "react"; | ||
import { useContext, useEffect, useState } from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { ThemeContext } from "../../providers/theme"; | ||
import { ThemeContext } from "../../providers/theme.tsx"; | ||
|
||
export const Portfolio = () => { | ||
const [imageId, setImageId] = useState(null); | ||
const { theme } = useContext(ThemeContext); | ||
|
||
const [portfolioData, setPortfolioData] = useState(null); | ||
|
||
useEffect(() => { | ||
fetch("/photos.json") | ||
.then((res) => res.json()) | ||
.then((data) => { | ||
setPortfolioData(data); | ||
console.log(data); | ||
}); | ||
}, []); | ||
return ( | ||
<div className={`${styles["portfolio__container"]} ${styles[theme]}`}> | ||
<h1 className={`${styles["portfolio__header"]} ${styles[theme]}`}> | ||
Our portfolio | ||
</h1> | ||
<div className={styles["portfolio"]}> | ||
<h3 className={`${styles["portfolio__info"]} ${styles[theme]}`}> | ||
We are experienced in taking photos for all kinds of circumstances. | ||
<br /> | ||
Below is a summary of our extensive portfolio, with us you will always | ||
look good! | ||
</h3> | ||
</div> | ||
<div className={styles["portfolio__photos"]}> | ||
{portfolioData.photos.map((photo) => ( | ||
<div key={photo.id} className={styles["portfolio__items"]}> | ||
<Link to={`/portfolio/${photo.id}`}> | ||
<img | ||
src={photo.url} | ||
className={styles["portfolio__photo"]} | ||
data-id={photo.id} | ||
onClick={() => { | ||
setImageId(photo.id); | ||
}} | ||
/> | ||
</Link> | ||
</div> | ||
))} | ||
portfolioData && ( | ||
<div className={`${styles["portfolio__container"]} ${styles[theme]}`}> | ||
<h1 className={`${styles["portfolio__header"]} ${styles[theme]}`}> | ||
Our portfolio | ||
</h1> | ||
<div className={styles["portfolio"]}> | ||
<h3 className={`${styles["portfolio__info"]} ${styles[theme]}`}> | ||
We are experienced in taking photos for all kinds of circumstances. | ||
<br /> | ||
Below is a summary of our extensive portfolio, with us you will | ||
always look good! | ||
</h3> | ||
</div> | ||
<div className={styles["portfolio__photos"]}> | ||
{portfolioData.photos.map((photo) => ( | ||
<div key={photo.id} className={styles["portfolio__items"]}> | ||
<Link to={`/portfolio/${photo.id}`}> | ||
<img | ||
src={photo.url} | ||
className={styles["portfolio__photo"]} | ||
data-id={photo.id} | ||
onClick={() => { | ||
setImageId(photo.id); | ||
}} | ||
/> | ||
</Link> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import styles from "./Portfolio.module.css"; | ||
import { useContext, useEffect, useState } from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { ThemeContext } from "../../providers/theme.tsx"; | ||
import { PortfolioInterface } from "./Portfolio.types"; | ||
|
||
|
||
export const Portfolio = () => { | ||
const [setImageId] = useState(null); | ||
const { theme } = useContext(ThemeContext); | ||
|
||
const [portfolioData, setPortfolioData] = useState<PortfolioInterface | null>(null); | ||
|
||
useEffect(() => { | ||
fetch("/photos.json") | ||
.then((res) => res.json()) | ||
.then((data) => | ||
setPortfolioData(data) | ||
); | ||
}, []); | ||
return ( | ||
portfolioData && ( | ||
<div className={`${styles["portfolio__container"]} ${styles[theme]}`}> | ||
<h1 className={`${styles["portfolio__header"]} ${styles[theme]}`}> | ||
Our portfolio | ||
</h1> | ||
<div className={styles["portfolio"]}> | ||
<h3 className={`${styles["portfolio__info"]} ${styles[theme]}`}> | ||
We are experienced in taking photos for all kinds of circumstances. | ||
<br /> | ||
Below is a summary of our extensive portfolio, with us you will | ||
always look good! | ||
</h3> | ||
</div> | ||
<div className={styles["portfolio__photos"]}> | ||
{portfolioData.photos.map((photo) => ( | ||
<div key={photo.id} className={styles["portfolio__items"]}> | ||
<Link to={`/portfolio/${photo.id}`}> | ||
<img | ||
src={photo.url} | ||
className={styles["portfolio__photo"]} | ||
data-id={photo.id} | ||
onClick={() => { | ||
setImageId(photo.id); | ||
}} | ||
/> | ||
</Link> | ||
</div> | ||
))} | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface PortfolioInterface { | ||
author: string; | ||
height: number; | ||
id: number; | ||
price: number; | ||
url: string; | ||
width: number; | ||
} |
2 changes: 1 addition & 1 deletion
2
my-app/src/Components/Portfolio/PortfolioImage/PortfolioImage.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
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,49 +1,49 @@ | ||
import styles from "./PortfolioModal.module.css"; | ||
import { Modal } from "../Modal/Modal.jsx"; | ||
import { useEffect } from "react"; | ||
// import styles from "./PortfolioModal.module.css"; | ||
// import { Modal } from "../Modal/Modal.jsx"; | ||
// import { useEffect } from "react"; | ||
|
||
export const PortfolioModal = ({ isOpen, onClose }) => { | ||
useEffect(() => { | ||
const handleKeyDown = (event) => { | ||
if (event.key === "Escape") { | ||
onClose(); | ||
} | ||
}; | ||
// export const PortfolioModal = ({ isOpen, onClose }) => { | ||
// useEffect(() => { | ||
// const handleKeyDown = (event) => { | ||
// if (event.key === "Escape") { | ||
// onClose(); | ||
// } | ||
// }; | ||
|
||
window.addEventListener("keydown", handleKeyDown); | ||
// window.addEventListener("keydown", handleKeyDown); | ||
|
||
return () => { | ||
window.removeEventListener("keydown", handleKeyDown); | ||
}; | ||
}, [onClose]); | ||
// return () => { | ||
// window.removeEventListener("keydown", handleKeyDown); | ||
// }; | ||
// }, [onClose]); | ||
|
||
useEffect(() => { | ||
document.body.style.overflow = isOpen ? "hidden" : "auto"; | ||
// useEffect(() => { | ||
// document.body.style.overflow = isOpen ? "hidden" : "auto"; | ||
|
||
return () => { | ||
document.body.style.overflow = "auto"; | ||
}; | ||
}, [isOpen]); | ||
// return () => { | ||
// document.body.style.overflow = "auto"; | ||
// }; | ||
// }, [isOpen]); | ||
|
||
return ( | ||
<> | ||
<div style={{ display: isOpen ? "block" : "none" }}> | ||
{isOpen && ( | ||
<div className="portfolio-modal__overlay" onClick={onClose}></div> | ||
)} | ||
// return ( | ||
// <> | ||
// <div style={{ display: isOpen ? "block" : "none" }}> | ||
// {isOpen && ( | ||
// <div className="portfolio-modal__overlay" onClick={onClose}></div> | ||
// )} | ||
|
||
<Modal> | ||
<button | ||
className={styles["portfolio-modal__button-close"]} | ||
onClick={onClose} | ||
> | ||
x | ||
</button> | ||
<div> | ||
<h1>Portfolio modal </h1> | ||
</div> | ||
</Modal> | ||
</div> | ||
</> | ||
); | ||
}; | ||
// <Modal> | ||
// <button | ||
// className={styles["portfolio-modal__button-close"]} | ||
// onClick={onClose} | ||
// > | ||
// x | ||
// </button> | ||
// <div> | ||
// <h1>Portfolio modal </h1> | ||
// </div> | ||
// </Modal> | ||
// </div> | ||
// </> | ||
// ); | ||
// }; |
Oops, something went wrong.