22 Oct 2024 Start Reactjs Project-1
22 Oct 2024 Start Reactjs Project-1
step1 src/App.js
function App() {
return (
<div> welcome</div>
)
}
step2
npm start
step3
https://www.npmjs.com/package/react-router-dom
npm i react-router-dom
step4 terminal
function Home() {
return (
<div>welcome Home Page</div>
)
}
step6 App.js
</Router>
)
}
step7 terminal
npm start
***************************6 Nov
2024********************************************************
step1 package.json
npm i react-bootstrap
npm i react-dom
npm i react-router-bootstrap
npm i react-router-dom
***************************7 Nov
2024*******************************************************
step1frontend/src/components/HeroSection.js
return(
<div className="hero-section">
<Container>
<Row className="align-items-center">
<Col md={6}>
<h1>sarso</h1>
</Col>
<Col md={6}>
<h1>aalo</h1>
</Col>
</Row>
</Container>
</div>
}
export default HeroSection
step2 frontend/src/pages/Home.js
function Home() {
return (
<div>
<HeroSection/>
<div>welcome Home Page</div>
</div>
)
}
*************************************11 Nov
2024***************************************
step1frontend/src/components/HeroSection.js
return(
<div className="hero-section">
<Container>
<Row className="align-items-center">
<Col md={6}>
<h1>Welcome to DellDen</h1>
<p>Your one-stop destination for the best products at unbeatable prices!</p>
<Button variant="primary" href="/">Shop Now</Button>
</Col>
<Col md={6}>
<img src='https://img.freepik.com/free-photo/view-table-with-articles-food-
family_1398-5025.jpg?semt=ais_hybrid'
alt="Shopping"
className="hero-image"
/>
</Col>
</Row>
</Container>
</div>
}
export default HeroSection
step2frontend/src/components/HeroSection.css
.hero-section {
background-color: #f8f9fa; /* Light background color */
padding: 4rem 0; /* Padding for the section */
text-align: left; /* Left align text */
}
.hero-section h1 {
font-size: 3rem; /* Large heading size */
color: #333; /* Dark text color */
}
.hero-section p {
font-size: 1.25rem; /* Medium text size */
color: #666; /* Grey text color */
}
.hero-image {
max-width: 100%; /* Responsive image */
height: auto; /* Maintain aspect ratio */
border-radius: 0.5rem; /* Rounded corners for the image */
}
step3frontend/src/components/HeroSection.js
return(
<div className="hero-section">
<Container>
<Row className="align-items-center">
<Col md={6}>
<h1>Welcome to DellDen</h1>
<p>Your one-stop destination for the best products at unbeatable prices!</p>
<Button variant="primary" href="/">Shop Now</Button>
</Col>
<Col md={6}>
<img src='https://img.freepik.com/free-photo/view-table-with-articles-food-
family_1398-5025.jpg?semt=ais_hybrid'
alt="Shopping"
className="hero-image"
/>
</Col>
</Row>
</Container>
</div>
}
export default HeroSection
*********************************12 nov
2024*********************************************
step1 frontend/src/data/Products.js
const products=[
{
id: 1,
name: 'Smartphone',
price: 299.99,
description: 'Latest model smartphone with amazing features.',
image: '/images/im1.jpg'
},
{
id: 2,
name: 'Laptop',
price: 799.99,
description: 'High-performance laptop for gaming and work.',
image: '/images/im2.jpg'
},
{
id: 3,
name: 'Headphones',
price: 99.99,
description: 'Noise-cancelling headphones with premium sound quality.',
image: '/images/im3.jpg'
},
{
id: 4,
name: 'Headphones',
price: 99.99,
description: 'Noise-cancelling headphones with premium sound quality.',
image: '/images/im4.jpg'
},
{
id: 5,
name: 'Headphones',
price: 99.99,
description: 'Noise-cancelling headphones with premium sound quality.',
image: '/images/im5.jpg'
},
{
id: 6,
name: 'Headphones',
price: 99.99,
description: 'Noise-cancelling headphones with premium sound quality.',
image: '/images/im6.jpg'
},
{
id: 7,
name: 'Headphones',
price: 99.99,
description: 'Noise-cancelling headphones with premium sound quality.',
image: '/images/im7.jpg'
},
{
id: 8,
name: 'Headphones',
price: 99.99,
description: 'Noise-cancelling headphones with premium sound quality.',
image: '/images/im8.jpg'
},
step2frontend/public/images
step2
https://react-bootstrap.netlify.app/
import Button from 'react-bootstrap/Button';
import Card from 'react-bootstrap/Card';
<Card style={{ width: '18rem' }}>
<Card.Img variant="top" src="holder.js/100px180" />
<Card.Body>
<Card.Title>Card Title</Card.Title>
<Card.Text>
Some quick example text to build on the card title and make up the
bulk of the card's content.
</Card.Text>
<Button variant="primary">Go somewhere</Button>
</Card.Body>
</Card>
step3frontend/src/components/ProductCard.js
step4 frontend/src/components/ProductList.js
function ProductList() {
return (
<div>
<ProductCard/>
</div>
)
}
step4 frontend/src/pages/Home.js
function Home() {
return (
<div>
<HeroSection/>
<ProductList/>
<div>welcome Home Page</div>
</div>
)
}
******************************************14 nov
2024************************************
step1 frontend/src/data/products.js
const products = [
{
id: 1,
name: 'Aata',
price: 299.99,
description: 'Latest model smartphone with amazing features.',
image: '/images/im1.jpg'
},
{
id: 2,
name: 'Home Made',
price: 799.99,
description: 'High-performance laptop for gaming and work.',
image: '/images/im2.jpg'
},
{
id: 3,
name: 'Delicious Food',
price: 99.99,
description: 'Noise-cancelling headphones with premium sound quality.',
image: '/images/im3.jpg'
},
{
id: 4,
name: 'Headphones',
price: 99.99,
description: 'Noise-cancelling headphones with premium sound quality.',
image: '/images/im1.jpg'
},
{
id: 5,
name: 'Headphones',
price: 99.99,
description: 'Noise-cancelling headphones with premium sound quality.',
image: '/images/im2.jpg'
},
{
id: 6,
name: 'Headphones',
price: 99.99,
description: 'Noise-cancelling headphones with premium sound quality.',
image: '/images/im2.jpg'
},
{
id: 7,
name: 'Headphones',
price: 99.99,
description: 'Noise-cancelling headphones with premium sound quality.',
image: '/images/im2.jpg'
},
{
id: 8,
name: 'Headphones',
price: 99.99,
description: 'Noise-cancelling headphones with premium sound quality.',
image: '/images/im2.jpg'
},
// Add more products here...
];
step2frontend/src/components/ProductList.js
step3frontend/src/components/ProductCard.js
return (
<Card style={{ width: '18rem' }}>
<Link to={`/product/${product.id}`}> {/* Correct link to ProductDetail */}
<Card.Img variant="top" src={product.image} />
</Link>
<Card.Body>
<Card.Title>{product.name}</Card.Title>
<Card.Text>Price: ${product.price}</Card.Text>
<Button variant="primary" >
Add to Cart
</Button>
</Card.Body>
</Card>
);
};
step4 frontend/src/pages/Home.js
step5
npm start
***************************18 nov
2024*****************************************************************
step1 frontend/src/pages/Home.css
.home-container {
background-color: #f8f9fa; /* Light gray background */
padding: 20px; /* Padding around the container */
min-height: 100vh; /* Make sure the container covers full height */
}
h2 {
color: #343a40; /* Darker color for heading */
}
.card {
border: none; /* Remove default card border */
border-radius: 8px; /* Rounded corners for the card */
}
.card-body {
padding: 20px; /* Padding for the card body */
}
.card-title {
font-size: 1.5rem; /* Larger title font size */
}
.card-text {
font-size: 1.25rem; /* Larger text size for product info */
}
.product-list {
display: flex; /* Align items in a flexbox */
flex-wrap: wrap; /* Allow items to wrap to the next line */
justify-content: space-between; /* Space items evenly */
}
.product-item {
margin-bottom: 20px; /* Space between product items */
flex: 1 0 21%; /* Responsive item sizing (4 items per row) */
max-width: 22%; /* Limit maximum width for product items */
}
step2 frontend/src/components/Navbar.js
</Nav>
</Navbar.Collapse>
</Container>
</Navbar>
)
}
step3 frontend/src/components/NavigationBar.css
.custom-navbar {
background-color: #343a40; /* Dark background color */
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Subtle shadow */
}
.custom-navbar .nav-link {
color: #ffffff; /* White text color */
margin-left: 15px; /* Space between links */
transition: color 0.3s; /* Smooth transition */
}
.custom-navbar .nav-link:hover {
color: #ffd700; /* Change color on hover */
}
.custom-navbar .navbar-brand {
font-size: 1.5rem; /* Brand font size */
font-weight: bold; /* Brand bold text */
}
.custom-navbar .navbar-toggler {
border: none; /* Remove border */
}
.custom-navbar .navbar-toggler-icon {
background-color: #ffffff; /* Change toggle icon color */
}