add gallery
This commit is contained in:
parent
691ae1e3f9
commit
57ab55bc45
108
src/assets/data/gallery.js
Normal file
108
src/assets/data/gallery.js
Normal file
@ -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;
|
40
src/assets/stylesheets/gallery.scss
Normal file
40
src/assets/stylesheets/gallery.scss
Normal file
@ -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;
|
||||||
|
}
|
@ -3,9 +3,15 @@ import DropdownContainer from "../components/DropdownContainer";
|
|||||||
import GlobalStore from "../store/global";
|
import GlobalStore from "../store/global";
|
||||||
import NavBar from "../components/NavBar";
|
import NavBar from "../components/NavBar";
|
||||||
import Footer from "../components/Footer";
|
import Footer from "../components/Footer";
|
||||||
|
import { useLocation } from "react-router-dom";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
const AppOuter = ({ children }) => {
|
const AppOuter = ({ children }) => {
|
||||||
const { isHamburger, setIsHamburger } = useContainer(GlobalStore);
|
const { isHamburger, setIsHamburger } = useContainer(GlobalStore);
|
||||||
|
const location = useLocation();
|
||||||
|
useEffect(() => {
|
||||||
|
setIsHamburger(false);
|
||||||
|
}, [location.pathname]);
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
{isHamburger ? (
|
{isHamburger ? (
|
||||||
|
@ -1,22 +1,62 @@
|
|||||||
import React, { Component } from "react";
|
import React, { useEffect, useMemo } from "react";
|
||||||
import backgroundVideo from "../assets/video.mp4";
|
import "../assets/stylesheets/gallery.scss";
|
||||||
import "../assets/stylesheets/home.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 {
|
const Render = ({ onLoad, data, sizeRef }) => {
|
||||||
render() {
|
|
||||||
return (
|
return (
|
||||||
<div className="home">
|
<div className="gallery__content">
|
||||||
<video autoPlay loop muted className="home__video">
|
<Image
|
||||||
<source src={backgroundVideo} type="video/mp4" />
|
onLoad={() => {
|
||||||
</video>
|
setTimeout(() => {
|
||||||
<div className="home__content">
|
onLoad(sizeRef.current.size);
|
||||||
<label className="home__content__title">
|
}, 100);
|
||||||
ILLINOIS TECH
|
}}
|
||||||
<br />
|
onError={() =>
|
||||||
ROBOTICS
|
setTimeout(() => {
|
||||||
</label>
|
onLoad(sizeRef.current.size);
|
||||||
|
}, 100)
|
||||||
|
}
|
||||||
|
width={"100%"}
|
||||||
|
src={data.img}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
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 (
|
||||||
|
<div className="gallery">
|
||||||
|
<div className="gallery__content">
|
||||||
|
<div className="gallery__content__main">
|
||||||
|
<div>
|
||||||
|
<h1 className="gallery__title">Gallery</h1>
|
||||||
|
<WaterfallPosition
|
||||||
|
columnNumber={count}
|
||||||
|
list={gallery.pic}
|
||||||
|
Render={Render}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
}
|
export default Gallery;
|
||||||
|
@ -3,8 +3,59 @@ import "../assets/stylesheets/project.scss";
|
|||||||
import { useContainer } from "unstated-next";
|
import { useContainer } from "unstated-next";
|
||||||
import GlobalStore from "../store/global";
|
import GlobalStore from "../store/global";
|
||||||
import projects from "../assets/data/projects";
|
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 (
|
||||||
|
<div className="project__content__main__container">
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<h3
|
||||||
|
style={{
|
||||||
|
fontFamily: "itrFontMedium",
|
||||||
|
fontSize: "25px",
|
||||||
|
color: "#fff",
|
||||||
|
marginBottom: 12,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{data.title}
|
||||||
|
</h3>
|
||||||
|
<h3
|
||||||
|
style={{
|
||||||
|
fontFamily: "itrFontMedium",
|
||||||
|
fontSize: "25px",
|
||||||
|
color: "#fff",
|
||||||
|
marginBottom: 12,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{data.sub}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div className="project_item_content">
|
||||||
|
<Image
|
||||||
|
onLoad={() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
onLoad(sizeRef.current.size);
|
||||||
|
}, 500);
|
||||||
|
}}
|
||||||
|
onError={() =>
|
||||||
|
setTimeout(() => {
|
||||||
|
onLoad(sizeRef.current.size);
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
width={"100%"}
|
||||||
|
src={data.img}
|
||||||
|
/>
|
||||||
|
<span>{data.content}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
const Project = () => {
|
const Project = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
@ -26,11 +77,19 @@ const Project = () => {
|
|||||||
<div className="project__content__main">
|
<div className="project__content__main">
|
||||||
<div>
|
<div>
|
||||||
<h1 className="projects__title">Active Projects</h1>
|
<h1 className="projects__title">Active Projects</h1>
|
||||||
<WaterfallPosition columnNumber={count} list={projects.active} />
|
<WaterfallPosition
|
||||||
|
columnNumber={count}
|
||||||
|
list={projects.active}
|
||||||
|
Render={Render}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h1 className="projects__title">Retired/Inactive Projects</h1>
|
<h1 className="projects__title">Retired/Inactive Projects</h1>
|
||||||
<WaterfallPosition columnNumber={count} list={projects.inactive} />
|
<WaterfallPosition
|
||||||
|
columnNumber={count}
|
||||||
|
list={projects.inactive}
|
||||||
|
Render={Render}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* <WaterfallPositionDemo /> */}
|
{/* <WaterfallPositionDemo /> */}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import { useSize } from "ahooks";
|
import { useDebounce, useSize, useThrottleFn } from "ahooks";
|
||||||
import React, { useRef, useEffect, useState } from "react";
|
import React, { useRef, useEffect, useState } from "react";
|
||||||
import "../assets/stylesheets/waterfall.scss";
|
import "../../assets/stylesheets/waterfall.scss";
|
||||||
import { Image } from "antd";
|
|
||||||
|
|
||||||
const WaterfallItem = ({ data, onLoad }) => {
|
const WaterfallItem = ({ data, onLoad, Render }) => {
|
||||||
const ref = useRef();
|
const ref = useRef();
|
||||||
const size = useSize(ref);
|
const size = useSize(ref);
|
||||||
const sizeRef = useRef({});
|
const sizeRef = useRef({});
|
||||||
@ -12,58 +11,20 @@ const WaterfallItem = ({ data, onLoad }) => {
|
|||||||
}, [size]);
|
}, [size]);
|
||||||
return (
|
return (
|
||||||
<div className="waterfallItem" ref={ref}>
|
<div className="waterfallItem" ref={ref}>
|
||||||
<div className="project__content__main__container">
|
<Render
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "row",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<h3
|
|
||||||
style={{
|
|
||||||
fontFamily: "itrFontMedium",
|
|
||||||
fontSize: "25px",
|
|
||||||
color: "#fff",
|
|
||||||
marginBottom: 12,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{data.title}
|
|
||||||
</h3>
|
|
||||||
<h3
|
|
||||||
style={{
|
|
||||||
fontFamily: "itrFontMedium",
|
|
||||||
fontSize: "25px",
|
|
||||||
color: "#fff",
|
|
||||||
marginBottom: 12,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{data.sub}
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
<div className="project_item_content">
|
|
||||||
<Image
|
|
||||||
onLoad={() => {
|
onLoad={() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
onLoad(sizeRef.current.size);
|
onLoad(sizeRef.current.size);
|
||||||
}, 500);
|
}, 500);
|
||||||
}}
|
}}
|
||||||
onError={() =>
|
sizeRef={sizeRef}
|
||||||
setTimeout(() => {
|
data={data}
|
||||||
onLoad(sizeRef.current.size);
|
|
||||||
}, 500)
|
|
||||||
}
|
|
||||||
width={"100%"}
|
|
||||||
src={data.img}
|
|
||||||
/>
|
/>
|
||||||
<span>{data.content}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const WaterfallPosition = ({ columnNumber, list }) => {
|
const useWaterfall = ({ list, columnNumber, Render }) => {
|
||||||
const stateRef = useRef({
|
const stateRef = useRef({
|
||||||
heights: [],
|
heights: [],
|
||||||
loadNum: 0,
|
loadNum: 0,
|
||||||
@ -71,7 +32,7 @@ const WaterfallPosition = ({ columnNumber, list }) => {
|
|||||||
const onload = (index, height) => {
|
const onload = (index, height) => {
|
||||||
stateRef.current.heights[index] = height;
|
stateRef.current.heights[index] = height;
|
||||||
stateRef.current.loadNum++;
|
stateRef.current.loadNum++;
|
||||||
if (stateRef.current.loadNum === list.length) {
|
if (stateRef.current.loadNum <= list.length) {
|
||||||
onSize();
|
onSize();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -95,12 +56,29 @@ const WaterfallPosition = ({ columnNumber, list }) => {
|
|||||||
};
|
};
|
||||||
const waterfallDOM = useRef();
|
const waterfallDOM = useRef();
|
||||||
const size = useSize(waterfallDOM);
|
const size = useSize(waterfallDOM);
|
||||||
|
const { run: onSizeThrottle } = useThrottleFn(onSize, { wait: 5e2 });
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onSize();
|
onSizeThrottle();
|
||||||
}, [size, columnNumber]);
|
}, [size, columnNumber]);
|
||||||
const rendered = list.map((item, index) => (
|
const rendered = list.map((item, index) => (
|
||||||
<WaterfallItem onLoad={(size) => onload(index, size.height)} data={item} />
|
<WaterfallItem
|
||||||
|
onLoad={(size) => onload(index, size.height)}
|
||||||
|
data={item}
|
||||||
|
Render={Render}
|
||||||
|
/>
|
||||||
));
|
));
|
||||||
|
return {
|
||||||
|
waterfallDOM,
|
||||||
|
columns,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const WaterfallPosition = ({ columnNumber, list, Render }) => {
|
||||||
|
const { waterfallDOM, columns } = useWaterfall({
|
||||||
|
columnNumber,
|
||||||
|
list,
|
||||||
|
Render,
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
<div ref={waterfallDOM} className="waterfallContainer">
|
<div ref={waterfallDOM} className="waterfallContainer">
|
||||||
{columns.map((column) => {
|
{columns.map((column) => {
|
14
src/index.js
14
src/index.js
@ -8,6 +8,7 @@ import reportWebVitals from "./reportWebVitals";
|
|||||||
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
||||||
import ErrorRoute from "./routes/ErrorRoute";
|
import ErrorRoute from "./routes/ErrorRoute";
|
||||||
import GlobalStore from "./store/global";
|
import GlobalStore from "./store/global";
|
||||||
|
import GalleryRoute from "./routes/GalleryRoute";
|
||||||
|
|
||||||
const root = ReactDOM.createRoot(document.getElementById("root"));
|
const root = ReactDOM.createRoot(document.getElementById("root"));
|
||||||
|
|
||||||
@ -31,11 +32,18 @@ const router = createBrowserRouter([
|
|||||||
path: "/projects",
|
path: "/projects",
|
||||||
element: <ProjectsRoute></ProjectsRoute>,
|
element: <ProjectsRoute></ProjectsRoute>,
|
||||||
errorElement: <ErrorRoute></ErrorRoute>,
|
errorElement: <ErrorRoute></ErrorRoute>,
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
path: "/gallery",
|
||||||
|
element: <GalleryRoute></GalleryRoute>,
|
||||||
|
errorElement: <ErrorRoute></ErrorRoute>,
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
root.render(<GlobalStore.Provider>
|
root.render(
|
||||||
|
<GlobalStore.Provider>
|
||||||
<RouterProvider router={router}></RouterProvider>
|
<RouterProvider router={router}></RouterProvider>
|
||||||
</GlobalStore.Provider>);
|
</GlobalStore.Provider>
|
||||||
|
);
|
||||||
|
|
||||||
reportWebVitals();
|
reportWebVitals();
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
import AppOuter from "../components/AppOuter";
|
||||||
|
import Gallery from "../components/Gallery";
|
||||||
|
|
||||||
|
const GalleryRoute = () => {
|
||||||
|
return (
|
||||||
|
<AppOuter>
|
||||||
|
<Gallery />
|
||||||
|
</AppOuter>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default GalleryRoute;
|
Loading…
x
Reference in New Issue
Block a user