Skip to content

Commit f273047

Browse files
committed
feat: add the tabs project to the home app
1 parent 13237e7 commit f273047

File tree

5 files changed

+93
-74
lines changed

5 files changed

+93
-74
lines changed

src/App.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import ToursApp from './projects/2.Tours'
66
import Reviews from './projects/3.Reviews'
77
import Accordion from './projects/4.Accordion'
88
import Menu from './projects/5.Menu'
9-
// import Tabs from './projects/6.Tabs'
9+
import Tabs from './projects/6.Tabs'
1010
// import Slider from './projects/7.Slider'
1111
// import Navbar from './projects/8.Navbar'
1212
// import SidebarModal from './projects/9.Sidebar-Modal'
@@ -25,8 +25,8 @@ function App() {
2525
<Route path="/reviews" component={Reviews}/>
2626
<Route path="/accordion" component={Accordion}/>
2727
<Route path="/menu" component={Menu}/>
28-
{/* <Route path="/tabs" component={Tabs}/>
29-
<Route path="/slider" component={Slider}/>
28+
<Route path="/tabs" component={Tabs}/>
29+
{/* <Route path="/slider" component={Slider}/>
3030
<Route path="/navbar" component={Navbar}/>
3131
<Route path="/sidebar-modal" component={SidebarModal}/>
3232
<Route path="/stripe-menu" component={StripeMenu}/>

src/data.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ const projects = [
2424
image: './images/projects_thumb/Menu.png',
2525
link: '/menu'
2626
},
27+
{
28+
title: 'Tabs',
29+
image: './images/projects_thumb/Tabs.png',
30+
link: '/tabs'
31+
},
2732

2833
];
2934
export default projects;

src/projects/6.Tabs/App.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { useState, useEffect } from 'react'
2+
import { FaAngleDoubleRight } from 'react-icons/fa'
3+
4+
5+
const url = 'https://course-api.com/react-tabs-project'
6+
7+
function App() {
8+
const [loading, setLoading] = useState(true)
9+
const [jobs, setJobs] = useState([])
10+
const [value, setValue] = useState(0)
11+
12+
const fetchJobs = async() => {
13+
const newJobs = await fetch(url).then(response => response.json())
14+
setJobs(newJobs)
15+
setLoading(false)
16+
}
17+
useEffect(() => {
18+
fetchJobs()
19+
}, [])
20+
21+
if(loading){
22+
return(
23+
<section className='section loading'>
24+
<h1>Loading...</h1>
25+
</section>
26+
);
27+
}
28+
29+
const {company, dates, duties, title} = jobs[value]
30+
return (
31+
<section className='section'>
32+
<div className="title">
33+
<h2>experience</h2>
34+
<div className="underline"></div>
35+
</div>
36+
<div className="jobs-center">
37+
<div className="btn-container">
38+
{
39+
jobs.map((job, index) => {
40+
return (
41+
<button
42+
key={job.id}
43+
onClick={() => setValue(index)}
44+
className={`job-btn ${index === value && 'active-btn'}`}
45+
>
46+
{job.company}
47+
</button>
48+
)
49+
})
50+
}
51+
</div>
52+
<article className="job-info">
53+
<h3>{title}</h3>
54+
<h4>{company}</h4>
55+
<p className="job-date">{dates}</p>
56+
{duties.map((duty, index) => {
57+
return (
58+
<div className="job-desc" key={index}>
59+
<FaAngleDoubleRight className="job-icon">
60+
</FaAngleDoubleRight>
61+
<p>{duty}</p>
62+
</div>
63+
)
64+
})
65+
}
66+
</article>
67+
</div>
68+
<button type="button" className="btn">
69+
More info
70+
</button>
71+
72+
</section>
73+
)
74+
}
75+
76+
export default App

src/projects/6.Tabs/index.js

Lines changed: 5 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,11 @@
1-
import { useState, useEffect } from 'react'
2-
import { FaAngleDoubleRight } from 'react-icons/fa'
3-
import './index.css'
4-
5-
const url = 'https://course-api.com/react-tabs-project'
1+
import App from './App.js';
2+
import './index.scss'
63

74
function Index() {
8-
const [loading, setLoading] = useState(true)
9-
const [jobs, setJobs] = useState([])
10-
const [value, setValue] = useState(0)
11-
12-
const fetchJobs = async() => {
13-
const newJobs = await fetch(url).then(response => response.json())
14-
setJobs(newJobs)
15-
setLoading(false)
16-
}
17-
useEffect(() => {
18-
fetchJobs()
19-
}, [])
20-
21-
if(loading){
22-
return(
23-
<section className='section loading'>
24-
<h1>Loading...</h1>
25-
</section>
26-
);
27-
}
28-
29-
const {company, dates, duties, title} = jobs[value]
305
return (
31-
<section className='section'>
32-
<div className="title">
33-
<h2>experience</h2>
34-
<div className="underline"></div>
35-
</div>
36-
<div className="jobs-center">
37-
<div className="btn-container">
38-
{
39-
jobs.map((job, index) => {
40-
return (
41-
<button
42-
key={job.id}
43-
onClick={() => setValue(index)}
44-
className={`job-btn ${index === value && 'active-btn'}`}
45-
>
46-
{job.company}
47-
</button>
48-
)
49-
})
50-
}
51-
</div>
52-
<article className="job-info">
53-
<h3>{title}</h3>
54-
<h4>{company}</h4>
55-
<p className="job-date">{dates}</p>
56-
{duties.map((duty, index) => {
57-
return (
58-
<div className="job-desc" key={index}>
59-
<FaAngleDoubleRight className="job-icon">
60-
</FaAngleDoubleRight>
61-
<p>{duty}</p>
62-
</div>
63-
)
64-
})
65-
}
66-
</article>
67-
</div>
68-
<button type="button" className="btn">
69-
More info
70-
</button>
71-
72-
</section>
6+
<div className="tabs">
7+
<App/>
8+
</div>
739
)
7410
}
7511

src/projects/6.Tabs/index.css renamed to src/projects/6.Tabs/index.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Variables
4343
--max-width: 1170px;
4444
--fixed-width: 620px;
4545
}
46+
47+
.tabs {
4648
/*
4749
===============
4850
Global Styles
@@ -263,5 +265,5 @@ Variables
263265
color: var(--clr-primary-1);
264266
background: var(--clr-primary-8);
265267
}
266-
.center-btn {
267-
}
268+
269+
}

0 commit comments

Comments
 (0)