Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added lazy loading of images for both TS and JS supported components #599

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
316 changes: 239 additions & 77 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"react": "^16.8.6",
"react-alerts-component": "^1.1.0",
"react-dom": "^16.8.6",
"react-lazy-load-image-component": "1.4.1",
"react-loadable": "^5.5.0",
"react-redux": "^7.0.2",
"react-router-dom": "^4.4.0-beta.6",
Expand Down Expand Up @@ -57,6 +58,7 @@
"@types/node": "^13.7.4",
"@types/react": "^16.9.22",
"@types/react-dom": "^16.9.5",
"@types/react-lazy-load-image-component": "1.3.0",
"@types/react-redux": "^7.1.7",
"@types/react-router-dom": "5.1.3",
"@types/redux-logger": "3.0.7",
Expand Down
3 changes: 2 additions & 1 deletion src/ignitus-About/Styles/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import styled from '@emotion/styled';
import * as T from '../../ignitus-Helpers/emotion-Styles/shared';
import * as F from '../../ignitus-Helpers/emotion-Styles/font';
import {LazyLoadImage} from 'react-lazy-load-image-component';

const breakpoints: number[] = [576, 768, 992, 1200];
const mq: string[] = breakpoints.map(bp => `@media (min-width: ${bp}px)`);
Expand Down Expand Up @@ -49,7 +50,7 @@ export const PictureContainer = styled.section`
flex: 1;
`;

export const Img = styled.img`
export const Img = styled(LazyLoadImage)`
max-width: 100%;
padding: 3rem;
`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { withErrorBoundary } from '../../ignitus-Internals';
import { LazyLoadImage } from 'react-lazy-load-image-component';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute imports should come before relative imports import/first

import * as t from './Constants';
import '../Styles/style.scss';

Expand All @@ -16,14 +17,14 @@ const commonLoginUI = () => (
<div className=" col-lg-5 col-md-5 ml-lg-5 ml-md-4 col-sm-5 col p-0 h-50 common-auth-ui-css">
<p className="mb-5 text-center common-ui-text">Student</p>
<Link to="/login/student">
<img alt="Student auth" className="img-fluid" src={t.studentAuth} />
<LazyLoadImage alt="Student auth" className="img-fluid" src={t.studentAuth} />
</Link>
</div>

<div className="col-lg-5 col-md-5 ml-lg-4 ml-md-4 col-sm-5 ml-sm-4 col p-0 common-auth-ui-css">
<p className="mb-5 text-center common-ui-text">Professor</p>
<Link to="/login/professor">
<img alt="Professor auth" className="img-fluid" src={t.professorAuth} />
<LazyLoadImage alt="Professor auth" className="img-fluid" src={t.professorAuth} />
</Link>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { withErrorBoundary } from '../../ignitus-Internals';
import { LazyLoadImage } from 'react-lazy-load-image-component';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute imports should come before relative imports import/first

import * as t from './Constants';
import '../Styles/style.scss';

Expand All @@ -17,14 +18,14 @@ const commonSignUpUI = () => (
<div className="col-lg-5 col-md-5 ml-lg-5 ml-md-4 col-sm-5 col p-0 h-50 common-auth-ui-css">
<p className="mb-5 text-center common-ui-text">Student</p>
<Link to="/signup/student" className="">
<img alt="Student auth" className="img-fluid" src={t.studentAuth} />
<LazyLoadImage alt="Student auth" className="img-fluid" src={t.studentAuth} />
</Link>
</div>

<div className="col-lg-5 col-md-5 ml-lg-4 ml-md-4 col-sm-5 ml-sm-4 col p-0 common-auth-ui-css">
<p className="mb-5 text-center common-ui-text">Professor</p>
<Link to="/signup/professor" className="">
<img alt="Professor auth" className="img-fluid" src={t.professorAuth} />
<LazyLoadImage alt="Professor auth" className="img-fluid" src={t.professorAuth} />
</Link>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/ignitus-Contributors/Styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import styled from '@emotion/styled';
import * as C from '../../ignitus-Helpers/emotion-Styles/colors';
import * as T from '../../ignitus-Helpers/emotion-Styles/shared';
import {LazyLoadImage} from 'react-lazy-load-image-component';

const breakpoints: number[] = [576, 768, 992, 1200];
const mq: string[] = breakpoints.map(bp => `@media (min-width: ${bp}px)`);
Expand Down Expand Up @@ -41,7 +42,7 @@ export const Card = styled.div`
}
`;

export const CardPicture = styled.img`
export const CardPicture = styled(LazyLoadImage)`
max-width: 100%;
height: 75%;
object-fit: contain;
Expand Down
3 changes: 2 additions & 1 deletion src/ignitus-CoreTeam/Styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styled from '@emotion/styled';
import * as C from '../../ignitus-Helpers/emotion-Styles/colors';
import * as F from '../../ignitus-Helpers/emotion-Styles/font';
import * as T from '../../ignitus-Helpers/emotion-Styles/shared';
import {LazyLoadImage} from 'react-lazy-load-image-component';

type LinkWrapperProps = {
toggle: boolean;
Expand Down Expand Up @@ -54,7 +55,7 @@ export const TeamContainer = styled(T.Container)`
padding: 0 15px;
`;

export const TeamItemImg = styled.img`
export const TeamItemImg = styled(LazyLoadImage)`
border-radius: 100%;
width: 6em;
`;
Expand Down
3 changes: 2 additions & 1 deletion src/ignitus-Dashboard-Header/Components/dashBoardHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Redirect, Link } from 'react-router-dom';
import { HashLink } from 'react-router-hash-link';
import logo from '../../ignitus-Assets/Images/nav-logo.svg';
import { withErrorBoundary } from '../../ignitus-Internals';
import { LazyLoadImage } from 'react-lazy-load-image-component';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute imports should come before relative imports import/first


