Skip to content

Commit

Permalink
added lazy loading
Browse files Browse the repository at this point in the history
  • Loading branch information
MeridjaNassim committed Mar 13, 2020
1 parent 16a8012 commit 33b1fd6
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 12 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-helmet": "^5.2.1",
"react-lazyload": "^2.6.5",
"styled-components": "^5.0.1"
},
"devDependencies": {
Expand Down
12 changes: 12 additions & 0 deletions src/components/Loading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react"
import styled from "styled-components"
import spinner from "../images/loading.gif"
export default function Loading() {
return (
<Loader>
<img src={spinner} alt="loading..."></img>
</Loader>
)
}

const Loader = styled.div``
12 changes: 9 additions & 3 deletions src/components/Mains/MainHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Button from "../Button"
import Record from "../Record"
import { Link } from "gatsby"
import theme from "../../constants/theme.json"
import Loading from "../../components/Loading"
import LazyLoad from "react-lazyload"
/// pictures :
import homeHead from "../../images/super_woman.svg"
import homeAbout from "../../images/logo.svg"
Expand All @@ -16,10 +18,10 @@ import marker from "../../images/icons/marker.svg"
import event from "../../images/icons/event_icon.svg"
import EditionCard from "../../components/editionCard"
import ReverseEditionCard from "../../components/ReverseEditionCard"
import yassir from "../../images/partners/yassir-seeklogo.com.svg"
import techno from "../../images/partners/techno.png"
import soc from "../../images/partners/societe.png"
import sai from "../../images/partners/schoolai.png"

export default function MainHome() {
return (
<Wrapper>
Expand Down Expand Up @@ -52,10 +54,14 @@ export default function MainHome() {
Register
</Button>
</Content>
<CustomImg src={homeHead} alt="Landing image"></CustomImg>
<LazyLoad key="mainhead" placeholder={<Loading></Loading>}>
<CustomImg src={homeHead} alt="Landing image"></CustomImg>
</LazyLoad>
</Section>
<Section2>
<CustomImg2 src={homeAbout} alt="Event Logo"></CustomImg2>
<LazyLoad key="eventlogo" placeholder={<Loading></Loading>}>
<CustomImg2 src={homeAbout} alt="Event Logo"></CustomImg2>
</LazyLoad>
<Content>
<h5>ABOUT THE EVENT</h5>
<Title>International Women's Day 2020</Title>
Expand Down
8 changes: 6 additions & 2 deletions src/components/Track.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import React from "react"
import styled from "styled-components"

import Loading from "../components/Loading"
import LazyLoad from "react-lazyload"
export default function Track({ imgsource, altimg, title, content }) {
return (
<Container>
<Logo src={imgsource} alt={altimg}></Logo>
<LazyLoad key={altimg} placeholder={<Loading></Loading>}>
<Logo src={imgsource} alt={altimg}></Logo>
</LazyLoad>

<Content>
<h3>{title}</h3>
<p>{content}</p>
Expand Down
7 changes: 5 additions & 2 deletions src/components/speakerCard.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react"
import { Link } from "gatsby"
import Loading from "../components/Loading"
import LazyLoad from "react-lazyload"
import styled from "styled-components"
import theme from "../constants/theme.json"
const StyltedCArd = styled.div`
Expand Down Expand Up @@ -124,7 +125,9 @@ const SpeakerCard = ({
*/}

<ProfilePic>
<img src={picture} alt="profiles" />
<LazyLoad key={name} placeholder={<Loading></Loading>}>
<img src={picture} alt="profiles" />
</LazyLoad>
</ProfilePic>
<h1> {name} </h1>
<h2> {role} </h2>
Expand Down
6 changes: 3 additions & 3 deletions src/content/talks/talks.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
"title": "Zoom in modern web/mobile development",
"content": "The shape of web and mobile apps development have been and still changing in a non-stop manner, but nowadays almost all major dev options have implemented a set of common key concepts influenced by the huge advancements around the web dev ecosystem.",
"img": "dev.svg",
"alt": "talk"
"alt": "mobileDev"
},

{
"title": "How AI and Big Data are shaping our world view",
"content": "Should you trust your own opinions? In this talk Hichem Bouzara will explain the process through which Artificial Intelligence algorithms relying on Big Data are effectively shaping our points of view without us knowing it.",
"img": "bigdata.svg",
"alt": "talk"
"alt": "AI"
},
{
"title": "How to design Human - Centered AI Products ? ",
"content": "confused with development of ai products ? don't know where to start ? this talk will help you get a clearer vision about it and guide you through the process of designing human centered ai product",
"img": "designAI.svg",
"alt": "talk"
"alt": "AI2"
}
]
6 changes: 5 additions & 1 deletion src/pages/about.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React from "react"
import Loading from "../components/Loading"
import LazyLoad from "react-lazyload"
import Layout from "../components/layout/layout"
import SEO from "../components/seo"
import styled from "styled-components"
Expand Down Expand Up @@ -281,7 +283,9 @@ export default function about() {
</StyleadHead>
<DetailContent>
<ImgContainer>
<img src={require("../images/super_woman.svg")} alt="about IWD" />
<LazyLoad key="super_woman" placeholder={<Loading></Loading>}>
<img src={require("../images/super_woman.svg")} alt="about IWD" />
</LazyLoad>
</ImgContainer>
<Content>
<h5>ABOUT THE EVENT</h5>
Expand Down
6 changes: 5 additions & 1 deletion src/pages/agenda.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import SEO from "../components/seo"
import styled from "styled-components"
import theme from "../constants/theme.json"
import { MainWrapper as Wrapper } from "../components/Container"
import Loading from "../components/Loading"
import LazyLoad from "react-lazyload"
import agendapic from "../images/agenda-svg.svg"
// TODO : Implement Page
// TODO : Add Agenda to the page ( the actual agenda)
Expand Down Expand Up @@ -33,7 +35,9 @@ export default function agenda() {
<Layout>
<SEO title="Agenda"></SEO>
<Wrapper>
<Agenda src={agendapic} alt="agenda of event"></Agenda>
<LazyLoad key="agenda" placeholder={<Loading></Loading>}>
<Agenda src={agendapic} alt="agenda of event"></Agenda>
</LazyLoad>
</Wrapper>
</Layout>
)
Expand Down

0 comments on commit 33b1fd6

Please sign in to comment.