Skip to content

Commit c22a0da

Browse files
committed
Create separate components for header and section-nav from the select/index.js, as they can be genralised and reused in other components as well.
Signed-off-by: Falgun Patel <[email protected]>
1 parent 53f1e3c commit c22a0da

File tree

5 files changed

+60
-53
lines changed

5 files changed

+60
-53
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from "react";
2+
3+
//TODO: Generalise for use in every component
4+
export default function Header() {
5+
return (
6+
<>
7+
<a id="Identity">
8+
<h2>Select</h2>
9+
</a>
10+
<p>
11+
Select component is a dropdown menu for selecting an option from a list.
12+
</p>
13+
</>
14+
);
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from "react";
2+
import { useLocation } from "@reach/router";
3+
import { navigate } from "gatsby";
4+
import TabButton from "../../../../../reusecore/Button";
5+
6+
export default function SectionNav() {
7+
const location = useLocation();
8+
return (
9+
<div className="filterBtns">
10+
<TabButton
11+
className={
12+
location.pathname === "/projects/sistent/components/select"
13+
? "active"
14+
: ""
15+
}
16+
onClick={() => navigate("/projects/sistent/components/select")}
17+
title="Overview"
18+
/>
19+
<TabButton
20+
className={
21+
location.pathname === "/projects/sistent/components/selet/guidance"
22+
? "active"
23+
: ""
24+
}
25+
onClick={() => navigate("/projects/sistent/components/select/guidance")}
26+
title="Guidance"
27+
/>
28+
<TabButton
29+
className={
30+
location.pathname === "/projects/sistent/components/select/code"
31+
? "active"
32+
: ""
33+
}
34+
onClick={() => navigate("/projects/sistent/components/select/code")}
35+
title="Code"
36+
/>
37+
</div>
38+
);
39+
}

src/sections/Projects/Sistent/components/select/code.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
OutlinedInput,
1616
Select,
1717
} from "@mui/material";
18-
import { Header, SectionNav } from ".";
18+
import Header from "../header/header";
19+
import SectionNav from "../section-nav/section-nav";
1920

2021
const codes = {
2122
"variant-outlined": `<Select>

src/sections/Projects/Sistent/components/select/guidance.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
OutlinedInput,
1414
} from "@mui/material";
1515
import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode";
16-
import { Header, SectionNav } from ".";
16+
import Header from "../header/header";
17+
import SectionNav from "../section-nav/section-nav";
1718
const SelectGuidance = () => {
1819
const { isDark } = useStyledDarkMode();
1920
const [selectedAge, setSelectedAge] = React.useState("");

src/sections/Projects/Sistent/components/select/index.js

+2-51
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ import React from "react";
22
import { SistentThemeProvider } from "@layer5/sistent";
33
import { SistentLayout } from "../../sistent-layout";
44
import { Row } from "../../../../../reusecore/Layout";
5-
import { useLocation } from "@reach/router";
65
import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode";
7-
import { navigate } from "gatsby";
8-
import TabButton from "../../../../../reusecore/Button";
96
import {
107
FormControl,
118
InputLabel,
129
MenuItem,
1310
Select,
1411
OutlinedInput,
1512
} from "@mui/material";
13+
import Header from "../header/header";
14+
import SectionNav from "../section-nav/section-nav";
1615

1716
const SistentSelect = () => {
1817
const { isDark } = useStyledDarkMode();
@@ -224,52 +223,4 @@ const SistentSelect = () => {
224223
);
225224
};
226225

227-
export function SectionNav() {
228-
const location = useLocation();
229-
return (
230-
<div className="filterBtns">
231-
<TabButton
232-
className={
233-
location.pathname === "/projects/sistent/components/select"
234-
? "active"
235-
: ""
236-
}
237-
onClick={() => navigate("/projects/sistent/components/select")}
238-
title="Overview"
239-
/>
240-
<TabButton
241-
className={
242-
location.pathname === "/projects/sistent/components/selet/guidance"
243-
? "active"
244-
: ""
245-
}
246-
onClick={() => navigate("/projects/sistent/components/select/guidance")}
247-
title="Guidance"
248-
/>
249-
<TabButton
250-
className={
251-
location.pathname === "/projects/sistent/components/select/code"
252-
? "active"
253-
: ""
254-
}
255-
onClick={() => navigate("/projects/sistent/components/select/code")}
256-
title="Code"
257-
/>
258-
</div>
259-
);
260-
}
261-
262-
export function Header() {
263-
return (
264-
<>
265-
<a id="Identity">
266-
<h2>Select</h2>
267-
</a>
268-
<p>
269-
Select component is a dropdown menu for selecting an option from a list.
270-
</p>
271-
</>
272-
);
273-
}
274-
275226
export default SistentSelect;

0 commit comments

Comments
 (0)