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

Phone catalog app #216

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c0464ad
doesnt show anything
ValeraViachalo Sep 6, 2023
4fb11f3
swiper issue
ValeraViachalo Sep 6, 2023
bf1a221
Home page and started phones page
ValeraViachalo Sep 11, 2023
a2eaf35
.
ValeraViachalo Sep 11, 2023
0d0e9c7
catalog app
ValeraViachalo Sep 14, 2023
85ce65b
fav icon added
ValeraViachalo Sep 14, 2023
8fb1b54
some improvements
ValeraViachalo Sep 15, 2023
ab7c942
.
ValeraViachalo Sep 15, 2023
048069c
some UI improvments
ValeraViachalo Sep 17, 2023
6a9f7b5
.
ValeraViachalo Sep 17, 2023
f43a9e7
improved hover problem
ValeraViachalo Sep 17, 2023
07da831
solved footer problem
ValeraViachalo Sep 18, 2023
5171853
card smooth hover
ValeraViachalo Sep 18, 2023
654c909
.
ValeraViachalo Sep 18, 2023
79b604a
card smooth hover(try 2)
ValeraViachalo Sep 18, 2023
e39d1cf
card smooth hover(try 3)
ValeraViachalo Sep 18, 2023
e7da55c
.
ValeraViachalo Sep 18, 2023
e9d4984
improved product page and pagination
ValeraViachalo Sep 19, 2023
724bb6f
created response
ValeraViachalo Sep 20, 2023
0d12f5b
improved response and fixed swiper
ValeraViachalo Sep 21, 2023
9c41092
litle impovments
ValeraViachalo Sep 21, 2023
b629fc5
swiper issue solve (try 1)
ValeraViachalo Sep 21, 2023
3dfdfce
.
ValeraViachalo Sep 21, 2023
a41f226
some style imporments
ValeraViachalo Sep 21, 2023
b27edb8
carousel improved
ValeraViachalo Sep 22, 2023
80f9fc5
some improvements
ValeraViachalo Oct 9, 2023
88deb57
.
ValeraViachalo Oct 9, 2023
ab7f151
added function for pagination to up
ValeraViachalo Oct 9, 2023
555e55e
fixed all filter
ValeraViachalo Oct 10, 2023
6e6d1f3
transition on galery
ValeraViachalo Oct 10, 2023
ecf1595
added some animations
ValeraViachalo Oct 11, 2023
f2af603
.
ValeraViachalo Oct 11, 2023
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
246 changes: 188 additions & 58 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,27 @@
"license": "GPL-3.0",
"dependencies": {
"@cypress/react": "^5.12.4",
"@reduxjs/toolkit": "^1.9.5",
"@uiball/loaders": "^1.3.0",
"bulma": "^0.9.3",
"classnames": "^2.3.2",
"lodash": "^4.17.21",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "^4.0.3"
"react-redux": "^8.1.2",
"react-router-dom": "^6.15.0",
"react-scripts": "^4.0.3",
"swiper": "^9.4.1"
},
"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/lodash": "^4.14.197",
"@types/node": "^17.0.23",
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
Expand Down
Binary file added public/img/fav-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Phone catalog</title>
<link rel="shortcut icon" href="./img/fav-icon.png" type="image/x-icon">
</head>
<body>
<div id="root"></div>
<script src="https://cdn.jsdelivr.net/npm/swiper@10/swiper-bundle.min.js"></script>
</body>
</html>
14 changes: 13 additions & 1 deletion src/App.scss
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
// not empty
@import "styles/global-imports";

.app {
min-height: 100vh;
display: flex;
flex-direction: column;

&__section {
flex: 1 0 auto;
display: flex;
flex-direction: column;
}
}
71 changes: 69 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,75 @@
import { Navigate, Route, Routes } from 'react-router-dom';
import './App.scss';

import { Header } from './components/Header';
import { HomePage } from './pages/HomePage';
import { Footer } from './components/Footer';
import { PhonesPage } from './pages/PhonesPage';
import { TabletPage } from './pages/TabletsPage/TabletsPage';
import { AccessoriesPage } from './pages/AccessoriesPage/AccessoriesPage';
import { ProductDetailsPage } from './pages/ProductDetailsPage';
import { CartPage } from './pages/CartPage/CartPage';
import { FavoritesPage } from './pages/FavoritesPage/FavoritesPage';
import { PageNotFound } from './pages/PageNotFound/PageNotFound';

const App = () => (
<div className="App">
<h1>React Phone Catalog</h1>
<div className="app">
<Header />

<section className="app__section">
<div className="app__content">
<Routes>
<Route path="/" element={<HomePage />} />
<Route path="home" element={<Navigate to="/" replace />} />

<Route path="phones">
<Route index element={<PhonesPage />} />

<Route
path=":productId"
element={<ProductDetailsPage />}
/>
</Route>

<Route path="tablets">
<Route index element={<TabletPage />} />

<Route
path=":productId"
element={<ProductDetailsPage />}
/>
</Route>

<Route path="accessories">
<Route index element={<AccessoriesPage />} />

<Route
path=":productId"
element={<ProductDetailsPage />}
/>
</Route>

<Route
path="favourites"
element={<FavoritesPage />}
/>

<Route
path="cart"
element={<CartPage />}
/>

<Route
path="*"
element={<PageNotFound />}
/>
</Routes>
</div>
</section>

<div className="app__footer">
<Footer />
</div>
</div>
);

