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

UI components #11

Merged
merged 1 commit into from
Mar 10, 2021
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

#environment variable
.env
19,554 changes: 19,554 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

41 changes: 36 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,40 @@
{
"name": "imagematch",
"name": "frontend-demo",
Copy link
Member

Choose a reason for hiding this comment

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

This must name of the project and not the purpose of a demonstration.

"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.10.1",
"react-dom": "^16.10.1",
"react-scripts": "3.1.2"
"@patternfly/react-core": "^3.129.3",
Copy link
Member

@rabajaj0509 rabajaj0509 Feb 4, 2021

Choose a reason for hiding this comment

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

Are we not using pattern fly 4? pf3 has flaws and all projects that are being developed at current time have moved to pf4. Its better you do all your development in pf4.

"@patternfly/react-topology": "^2.14.66",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"activestorage": "^5.2.4-1",
"axios": "^0.19.1",
"bootstrap": "^4.4.1",
"dotenv": "^8.2.0",
"react": "^16.12.0",
"react-bootstrap": "^1.0.1",
"react-dom": "^16.12.0",
"react-hook-form": "^6.0.8",
"react-image": "^2.2.2",
"react-image-mapper": "^0.0.15",
"react-js-pagination": "^3.0.3",
"react-lazy-load-image-component": "^1.5.0-beta.0",
"react-lazyload": "^2.6.7",
"react-modal": "^3.11.2",
"react-multiselect-checkboxes": "^0.1.1",
"react-paginate": "^6.3.2",
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"storybook": "start-storybook -p 9009 -s public",
"build-storybook": "build-storybook -s public"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -27,5 +50,13 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@storybook/addon-actions": "^5.3.8",
"@storybook/addon-links": "^5.3.8",
"@storybook/addons": "^5.3.8",
"@storybook/preset-create-react-app": "^1.5.2",
"@storybook/react": "^5.3.8",
"eslint-plugin-react-hooks": "^4.0.8"
Copy link
Member

Choose a reason for hiding this comment

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

Are we making of the eslint, because I see many syntax error that lint would not allow before merging.

}
}
2 changes: 2 additions & 0 deletions src/API/BASE_URL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const BASE_URL = process.env.REACT_APP_BASE_URL;
export default BASE_URL;
22 changes: 0 additions & 22 deletions src/App.css

This file was deleted.

45 changes: 23 additions & 22 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import { Route, Switch, BrowserRouter } from "react-router-dom";
import "@patternfly/react-core/dist/styles/base.css";
import { PageHeader, Page } from "@patternfly/react-core";
import React from "react";
import Products from "./Screens/Products"
import Versions from "./Screens/Versions";

