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

Develop #177

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
617 changes: 559 additions & 58 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,26 @@
"license": "GPL-3.0",
"dependencies": {
"@cypress/react": "^5.12.4",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
"@fortawesome/react-fontawesome": "^0.2.0",
"@mui/material": "^5.13.4",
"@uidotdev/usehooks": "^2.0.1",
"bulma": "^0.9.3",
"classnames": "^2.3.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^6.10.0",
"react-scripts": "^4.0.3"
},
"devDependencies": {
"@cypress/webpack-dev-server": "^1.8.4",
"@mate-academy/cypress-tools": "^1.0.4",
"@mate-academy/eslint-config-react": "*",
"@mate-academy/eslint-config-react-typescript": "*",
"@mate-academy/scripts": "^1.2.1",
"@mate-academy/scripts": "^1.2.8",
"@mate-academy/students-ts-config": "*",
"@mate-academy/stylelint-config": "*",
"@types/node": "^17.0.23",
Expand Down
18 changes: 18 additions & 0 deletions public/img/products/Cart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/img/products/Home.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/products/Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/products/accessories-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/img/products/arrow-top.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/products/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/img/products/favourites-added.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions public/img/products/favourites.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/products/image-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/products/phone-catalog-home.zip
Binary file not shown.
Binary file added public/img/products/phones-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/products/tablets-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Phone catalog</title>
<link rel="icon" type="image/x-icon" href="/img/products/favicon.png">
</head>
<body>
<div id="root"></div>
Expand Down
119 changes: 118 additions & 1 deletion src/App.scss
Original file line number Diff line number Diff line change
@@ -1 +1,118 @@
// not empty
@import url(https://fonts.googleapis.com/css?family=Montserrat:regular,500,600,700,800,900);

* {
padding: 0;
margin: 0;
border: 0;
}

*,
*:before,
*:after {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

::-webkit-scrollbar {
width: 12px;
}

::-webkit-scrollbar-thumb {
background-color: #c1c1c1;
}

:focus,
:active {
outline: none;
}

::-webkit-scrollbar:hover {
background-color: #f5f5f5;
}

::-webkit-scrollbar-thumb:hover {
background-color: #a0a0a0;
}

a,
a:visited {
text-decoration: none;
color: inherit;
}

a:focus,
a:active {
outline: none;
}

a:hover {
text-decoration: none;
cursor: pointer;
}

nav,
footer,
header,
aside {
display: block;
}

html,
body {
height: 100%;
width: 100%;
line-height: 1;
font-size: 18px;
font-family: "Montserrat", sans-serif;
-ms-text-size-adjust: 100%;
-moz-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}

input,
button,
textarea {
font-family: inherit;
}

input::-ms-clear {
display: none;
}

button {
cursor: pointer;
}

button::-moz-focus-inner {
padding: 0;
border: 0;
}

ul li {
list-style: none;
}

img {
vertical-align: top;
}

h1,
h2,
h3,
h4,
h5,
h6 {
font-size: inherit;
font-weight: 400;
}

main {
flex: 1 1 auto;
}

.wrapper {
display: flex;
flex-direction: column;
margin: 0 auto;
min-height: 100vh;
}
96 changes: 91 additions & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,95 @@
import { useState, useEffect } from 'react';
import { Navigate, Route, Routes } from 'react-router-dom';
import { Footer } from './components/Footer/Footer';
import { Header } from './components/Header/Header';
import { Homepage } from './components/Homepage/Homepage';
import {
ProductDetailsPage,
} from './components/ProductDetailsPage/ProductDetailsPage';
import { API_URL, getProducts } from './helpers/helper';
import { Product } from './types/Products';
import './App.scss';
import { Favoutires } from './components/Favourites/Favourites';
import { Cart } from './components/Cart/Cart';
import {
ProductDataContext,
} from './components/ProductDataContext/ProductDataContext';
import { ScrollToTop } from './helpers/ScrollToTop';
import { PhonesPage } from './components/ProductPage/PhonesPage/PhonesPage';
import { TabletsPage } from './components/ProductPage/TabletsPage/TabletsPage';
import {
AccessoriesPage,
} from './components/ProductPage/AccessoriesPage/AccessoriesPage';
import { NotFound } from './components/NotFound/NotFound';

const App = () => (
<div className="App">
<h1>React Phone Catalog</h1>
</div>
);
const App = () => {
const [products, setProducts] = useState<Product[]>([]);

useEffect(() => {
async function fetchData() {
try {
const response = await getProducts(API_URL);

setProducts(response);
} catch (fetchError) {
throw new Error('Data could not be fetched');
}
}

fetchData();
}, []);

return (
<div className="App">
<ScrollToTop />
<div className="wrapper">
<Header />
<ProductDataContext.Provider value={products}>
<Routes>
<Route
path="/"
element={<Homepage products={products} />}
/>
<Route path="phones">
<Route index element={<PhonesPage />} />
<Route
path=":productId"
element={<ProductDetailsPage products={products} />}
/>
</Route>
<Route path="tablets">
<Route index element={<TabletsPage />} />
<Route
path=":productId"
element={<ProductDetailsPage products={products} />}
/>
</Route>
<Route path="accessories">
<Route index element={<AccessoriesPage />} />
<Route
path=":productId"
element={<ProductDetailsPage products={products} />}
/>
</Route>
<Route
path="favourites"
element={<Favoutires />}
/>
<Route
path="cart"
element={<Cart />}
/>
<Route path="*" element={<NotFound />} />
<Route
path="home"
element={<Navigate to="/" replace />}
/>
</Routes>
</ProductDataContext.Provider>
<Footer />
</div>
</div>
);
};

export default App;
27 changes: 27 additions & 0 deletions src/components/BackToPage/BackToPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import { useNavigate } from 'react-router-dom';

export const BackToPage: React.FC = () => {
const navigate = useNavigate();

return (
<div className="product-info__back back-to-page">
<button
type="button"
onClick={() => navigate(-1)}
className="back-to-page__link"
data-cy="backButton"
>
&lt;
</button>
<button
type="button"
onClick={() => navigate(-1)}
className="back-to-page__link"
data-cy="backButton"
>
Back
</button>
</div>
);
};
Loading