Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: web security | categories and route highlighting #762

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/components/WebSecurity/Common/Labs/Labs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ const Labs = ({ LabData, heading }) => {
<>
<div style={{ width: "100%", maxWidth: "1200px", margin: "5px auto" }}>
<LabContainer>
<Sidebar heading={heading} topics={LabData} onlyCat={true} setCategoryActive={setCategoryActive} />
<Sidebar
heading={heading}
topics={LabData}
onlyCat={true}
setCategoryActive={setCategoryActive}
categoryActive={categoryActive}
/>

<RoomContainer>
<div className="header">
Expand Down
11 changes: 9 additions & 2 deletions src/components/WebSecurity/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const VerticalLine = styled.div`
// width: 100%;
// `;

const Sidebar = ({ heading, topic, topics, onSelectSubtopic, setCategoryActive, onlyCat }) => {
const Sidebar = ({ heading, topic, topics, onSelectSubtopic, setCategoryActive, onlyCat, categoryActive }) => {
const [openDropdown, setOpenDropdown] = useState(null);

const toggleDropdown = (index) => {
Expand Down Expand Up @@ -142,7 +142,14 @@ const Sidebar = ({ heading, topic, topics, onSelectSubtopic, setCategoryActive,
>
{onlyCat &&
categories.map((category, index) => (
<MainTitle key={index} onClick={() => setCategoryActive(category)}>
<MainTitle
key={index}
onClick={() => setCategoryActive(category)}
style={{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't you add this inside of MainTitle styled-component (above in creations of this element) instead?

background: categoryActive === category && "#ff6b08",
color: categoryActive === category && "#000000",
}}
>
<div
style={{
display: "flex",
Expand Down
6 changes: 5 additions & 1 deletion src/components/WebSecurity/SubHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import {
DropdownLi,
DropdownLink,
} from "./Common/SubHeaderElements"; // Make sure to provide the correct path
import { useLocation } from "react-router-dom";

const SubHeader = (props) => {
const { subHeaderData } = props;
const currentSubPath = useLocation().pathname.split("/").pop();

return (
<Nav>
Expand Down Expand Up @@ -48,7 +50,9 @@ const SubHeader = (props) => {
</DropdownUl>
</DropdownContainer>
) : (
<NavLink to={item.link}>{item.title}</NavLink>
<NavLink to={item.link} style={{ color: currentSubPath === item.link && "#ff6b08" }}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add default the "Topics" option because it appears first when we click on this page or change the redirection link to open it be http://localhost:3000/websecurity/topics and not http://localhost:3000/websecurity

image

{item.title}
</NavLink>
)}
</Li>
))
Expand Down
1 change: 1 addition & 0 deletions src/components/WebSecurity/WebSecurityTopics/Topics.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const Topics = () => {
setCategoryActive={setCategoryActive}
onSelectSubtopic={handleSelectSubtopic}
onlyCat={true}
categoryActive={categoryActive}
/>
<Container>
<div className="header">
Expand Down