function App() {
export default function PageLayoutSimpleNav() {
const logoProps = {
href: "https://github.com/lingostack",
target: "_blank",
};
return (
Comment on lines +9 to 13
Copy link
Member

Choose a reason for hiding this comment

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

There is no prop validation for this?

<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
<BrowserRouter>
<Switch>
<Page
header={<PageHeader logo={"LingoQA Dashboard"} logoProps={logoProps} />}>
<Route exact path="/" component={Products} />
<Route
path="/products/:productid/screenshots"
component={Versions}
/>
</Page>
</Switch>
</BrowserRouter>
);
}

export default App;
9 changes: 0 additions & 9 deletions src/App.test.js

This file was deleted.

23 changes: 23 additions & 0 deletions src/Components/Breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from "react";
import { Link } from 'react-router-dom';
import { AngleRightIcon } from '@patternfly/react-icons'

export default function Breadcrumbs() {
return (
<nav className="pf-c-breadcrumb" aria-label="breadcrumb">
<ol className="pf-c-breadcrumb__list">
<li className="pf-c-breadcrumb__item">
<Link to="/" className="pf-c-breadcrumb__link">Products</Link>
<span className="pf-c-breadcrumb__item-divider">
<AngleRightIcon />
</span>
</li>
<li className="pf-c-breadcrumb__item">
<span className="pf-c-breadcrumb__link pf-m-current" aria-current="page">
Versions
</span>
</li>
</ol>
</nav>
Comment on lines +7 to +21
Copy link
Member

@rabajaj0509 rabajaj0509 Feb 4, 2021

Choose a reason for hiding this comment

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

This is ugly, in pf4 you can do something like:

import React from 'react';
import { Breadcrumb, BreadcrumbItem, BreadcrumbHeading } from '@patternfly/react-core';

SimpleBreadcrumbs = () => (
  <Breadcrumb>
    <BreadcrumbItem to="#">Section home</BreadcrumbItem>
    <BreadcrumbItem to="#">Section title</BreadcrumbItem>
    <BreadcrumbItem to="#">Section title</BreadcrumbItem>
    <BreadcrumbItem to="#" isActive>
      Section Landing
    </BreadcrumbItem>
  </Breadcrumb>
);

Copy link
Contributor

Choose a reason for hiding this comment

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

@rabajaj0509 Yes, we can do this now.
When we started working on this app at that time the patternfly didn't implement the react-router with the breadcrumb and used product anchor tag with it and that was the reason we had to hardcode the breadcrumb component.

)
}
181 changes: 181 additions & 0 deletions src/Components/Paginate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
import React, { useState } from "react";
import { Split, SplitItem } from "@patternfly/react-core";
import { Pagination, PaginationVariant } from "@patternfly/react-core";
import SimpleEmptyState from "./SimpleEmptyState";

export default function Paginate(props) {
const [screenshotsOther, setScreenshotsOther] = useState([]);
const [screenshotsEN, setScreenshotsEN] = useState([]);
const [itemCount, setItemCount] = useState();
const [elementsRight, setElementRight] = useState([]);
const [elementsLeft, setElementLeft] = useState([]);
const [offset, setOffset] = useState();
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(10);

//Set the page
const onSetPage = (_event, pageNumber) => {
setPage(pageNumber)
};

//Items to be displayed per page
const onPerPageSelect = (_event, perPage) => {
setPerPage(perPage)
};

//Next set of Items
const onNextClick = (_event, page) => {
setPage(page)
setOffset((page - 1) * (perPage))
};

//Previous set of Items
const onPreviousClick = (_event, page) => {
setPage(page)
setOffset((page - 1) * (perPage));
};

//First set of Items
const onFirstClick = (_event, page) => {
setPage(page)
setOffset(0)
};

//Last set of items
const onLastClick = (_event, page) => {
setPage(page)
setOffset((page - 1) * (perPage));
};

React.useEffect(() => {
setScreenshotsOther(props.screenshotsOther);
setScreenshotsEN(props.screenshotsEN);
setItemCount(props.itemCount);
setOffset(0);
}, [props.screenshotsEN, props.screenshotsOther, props.itemCount]);

React.useEffect(() => {
const SetImages = () => {
if (props.screenshotsEN.length !== 0) {
const elementsLeft = props.screenshotsEN[0].images.slice(offset, (offset + perPage));
setElementLeft(elementsLeft)
}
if (props.screenshotsOther.length !== 0) {
const elementsRight = props.screenshotsOther[0].images.slice(offset, (offset + perPage));
setElementRight(elementsRight)
}
}
SetImages();
}, [offset, perPage, screenshotsEN, screenshotsOther])

const paginateEN = () => (
<>
<Pagination
widgetId="pagination-options-menu-bottom"
itemCount={itemCount}
perPage={perPage}
page={page}
variant={PaginationVariant.bottom}
onSetPage={onSetPage}
onPerPageSelect={onPerPageSelect}
onNextClick={onNextClick}
onPreviousClick={onPreviousClick}
onFirstClick={onFirstClick}
onLastClick={onLastClick}
/>
<div className="en_screens mb-4">
{elementsLeft.map((image, index) => (
<img src={image} alt="" key={index} className="image" />
))}
</div>
<Pagination
widgetId="pagination-options-menu-bottom"
itemCount={itemCount}
perPage={perPage}
page={page}
variant={PaginationVariant.bottom}
onSetPage={onSetPage}
onPerPageSelect={onPerPageSelect}
onNextClick={onNextClick}
onPreviousClick={onPreviousClick}
onFirstClick={onFirstClick}
onLastClick={onLastClick}
/>
</>
)

const paginateOther = () => (
<>
<Pagination
widgetId="pagination-options-menu-bottom"
itemCount={itemCount}
perPage={perPage}
page={page}
variant={PaginationVariant.bottom}
onSetPage={onSetPage}
onPerPageSelect={onPerPageSelect}
onNextClick={onNextClick}
onPreviousClick={onPreviousClick}
onFirstClick={onFirstClick}
onLastClick={onLastClick}
/>
{/* For screenshots display side by side */}
<div id="image-compare">
<Split gutter="md">
<div>
{elementsLeft.length &&
<SplitItem>
<div>
{elementsLeft.map((image, index) => (
<img src={image} alt="" key={index} className="image" />
))}
</div>
</SplitItem>

}
</div>
<div>
{elementsRight.length &&
<SplitItem>
<div>
{elementsRight.map((image, index) => (
<img src={image} alt="" key={index} className="image" />
))}
</div>
</SplitItem>
}
</div>
</Split>
</div>
<Pagination
widgetId="pagination-options-menu-bottom"
itemCount={itemCount}
perPage={perPage}
page={page}
variant={PaginationVariant.bottom}
onSetPage={onSetPage}
onPerPageSelect={onPerPageSelect}
onNextClick={onNextClick}
onPreviousClick={onPreviousClick}
onFirstClick={onFirstClick}
onLastClick={onLastClick}
/>
</>
)

if (props.screenshotsEN.length === 0) {
return <SimpleEmptyState />;
}
else if ((typeof itemCount !== "undefined") && (props.screenshotsOther.length === 0)) {
return <div className="mb-4">{paginateEN()}</div>;
}
else if ((typeof itemCount !== "undefined") && (props.screenshotsOther[0].id === props.screenshotsEN[0].id)) {
return <div className="mb-4">{paginateEN()}</div>;
}
else {
if (typeof itemCount !== "undefined")
return <div className="mb-4">{paginateOther()}</div>
else
return null
}
}
Loading