Finished sidebar functionality.
This commit is contained in:
+13
-11
@@ -111,8 +111,8 @@ function App() {
|
|||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<SideBar tags={tags} handleToggleSidebar={handleToggleSidebar} toggle={toggle} />
|
<SideBar tags={tags} handleToggleSidebar={handleToggleSidebar} toggle={toggle} />
|
||||||
<Routes>
|
|
||||||
<Route path="/" element={<div className='content'>
|
<div className='content'>
|
||||||
<div className="head">
|
<div className="head">
|
||||||
<button className='sidebar-btn btn' style={{marginRight: '10px'}} onClick={handleToggleSidebar}></button>
|
<button className='sidebar-btn btn' style={{marginRight: '10px'}} onClick={handleToggleSidebar}></button>
|
||||||
<input className="search" type="search" placeholder=" Search" onChange={search}/>
|
<input className="search" type="search" placeholder=" Search" onChange={search}/>
|
||||||
@@ -125,14 +125,6 @@ function App() {
|
|||||||
<button className='btn' style={{marginTop: '10px'}} onClick={() => setFilterBox(true)}></button>
|
<button className='btn' style={{marginTop: '10px'}} onClick={() => setFilterBox(true)}></button>
|
||||||
<button className='btn' style={{marginLeft: '10px'}} onClick={() => setSortBox(true)}></button>
|
<button className='btn' style={{marginLeft: '10px'}} onClick={() => setSortBox(true)}></button>
|
||||||
|
|
||||||
<List
|
|
||||||
lightMode={lightMode}
|
|
||||||
SetLoader={SetLoader}
|
|
||||||
data={filteredData}
|
|
||||||
tags={tags}
|
|
||||||
reFetch={fetchData}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{numberOfResults === 0 ? <NoResults /> : null}
|
{numberOfResults === 0 ? <NoResults /> : null}
|
||||||
|
|
||||||
{sortBox ? <Sort
|
{sortBox ? <Sort
|
||||||
@@ -159,6 +151,17 @@ function App() {
|
|||||||
/> : null}
|
/> : null}
|
||||||
|
|
||||||
{loader ? <Loader lightMode={lightMode} /> : null}
|
{loader ? <Loader lightMode={lightMode} /> : null}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Routes>
|
||||||
|
<Route path="/" element={<div className='content'>
|
||||||
|
<List
|
||||||
|
lightMode={lightMode}
|
||||||
|
SetLoader={SetLoader}
|
||||||
|
data={filteredData}
|
||||||
|
tags={tags}
|
||||||
|
reFetch={fetchData}
|
||||||
|
/>
|
||||||
</div>} />
|
</div>} />
|
||||||
|
|
||||||
<Route path="tags/:tagId" element={<Tags
|
<Route path="tags/:tagId" element={<Tags
|
||||||
@@ -168,7 +171,6 @@ function App() {
|
|||||||
tags={tags}
|
tags={tags}
|
||||||
reFetch={fetchData}
|
reFetch={fetchData}
|
||||||
/>} />
|
/>} />
|
||||||
|
|
||||||
</Routes>
|
</Routes>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ const SideBar = ({ tags, handleToggleSidebar, toggle }) => {
|
|||||||
<SidebarContent className='sidebar-content'>
|
<SidebarContent className='sidebar-content'>
|
||||||
<Menu iconShape="circle">
|
<Menu iconShape="circle">
|
||||||
|
|
||||||
<MenuItem><Link to="/"><h3>View All</h3></Link></MenuItem>
|
<MenuItem><Link to="/"><h3>Show Everything</h3></Link></MenuItem>
|
||||||
|
|
||||||
<SubMenu title='Tags'>
|
<SubMenu icon='#' defaultOpen={true} title='Tags'>
|
||||||
{tags.map((e, i) => {
|
{tags.map((e, i) => {
|
||||||
const path = `/tags/${e}`
|
const path = `/tags/${e}`
|
||||||
return <MenuItem key={i}><Link to={path}>{e}</Link></MenuItem>
|
return <MenuItem key={i}><Link to={path}>{e}</Link></MenuItem>
|
||||||
|
|||||||
+5
-3
@@ -1,18 +1,20 @@
|
|||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import List from '../componets/List';
|
import List from '../componets/List';
|
||||||
|
|
||||||
const Tags = ({ data }) => {
|
const Tags = ({ data, tags, SetLoader, lightMode, reFetch }) => {
|
||||||
const { tagId } = useParams();
|
const { tagId } = useParams();
|
||||||
const dataWithMatchingTag = data.filter((e) => {
|
const dataWithMatchingTag = data.filter((e) => {
|
||||||
return e.tag.includes(tagId)
|
return e.tag.includes(tagId)
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(dataWithMatchingTag)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="content">
|
<div className="content">
|
||||||
<List
|
<List
|
||||||
|
lightMode={lightMode}
|
||||||
data={dataWithMatchingTag}
|
data={dataWithMatchingTag}
|
||||||
|
tags={tags}
|
||||||
|
SetLoader={SetLoader}
|
||||||
|
reFetch={reFetch}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -23,11 +23,9 @@
|
|||||||
|
|
||||||
.App {
|
.App {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
display: flex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
width: 100%;
|
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user