Expand Down
19 changes: 19 additions & 0 deletions src/components/Button/ButtonBack/ButtonBack.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@import "../../../styles/global-imports";

.button-back {
display: flex;
gap: 6px;

margin: 40px 0 16px;
background-color: $c-white;

@extend %small-text;
color: $c-secondary;

&--arrow {
width: 16px;
height: 16px;
background: url("../../../images/icons/Arrow.svg") no-repeat center;
transform: rotate(180deg);
}
}
18 changes: 18 additions & 0 deletions src/components/Button/ButtonBack/ButtonBack.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import './ButtonBack.scss';

export const ButtonBack = () => {
const handleGoBack = () => (
window.history.back()
);

return (
<button
type="button"
className="button-back"
onClick={handleGoBack}
>
<div className="button-back--arrow" />
Back
</button>
);
};
28 changes: 28 additions & 0 deletions src/components/Button/ButtonCart/ButtonCart.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@import "../../../styles/global-imports";

.button-cart {
width: 100%;
height: 40px;

display: flex;
align-items: center;
justify-content: center;

color: $c-white;
background-color: $c-primary;
border: 1px solid $c-primary;

@extend %body-text;

&:not(.button-cart--added) {
@include hover(border-color, $c-elements);
}

&--added {
color: $c-green;
background-color: $c-white;

@include hover(border-color, $c-primary);

}
}
49 changes: 49 additions & 0 deletions src/components/Button/ButtonCart/ButtonCart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { useContext } from 'react';

import classNames from 'classnames';
import './ButtonCart.scss';

import { Product } from '../../../types/Product';
import { CartContext } from '../../../contexts/CartContextProvider';

type Props = {
product: Product,
};

export const ButtonCart: React.FC<Props> = ({ product }) => {
const {
cart,
addToCart,
removeFromCart,
} = useContext(CartContext);

const isAdded = cart.find(currentItem => (
currentItem.product.phoneId === product.phoneId));

const handleAddCart = () => {
if (isAdded) {
removeFromCart(product.phoneId);
} else {
const cartItem = {
id: product.phoneId,
quantity: 1,
product,
};

addToCart(cartItem);
}
};

return (
<button
type="button"
onClick={handleAddCart}
className={classNames(
'button-cart',
{ 'button-cart--added': isAdded },
)}
>
{isAdded ? 'Added to cart' : 'Add to cart'}
</button>
);
};
1 change: 1 addition & 0 deletions src/components/Button/ButtonCart/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ButtonCart';
16 changes: 16 additions & 0 deletions src/components/Button/ButtonFavorites/ButtonFavorites.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@import "../../../styles/global-imports";

.button-favorites {
width: 40px;
height: 40px;

background: url("../../../images/icons/icon-favourites.svg") no-repeat center;

border: 1px solid $c-icons;

@include hover(border-color, $c-primary);

&-active {
background-image: url("../../../images/icons/icon-favourites-active.svg");
}
}
41 changes: 41 additions & 0 deletions src/components/Button/ButtonFavorites/ButtonFavorites.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint-disable jsx-a11y/control-has-associated-label */
import { useContext } from 'react';

import classNames from 'classnames';
import './ButtonFavorites.scss';

import { FavoriteContext } from '../../../contexts/FavoriteContextProvider';
import { Product } from '../../../types/Product';

type Props = {
product: Product;
};

export const ButtonFavorites: React.FC<Props> = ({ product }) => {
const {
favorites,
addToFavorite,
removeFromFavorite,
} = useContext(FavoriteContext);

const isAdded = favorites.find(({ phoneId }) => phoneId === product.phoneId);

const handleAddFavorites = () => {
if (isAdded) {
removeFromFavorite(product.phoneId);
} else {
addToFavorite(product);
}
};

return (
<button
type="button"
onClick={handleAddFavorites}
className={classNames(
'button-favorites',
{ 'button-favorites-active': isAdded },
)}
/>
);
};
1 change: 1 addition & 0 deletions src/components/Button/ButtonFavorites/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ButtonFavorites';
21 changes: 21 additions & 0 deletions src/components/Button/ButtonToUp/ButtonToUp.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@import "../../../styles/global-imports";

.button-to-up {
background-color: $c-white;
color: $c-secondary;
@extend %small-text;

display: flex;
align-items: center;

&--arrow {
margin-left: 16px;
height: 32px;
width: 32px;
border: 1px solid $c-icons;

transform: rotate(-90deg);

background: url("../../../images/icons/Arrow.svg") no-repeat center;
}
}
21 changes: 21 additions & 0 deletions src/components/Button/ButtonToUp/ButtonToUp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import './ButtonToUp.scss';

export const ButtonToUp = () => {
const handleBackToTop = () => {
window.scrollTo({
top: 0,
behavior: 'smooth',
});
};

return (
<button
className="button-to-up"
type="button"
onClick={handleBackToTop}
>
Back to top
<div className="button-to-up--arrow" />
</button>
);
};
1 change: 1 addition & 0 deletions src/components/Button/ButtonToUp/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ButtonToUp';
Loading
Loading