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

[FIX] #157 Implemented 'Buy Now' & 'Add to Cart' Buttons #166

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"react": "^18.2.0",
"react-bootstrap": "^2.10.0",
"react-dom": "^18.2.0",
"react-icons": "^5.2.1",
"react-hook-form": "^7.51.4",
"react-icons": "^5.2.1",
"react-image-zoom": "^1.3.1",
"react-inner-image-zoom": "^3.0.2",
"react-lazy-load-image-component": "^1.6.0",
Expand Down
40 changes: 40 additions & 0 deletions src/components/Buttons/buttons.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* src/components/buttons.css */
Copy link
Owner

Choose a reason for hiding this comment

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

CSS classes should be in hierarchical structure

.button-container {
display: flex;
gap: 10px;
}

.buy-now-button, .add-to-cart-button {
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
}

.buy-now-button {
background-color: #ff5722;
color: white;
}

.buy-now-button:hover {
background-color: #e64a19;
}

.add-to-cart-button {
background-color: #009688;
color: white;
display: flex;
align-items: center;
gap: 5px;
}

.add-to-cart-button:hover {
background-color: #00796b;
}

.cart-icon {
font-size: 18px;
}

16 changes: 16 additions & 0 deletions src/components/Buttons/buttons.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { FaShoppingCart } from 'react-icons/fa';
import './buttons.css';

const Buttons = () => {
return (
<div className="button-container">
<button className="buy-now-button">Buy Now</button>
<button className="add-to-cart-button">
<FaShoppingCart className="cart-icon" /> Add to Cart
</button>
</div>
);
};

export default Buttons;
11 changes: 8 additions & 3 deletions src/pages/Home/TopProducts/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// src/components/TopProducts.jsx
import React from 'react';
import './style.css';

Expand All @@ -6,6 +7,7 @@ import img2 from '../../../assets/images/thumbnail-1.webp';
import img3 from '../../../assets/images/thumbnail-1.webp';
import { Link } from 'react-router-dom';
import Rating from '@mui/material/Rating';
import Buttons from '../../../components/Buttons/buttons';

const TopProducts = (props) => {
return (
Expand All @@ -16,7 +18,7 @@ const TopProducts = (props) => {
<div className="items d-flex align-items-center">
<div className="img">
<Link to="">
<img src={img1} className="w-100" />
<img src={img1} className="w-100" alt="Product 1" />
</Link>
</div>

Expand All @@ -34,13 +36,14 @@ const TopProducts = (props) => {
<span className="price text-g font-weight-bold">$28.85</span>{' '}
<span className="oldPrice">$32.8</span>
</div>
<Buttons /> {/* Add the Buttons component here */}
</div>
</div>

<div className="items d-flex align-items-center">
<div className="img">
<Link to="">
<img src={img1} className="w-100" />
<img src={img1} className="w-100" alt="Product 2" />
</Link>
</div>

Expand All @@ -58,13 +61,14 @@ const TopProducts = (props) => {
<span className="price text-g font-weight-bold">$28.85</span>{' '}
<span className="oldPrice">$32.8</span>
</div>
<Buttons /> {/* Add the Buttons component here */}
</div>
</div>

<div className="items d-flex align-items-center">
<div className="img">
<Link to="">
<img src={img1} className="w-100" />
<img src={img1} className="w-100" alt="Product 3" />
</Link>
</div>

Expand All @@ -82,6 +86,7 @@ const TopProducts = (props) => {
<span className="price text-g font-weight-bold">$28.85</span>{' '}
<span className="oldPrice">$32.8</span>
</div>
<Buttons /> {/* Add the Buttons component here */}
</div>
</div>
</div>
Expand Down