class dashBoardHeader extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -42,7 +43,7 @@ class dashBoardHeader extends React.Component {
<React.Fragment>
<nav className="navbar navbar-expand-lg whitenav">
<HashLink className="navbar-brand" to="/#">
<img src={logo} width="40" height="40" alt="logo" />
<LazyLoadImage src={logo} width="40" height="40" alt="logo" />
</HashLink>
<button
className="navbar-toggler"
Expand Down
3 changes: 2 additions & 1 deletion src/ignitus-Footer/Components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { HashLink } from 'react-router-hash-link';
import { Link } from 'react-router-dom';
import { withErrorBoundary } from '../../ignitus-Internals';
import { logo } from './Constants';
import { LazyLoadImage } from 'react-lazy-load-image-component';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute imports should come before relative imports import/first


const PureFooter = ({
hideUnhide, featuresToggle, communityToggle, companyToggle, linkToggle,
Expand Down Expand Up @@ -103,7 +104,7 @@ const PureFooter = ({
<div className="col-md-2 mx-auto pd-left">
<ul className="list-unstyled">
<li>
<img src={logo} className="img-responsive img-css" alt="logo" />
<LazyLoadImage src={logo} className="img-responsive img-css" alt="logo" />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expected indentation of 14 space characters but found 16 react/jsx-indent
Multiple spaces found before 'src' no-multi-spaces

</li>
</ul>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/ignitus-Helpers/emotion-Styles/shared.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import styled from '@emotion/styled';
import * as C from './colors';
import * as F from './font';
import {LazyLoadImage} from 'react-lazy-load-image-component';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A space is required after '{' object-curly-spacing
A space is required before '}' object-curly-spacing
Absolute imports should come before relative imports import/first


const breakpoints = [576, 768, 992, 1200];
const mq = breakpoints.map(bp => `@media (min-width: ${bp}px)`);
Expand Down Expand Up @@ -71,7 +72,7 @@ export const Container = styled.div`
}
`;

export const Avatar = styled.img``;
export const Avatar = styled(LazyLoadImage)``;
export const Link = styled.a``;

export const flexibleColDiv = styled.div`
Expand Down
3 changes: 2 additions & 1 deletion src/ignitus-Introduction/Components/Introduction.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Link } from 'react-router-dom';
import '../Styles/style.scss';
import { withErrorBoundary } from '../../ignitus-Internals';
import * as t from './Constants';
import { LazyLoadImage } from 'react-lazy-load-image-component';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute imports should come before relative imports import/first


const Introduction = () => (
<div className="intro__wrapper">
Expand Down Expand Up @@ -40,7 +41,7 @@ const Introduction = () => (
</button>
</Link>
</div>
<img className="img-fluid" src={t.resume} alt="resume" />
<LazyLoadImage className="img-fluid" src={t.resume} alt="resume" />
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple spaces found before 'className' no-multi-spaces

</div>
</div>

Expand Down
5 changes: 3 additions & 2 deletions src/ignitus-ProfessorSignUp/Components/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';
import { Link } from 'react-router-dom';
import * as t from './Constants';
import { withErrorBoundary } from '../../ignitus-Internals';
import { LazyLoadImage } from 'react-lazy-load-image-component';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute imports should come before relative imports import/first

import '../Styles/style.scss';

class Signup extends React.Component {
Expand All @@ -20,7 +21,7 @@ class Signup extends React.Component {
<div className="col-lg-8 container-custom p-5">
<div className="row shadow border-rad">
<div className="col-md-6 p-0 container-image">
<img className="img-fluid img-login d-block" src={t.professorAuth} alt="login" />
<LazyLoadImage className="img-fluid img-login d-block" src={t.professorAuth} alt="login" />
<div className="text-below-image text-center">
<p className="mb-5 ">Let&apos;s get started</p>
<p>Help providing opportunities for your students</p>
Expand All @@ -34,7 +35,7 @@ class Signup extends React.Component {
</div>
<div className="col-md-6 container-form">
<div className="my-4">
<img className="img-fluid img mx-auto d-block" src={t.logo} alt="logo" />
<LazyLoadImage className="img-fluid img mx-auto d-block" src={t.logo} alt="logo" />
</div>
<form>
<div className="px-4">
Expand Down
5 changes: 3 additions & 2 deletions src/ignitus-StudentSignUp/Components/Signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import isEqual from 'lodash/isEqual';
import loader from '../../ignitus-Assets/Images/loader2.gif';
import * as t from './Constants';
import { withErrorBoundary } from '../../ignitus-Internals';
import { LazyLoadImage } from 'react-lazy-load-image-component';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute imports should come before relative imports import/first


import '../Styles/style.scss';

Expand Down Expand Up @@ -70,7 +71,7 @@ const Signup = ({ signUpRequest, studentSignUpData }) => {
<div className="col-lg-8 container-custom p-5">
<div className="row shadow border-rad">
<div className="col-md-6 p-0 container-image">
<img className="img-fluid img-login d-block" src={t.studentAuth} alt="login" />
<LazyLoadImage className="img-fluid img-login d-block" src={t.studentAuth} alt="login" />
<div className="text-below-image text-center">
<p className="mb-5 ">Let&apos;s get started</p>
<p>Skyrocket your career with best global opportunities</p>
Expand All @@ -84,7 +85,7 @@ const Signup = ({ signUpRequest, studentSignUpData }) => {
</div>
<div className="col-md-6 container-form">
<div className="my-4">
<img className="img-fluid img mx-auto d-block" src={t.logo} alt="logo" />
<LazyLoadImage className="img-fluid img mx-auto d-block" src={t.logo} alt="logo" />
</div>

{success && (
Expand Down
2 changes: 1 addition & 1 deletion src/ignitus-Team/Styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const Contributors = styled.div`
`;

export const Paragraph = styled(T.Paragraph)`
text-align: center;Ì
text-align: center;
`;

export const Link = styled(T.Link)`
Expand Down
3 changes: 2 additions & 1 deletion src/ignitus-WhatWeDo/Styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import styled from '@emotion/styled';
import * as C from '../../ignitus-Helpers/emotion-Styles/colors';
import * as F from '../../ignitus-Helpers/emotion-Styles/font';
import { LazyLoadImage } from 'react-lazy-load-image-component';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolute imports should come before relative imports import/first


const breakpoints = [576, 768, 992, 1200];
const mq = breakpoints.map(bp => `@media (min-width: ${bp}px)`);
Expand Down Expand Up @@ -36,7 +37,7 @@ export const Card = styled.div`
}
`;

export const CardPicture = styled.img`
export const CardPicture = styled(LazyLoadImage)`
max-width: 100%;
height: 75%;
object-fit: contain;
Expand Down