diff --git a/src/assets/data/gallery.js b/src/assets/data/gallery.js new file mode 100644 index 0000000..df9b2df --- /dev/null +++ b/src/assets/data/gallery.js @@ -0,0 +1,108 @@ +import pic0 from "../pics/gallery/IMG_0796.jpg"; +import pic1 from "../pics/gallery/IMG_6390.jpg"; +import pic2 from "../pics/gallery/IMG_6392.jpg"; +import pic3 from "../pics/gallery/IMG_6393.jpg"; +import pic4 from "../pics/gallery/IMG_8547.jpg"; +import pic5 from "../pics/gallery/IMG_8548.jpg"; +import pic6 from "../pics/gallery/IMG_8549.jpg"; +import pic7 from "../pics/gallery/JSDC2011.jpg"; +import pic8 from "../pics/gallery/JSDC2012.jpg"; +import pic9 from "../pics/gallery/dsc_0001.jpg"; +import pic10 from "../pics/gallery/dsc_0003.jpg"; +import pic11 from "../pics/gallery/dsc_0235.jpg"; +import pic12 from "../pics/gallery/dsc_0238.jpg"; +import pic13 from "../pics/gallery/dsc_0243.jpg"; +import pic14 from "../pics/gallery/jsdc2015_001.jpg"; +import pic15 from "../pics/gallery/jsdc2015_002.jpg"; +import pic16 from "../pics/gallery/jsdc2015_003.jpg"; + +const gallery = { + pic: [ + { + title: "", + content: "", + img: pic0, + }, + { + title: "", + content: "", + img: pic1, + }, + { + title: "", + content: "", + img: pic2, + }, + { + title: "", + content: "", + img: pic3, + }, + { + title: "", + content: "", + img: pic4, + }, + { + title: "", + content: "", + img: pic5, + }, + { + title: "", + content: "", + img: pic6, + }, + { + title: "", + content: "", + img: pic7, + }, + { + title: "", + content: "", + img: pic8, + }, + { + title: "", + content: "", + img: pic9, + }, + { + title: "", + content: "", + img: pic10, + }, + { + title: "", + content: "", + img: pic11, + }, + { + title: "", + content: "", + img: pic12, + }, + { + title: "", + content: "", + img: pic13, + }, + { + title: "", + content: "", + img: pic14, + }, + { + title: "", + content: "", + img: pic15, + }, + { + title: "", + content: "", + img: pic16, + } + ], +}; +export default gallery; diff --git a/src/assets/stylesheets/gallery.scss b/src/assets/stylesheets/gallery.scss new file mode 100644 index 0000000..134e0d9 --- /dev/null +++ b/src/assets/stylesheets/gallery.scss @@ -0,0 +1,40 @@ +@font-face { + font-family: itrFont; + src: url(../font/LeagueSpartan-ExtraBold.ttf); +} + +@font-face { + font-family: itrFontMedium; + src: url(../font/LeagueSpartan-Medium.ttf); +} + +.gallery { + background-color: #232323; + width: 100%; + min-height: 100vh; + height: auto; + opacity: 100%; + overflow-x: hidden; + display: flex; + -webkit-animation: fade 0.9s ease-in; + -moz-animation: fade 0.9s ease-in; + -ms-animation: fade 0.9s ease-in; + -o-animation: fade 0.9s ease-in; + animation: fade 0.9s ease-in; + background: linear-gradient(#3b3b3b, #1a1a1a); +} + +.gallery_wrap { + flex-wrap: wrap; + padding: 24px; + margin-left: 20px; + display: flex; + flex-direction: row; + justify-content: start; +} +.gallery__title { + margin: 20px 0 20px 20px; + font-family: itrFontMedium; + color: #fff; + text-align: center; +} diff --git a/src/components/AppOuter.js b/src/components/AppOuter.js index b610443..2c00a20 100644 --- a/src/components/AppOuter.js +++ b/src/components/AppOuter.js @@ -3,9 +3,15 @@ import DropdownContainer from "../components/DropdownContainer"; import GlobalStore from "../store/global"; import NavBar from "../components/NavBar"; import Footer from "../components/Footer"; +import { useLocation } from "react-router-dom"; +import { useEffect } from "react"; const AppOuter = ({ children }) => { const { isHamburger, setIsHamburger } = useContainer(GlobalStore); + const location = useLocation(); + useEffect(() => { + setIsHamburger(false); + }, [location.pathname]); return (
{isHamburger ? ( diff --git a/src/components/Gallery.js b/src/components/Gallery.js index bd11d48..1392c6f 100644 --- a/src/components/Gallery.js +++ b/src/components/Gallery.js @@ -1,22 +1,62 @@ -import React, { Component } from "react"; -import backgroundVideo from "../assets/video.mp4"; -import "../assets/stylesheets/home.scss"; +import React, { useEffect, useMemo } from "react"; +import "../assets/stylesheets/gallery.scss"; +import { useContainer } from "unstated-next"; +import GlobalStore from "../store/global"; +import gallery from "../assets/data/gallery"; +import WaterfallPosition from "./hooks/waterfall"; +import { Image } from "antd"; -export default class Gallery extends Component { - render() { - return ( -
- -
- +const Render = ({ onLoad, data, sizeRef }) => { + return ( +
+ { + setTimeout(() => { + onLoad(sizeRef.current.size); + }, 100); + }} + onError={() => + setTimeout(() => { + onLoad(sizeRef.current.size); + }, 100) + } + width={"100%"} + src={data.img} + /> +
+ ); +}; + +const Gallery = () => { + useEffect(() => { + window.scrollTo(0, 0); + }, []); + + const { bodySize } = useContainer(GlobalStore); + const count = useMemo(() => { + if (bodySize.width > 850) { + return 3; + } + if (bodySize.width > 650) { + return 2; + } + return 1; + }, [bodySize]); + return ( +
+
+
+
+

Gallery

+ +
- ); - } -} +
+ ); +}; +export default Gallery; diff --git a/src/components/Projects.js b/src/components/Projects.js index 118fade..6585c83 100644 --- a/src/components/Projects.js +++ b/src/components/Projects.js @@ -3,8 +3,59 @@ import "../assets/stylesheets/project.scss"; import { useContainer } from "unstated-next"; import GlobalStore from "../store/global"; import projects from "../assets/data/projects"; -import WaterfallPosition from "./Waterfall"; - +import WaterfallPosition from "./hooks/waterfall"; +import { Image } from "antd"; +const Render = ({ onLoad, data, sizeRef }) => { + return ( +
+
+

+ {data.title} +

+

+ {data.sub} +

+
+
+ { + setTimeout(() => { + onLoad(sizeRef.current.size); + }, 500); + }} + onError={() => + setTimeout(() => { + onLoad(sizeRef.current.size); + }, 500) + } + width={"100%"} + src={data.img} + /> + {data.content} +
+
+ ); +}; const Project = () => { useEffect(() => { window.scrollTo(0, 0); @@ -26,11 +77,19 @@ const Project = () => {

Active Projects

- +

Retired/Inactive Projects

- +
{/* */} diff --git a/src/components/Waterfall.js b/src/components/hooks/waterfall.js similarity index 51% rename from src/components/Waterfall.js rename to src/components/hooks/waterfall.js index 0fcb567..e1d48dc 100644 --- a/src/components/Waterfall.js +++ b/src/components/hooks/waterfall.js @@ -1,9 +1,8 @@ -import { useSize } from "ahooks"; +import { useDebounce, useSize, useThrottleFn } from "ahooks"; import React, { useRef, useEffect, useState } from "react"; -import "../assets/stylesheets/waterfall.scss"; -import { Image } from "antd"; +import "../../assets/stylesheets/waterfall.scss"; -const WaterfallItem = ({ data, onLoad }) => { +const WaterfallItem = ({ data, onLoad, Render }) => { const ref = useRef(); const size = useSize(ref); const sizeRef = useRef({}); @@ -12,58 +11,20 @@ const WaterfallItem = ({ data, onLoad }) => { }, [size]); return (
-
-
-

- {data.title} -

-

- {data.sub} -

-
-
- { - setTimeout(() => { - onLoad(sizeRef.current.size); - }, 500); - }} - onError={() => - setTimeout(() => { - onLoad(sizeRef.current.size); - }, 500) - } - width={"100%"} - src={data.img} - /> - {data.content} -
-
+ { + setTimeout(() => { + onLoad(sizeRef.current.size); + }, 500); + }} + sizeRef={sizeRef} + data={data} + />
); }; -const WaterfallPosition = ({ columnNumber, list }) => { +const useWaterfall = ({ list, columnNumber, Render }) => { const stateRef = useRef({ heights: [], loadNum: 0, @@ -71,7 +32,7 @@ const WaterfallPosition = ({ columnNumber, list }) => { const onload = (index, height) => { stateRef.current.heights[index] = height; stateRef.current.loadNum++; - if (stateRef.current.loadNum === list.length) { + if (stateRef.current.loadNum <= list.length) { onSize(); } }; @@ -95,12 +56,29 @@ const WaterfallPosition = ({ columnNumber, list }) => { }; const waterfallDOM = useRef(); const size = useSize(waterfallDOM); + const { run: onSizeThrottle } = useThrottleFn(onSize, { wait: 5e2 }); useEffect(() => { - onSize(); + onSizeThrottle(); }, [size, columnNumber]); const rendered = list.map((item, index) => ( - onload(index, size.height)} data={item} /> + onload(index, size.height)} + data={item} + Render={Render} + /> )); + return { + waterfallDOM, + columns, + }; +}; + +const WaterfallPosition = ({ columnNumber, list, Render }) => { + const { waterfallDOM, columns } = useWaterfall({ + columnNumber, + list, + Render, + }); return (
{columns.map((column) => { diff --git a/src/index.js b/src/index.js index 9c50dec..a9133d2 100644 --- a/src/index.js +++ b/src/index.js @@ -8,6 +8,7 @@ import reportWebVitals from "./reportWebVitals"; import { createBrowserRouter, RouterProvider } from "react-router-dom"; import ErrorRoute from "./routes/ErrorRoute"; import GlobalStore from "./store/global"; +import GalleryRoute from "./routes/GalleryRoute"; const root = ReactDOM.createRoot(document.getElementById("root")); @@ -31,11 +32,18 @@ const router = createBrowserRouter([ path: "/projects", element: , errorElement: , - } + }, + { + path: "/gallery", + element: , + errorElement: , + }, ]); -root.render( - -); +root.render( + + + +); reportWebVitals(); diff --git a/src/routes/GalleryRoute.js b/src/routes/GalleryRoute.js index e69de29..f9a912d 100644 --- a/src/routes/GalleryRoute.js +++ b/src/routes/GalleryRoute.js @@ -0,0 +1,12 @@ +import AppOuter from "../components/AppOuter"; +import Gallery from "../components/Gallery"; + +const GalleryRoute = () => { + return ( + + + + ); +}; + +export default GalleryRoute;