Skip to content

Commit 187d4b6

Browse files
Merge pull request #5 from rohitverma0234/05_Home-&-About-Page-with-Hero-Section
05 home & about page with hero section
2 parents c53c1d9 + 998ece0 commit 187d4b6

File tree

7 files changed

+193
-28
lines changed

7 files changed

+193
-28
lines changed

README.md

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1-
# Responsive-Header-Section
2-
## UseState Hook
3-
The useState hook is a built-in hook that allows functional components to manage state. It's commonly used when you need to add state to a component without converting it into a class.
4-
5-
Here's a basic overview of how to use useState:
6-
7-
import React, { useState } from 'react';
8-
9-
function ExampleComponent() {<br>
10-
// Here, we declare a state variable called "count" and a function to update it, "setCount".<br>
11-
// We initialize the state with a value of 0.<br>
12-
const [count, setCount] = useState(0);
13-
14-
return (
15-
<div>
16-
<p>You clicked {count} times</p>
17-
{/* When the button is clicked, we call setCount to update the state */}<br>
18-
<button onClick={() => setCount(count + 1)}>
19-
Click me
20-
</button>
21-
</div>
22-
);
23-
}
24-
25-
export default ExampleComponent;
1+
# Props
2+
## 1. Definition
3+
Props stands for properties and refers to the mechanism for passing data from one component to another within an application.
4+
5+
## 2. Here's how it works:
6+
1. <b>Parent Component Passing Data:</b> A parent component can pass data to a child component by using attributes similar to HTML attributes.
7+
8+
2. <b>Receiving Props</b>: The child component receives the data passed by the parent as props. Props are received as an object within the child component.
9+
10+
3. <b>Immutable Data</b>: Props are immutable, meaning that a child component cannot directly modify the props it receives from its parent. They are read-only.
11+
12+
4. <b>Functional and Class Components</b>: Props can be used with both functional and class components in React.
2613

2714
# Welcome to Rohit React Ecommerce Website
2815

public/images/hero.jpg

563 KB
Loading

src/About.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import React from 'react'
2+
import HeroSection from './components/HeroSection'
23

34
const About = () => {
5+
6+
const data = {
7+
name:"Rohit Store",
8+
}
9+
410
return (
5-
<div>About</div>
11+
<div>
12+
<HeroSection myData={data}/>
13+
</div>
614
)
715
}
816

src/GlobalStyle.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,34 @@ li {
8080
list-style: none;
8181
}
8282
83+
${"" /* resuable code section */}
84+
85+
.container {
86+
max-width: 120rem;
87+
margin: 0 auto;
88+
}
89+
90+
.grid {
91+
display: grid;
92+
gap: 9rem;
93+
}
94+
95+
.grid-two-column {
96+
grid-template-columns: repeat(2, 1fr);
97+
}
98+
99+
.grid-three-column {
100+
grid-template-columns: repeat(3, 1fr);
101+
}
102+
103+
.grid-four-column{
104+
grid-template-columns: 1fr 1.2fr .5fr .8fr ;
105+
}
106+
107+
.grid-five-column{
108+
grid-template-columns: repeat(5, 1fr);
109+
}
110+
83111
@media (max-width: ${({ theme }) => theme.media.tab}) {
84112
.container {
85113
max-width: 130rem;

src/Home.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
import React from 'react'
22
import styled from 'styled-components'
3+
import HeroSection from './components/HeroSection'
34

45
const Home = () => {
6+
const data = {
7+
name:"Rohit"
8+
}
9+
510
return (
611
<Wrapper className='test'>
7-
Home
12+
<HeroSection myData={data}/>
813
</Wrapper>
914
)
1015
}
1116

1217
const Wrapper = styled.section`
13-
background-color: ${({theme})=> theme.colors.bg};
18+
1419
`
1520

1621
export default Home

src/components/HeroSection.js

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import React from 'react'
2+
import { NavLink } from 'react-router-dom'
3+
import styled from 'styled-components'
4+
import { Button } from '../styles/Button'
5+
6+
const HeroSection = ({myData}) => {
7+
8+
const{name} = myData
9+
10+
return (
11+
<Wrapper>
12+
<div className="container">
13+
<div className="grid grid-two-column">
14+
<div className="hero-section-data">
15+
<p className="intro-data">Welcome to </p>
16+
<h1>{name}</h1>
17+
<p>
18+
Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestias
19+
atque temporibus veniam doloribus libero ad error omnis voluptates
20+
animi! Suscipit sapiente.
21+
</p>
22+
<NavLink>
23+
<Button>show now</Button>
24+
</NavLink>
25+
</div>
26+
{/* homepage image */}
27+
<div className="hero-section-image">
28+
<figure>
29+
<img
30+
src="./images/hero.jpg"
31+
alt="hero-section"
32+
className="img-style"
33+
/>
34+
</figure>
35+
36+
</div>
37+
</div>
38+
</div>
39+
</Wrapper>
40+
)
41+
}
42+
43+
const Wrapper = styled.section`
44+
padding: 12rem 0;
45+
46+
img {
47+
min-width: 10rem;
48+
height: 10rem;
49+
}
50+
51+
.hero-section-data {
52+
p {
53+
margin: 2rem 0;
54+
}
55+
56+
h1 {
57+
text-transform: capitalize;
58+
font-weight: bold;
59+
}
60+
61+
.intro-data {
62+
margin-bottom: 0;
63+
}
64+
}
65+
66+
.hero-section-image {
67+
width: 100%;
68+
height: auto;
69+
display: flex;
70+
justify-content: center;
71+
align-items: center;
72+
}
73+
figure {
74+
position: relative;
75+
76+
&::after {
77+
content: "";
78+
width: 60%;
79+
height: 80%;
80+
background-color: rgba(81, 56, 238, 0.4);
81+
position: absolute;
82+
left: 50%;
83+
top: -5rem;
84+
z-index: -1;
85+
}
86+
}
87+
.img-style {
88+
width: 100%;
89+
height: auto;
90+
}
91+
92+
@media (max-width: ${({ theme }) => theme.media.mobile}) {
93+
.grid {
94+
gap: 10rem;
95+
}
96+
97+
figure::after {
98+
content: "";
99+
width: 50%;
100+
height: 100%;
101+
left: 0;
102+
top: 10%;
103+
/* bottom: 10%; */
104+
background-color: rgba(81, 56, 238, 0.4);
105+
}
106+
}`
107+
108+
export default HeroSection

src/styles/Button.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import styled from "styled-components";
2+
3+
export const Button = styled.button`
4+
text-decoration: none;
5+
max-width: auto;
6+
background-color: rgb(98 84 243);
7+
color: rgb(255 255 255);
8+
padding: 1.4rem 2.4rem;
9+
border: none;
10+
text-transform: uppercase;
11+
text-align: center;
12+
cursor: pointer;
13+
transition: all 0.3s ease;
14+
-webkit-transition: all 0.3s ease 0s;
15+
-moz-transition: all 0.3s ease 0s;
16+
-o-transition: all 0.3s ease 0s;
17+
18+
&:hover,
19+
&:active {
20+
box-shadow: 0 2rem 2rem 0 rgb(132 144 255 / 30%);
21+
box-shadow: ${({ theme }) => theme.colors.shadowSupport};
22+
transform: scale(0.96);
23+
}
24+
25+
a {
26+
text-decoration: none;
27+
color: rgb(255 255 255);
28+
font-size: 1.8rem;
29+
}`

0 commit comments

Comments
 (0)