Skip to content

Commit 87caf85

Browse files
Day 5 Reviews
1 parent 2cbbdc6 commit 87caf85

File tree

2 files changed

+197
-85
lines changed

2 files changed

+197
-85
lines changed

7-slider/setup/src/App.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,42 @@ function App() {
66
const [people,setPeople] = useState(data);
77
const [index,setIndex] = useState(0);
88

9+
useEffect(()=>{
10+
const lastIndex = people.length - 1;
11+
if(index<0)
12+
setIndex(lastIndex);
13+
if(index===people.length)
14+
setIndex(0);
15+
},[index,people]);
16+
17+
useEffect(()=>{
18+
let slider = setInterval(()=>{
19+
setIndex(index+1);
20+
},3000);
21+
return (()=>clearInterval(slider));
22+
},[index])
23+
924
return (
1025
<section className="section">
1126
<div className="title">
1227
<h2><span>/</span>Reviews</h2>
1328
</div>
1429
<div className="section-center">
1530
{
16-
people.map((people,peopleIndex)=>{
17-
const {id,image,name,title,quote} = people;
31+
people.map((person,personIndex)=>{
32+
const {id,image,name,title,quote} = person;
1833
//More Stuff Coming
34+
let position = 'nextSlide';
35+
36+
if( index === personIndex )
37+
position = 'activeSlide'
38+
39+
if( ( index-1 === personIndex ) ||
40+
(index === 0 && personIndex === people.length-1) )
41+
position = 'lastSlide'
1942

2043
return (
21-
<article key={id}>
44+
<article key={id} className={position}>
2245
<img src={image} alt={name} className="person-img" />
2346
<h4>{name}</h4>
2447
<p className="title">{title}</p>
@@ -28,10 +51,10 @@ function App() {
2851
);
2952
})
3053
}
31-
<button className="prev">
54+
<button className="prev" onClick={()=>setIndex(index-1)}>
3255
<FiChevronLeft />
3356
</button>
34-
<button className="next">
57+
<button className="next" onClick={()=>setIndex(index+1)}>
3558
<FiChevronRight />
3659
</button>
3760
</div>

7-slider/setup/src/index.css

Lines changed: 169 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/*
2-
===============
3-
Variables
4-
===============
5-
*/
6-
71
:root {
82
/* dark shades of primary color*/
93
--clr-primary-1: hsl(21, 91%, 17%);
@@ -117,111 +111,177 @@ p {
117111
line-height: 1;
118112
}
119113
}
120-
/* global classes */
121114

122-
/* section */
123-
.section {
115+
/* main */
116+
.section
117+
{
124118
width: 90vw;
125119
margin: 5rem auto;
126120
max-width: var(--max-width);
127121
}
128122

129-
@media screen and (min-width: 992px) {
130-
.section {
123+
@media only screen and (min-width: 992px)
124+
{
125+
.section
126+
{
131127
width: 95vw;
132128
}
133129
}
134-
/*
135-
===============
136-
Slider
137-
===============
138-
*/
139-
.title {
140-
text-align: center;
141-
margin-bottom: 2rem;
130+
131+
132+
.section .title
133+
{
134+
margin-bottom: 0.75rem;
135+
color: var(--clr-grey-3);
142136
}
143-
.title h2 {
137+
138+
139+
.section .title h2
140+
{
144141
display: flex;
145-
align-items: center;
146142
justify-content: center;
147-
font-weight: 500;
143+
align-items: center;
144+
font-weight: 500;
148145
}
149-
.title span {
150-
font-size: 0.85em;
146+
147+
.section .title h2 span
148+
{
151149
color: var(--clr-primary-5);
152150
margin-right: 1rem;
151+
font-size: 0.85em;
153152
font-weight: 700;
154153
}
155-
.section-center {
154+
155+
.section-center
156+
{
156157
margin: 0 auto;
157158
margin-top: 4rem;
158159
width: 80vw;
159-
/* have to have a height */
160160
height: 450px;
161161
max-width: 800px;
162-
text-align: center;
163-
position: relative;
164162
display: flex;
165-
/* overflow: hidden; */
163+
justify-content: center;
164+
align-items: center;
165+
position: relative;
166+
text-align: center;
167+
overflow: hidden;
168+
}
169+
170+
.section-center article
171+
{
172+
position: absolute;
173+
top: 0;
174+
left: 0;
175+
width: 100%;
176+
height: 100%;
177+
opacity: 0;
178+
transition: var(--transition);
179+
}
180+
181+
.section-center article h4
182+
{
183+
text-transform: uppercase;
184+
color: var(--clr-primary-5);
185+
margin-bottom: .25rem;
166186
}
167-
.person-img {
187+
188+
.section-center article img
189+
{
168190
border-radius: 50%;
169-
margin-bottom: 1rem;
170191
width: 150px;
171192
height: 150px;
172193
object-fit: cover;
173194
border: 4px solid var(--clr-grey-8);
174195
box-shadow: var(--dark-shadow);
196+
margin-bottom: 1rem;
175197
}
176-
article h4 {
177-
text-transform: uppercase;
178-
color: var(--clr-primary-5);
179-
margin-bottom: 0.25rem;
180-
}
181-
.title {
182-
text-transform: capitalize;
183-
margin-bottom: 0.75rem;
198+
199+
.section-center article .title
200+
{
184201
color: var(--clr-grey-3);
202+
text-transform: capitalize;
185203
}
186-
.text {
187-
max-width: 35em;
188-
margin: 0 auto;
189-
margin-top: 2rem;
204+
205+
206+
.section-center article .text
207+
{
190208
line-height: 2;
191209
color: var(--clr-grey-5);
210+
margin: 2rem auto 0;
192211
}
212+
213+
193214
.icon {
194-
font-size: 3rem;
195-
margin-top: 1rem;
196-
color: var(--clr-primary-5);
215+
font-size: 3rem;
216+
margin-top: 1rem;
217+
color: #ba5d2c;
218+
color: var(--clr-primary-5);
197219
}
198-
.prev,
199-
.next {
220+
221+
222+
.prev
223+
{
200224
position: absolute;
201225
top: 200px;
202-
transform: translateY(-50%);
226+
left: 0;
203227
background: var(--clr-grey-5);
204-
color: var(--clr-white);
228+
border: 0;
229+
outline: 0;
205230
width: 1.25rem;
206231
height: 1.25rem;
207-
display: grid;
208-
place-items: center;
209-
border-color: transparent;
210-
font-size: 1rem;
232+
color: white;
211233
border-radius: var(--radius);
234+
display: flex;
235+
align-items: center;
236+
justify-content: center;
237+
font-size: 1.25rem;
238+
transition: var(--transition);
212239
cursor: pointer;
240+
padding: 2px;
241+
transform: translateY(-50%);
242+
}
243+
244+
.next
245+
{
246+
position: absolute;
247+
top: 200px;
248+
right: 0;
249+
background: var(--clr-grey-5);
250+
border: 0;
251+
outline: 0;
252+
width: 1.25rem;
253+
height: 1.25rem;
254+
color: white;
255+
border-radius: var(--radius);
256+
display: flex;
257+
align-items: center;
258+
justify-content: center;
259+
font-size: 1.25rem;
213260
transition: var(--transition);
261+
cursor: pointer;
262+
padding: 2px;
263+
transform: translateY(-50%);
264+
}
265+
266+
article.activeSlide {
267+
opacity: 1;
268+
transform: translateX(0);
214269
}
215-
.prev:hover,
216-
.next:hover {
217-
background: var(--clr-primary-5);
270+
article.lastSlide {
271+
transform: translateX(-100%);
218272
}
219-
.prev {
220-
left: 0;
273+
article.nextSlide {
274+
transform: translateX(100%);
221275
}
222-
.next {
223-
right: 0;
276+
277+
@media only screen and (min-width: 992px)
278+
{
279+
.prev,.next
280+
{
281+
font-size: 2em;
282+
}
224283
}
284+
225285
@media (min-width: 800px) {
226286
.text {
227287
max-width: 45em;
@@ -233,22 +293,51 @@ article h4 {
233293
font-size: 1.5rem;
234294
}
235295
}
236-
article {
237-
position: absolute;
238-
top: 0;
239-
left: 0;
240-
width: 100%;
241-
height: 100%;
242-
/* opacity: 0; */
243-
transition: var(--transition);
244-
}
245-
/* article.activeSlide {
246-
opacity: 1;
247-
transform: translateX(0);
248-
}
249-
article.lastSlide {
250-
transform: translateX(-100%);
251-
}
252-
article.nextSlide {
253-
transform: translateX(100%);
254-
} */
296+
297+
298+
299+
300+
301+
302+
303+
304+
305+
306+
307+
308+
309+
310+
311+
312+
313+
314+
315+
316+
317+
318+
319+
320+
321+
322+
323+
324+
325+
326+
327+
328+
329+
330+
331+
332+
333+
334+
335+
336+
337+
338+
339+
340+
341+
342+
343+

0 commit comments

Comments
 (0)