Skip to content

Commit

Permalink
Refactor NavBar component to accept dynamic buttons and update HomePa…
Browse files Browse the repository at this point in the history
…ge to use new props
  • Loading branch information
bvdcode committed Dec 17, 2024
1 parent 8f5fc38 commit 1c29e30
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 13 additions & 2 deletions Sources/octockup.client/src/components/NavBar/NavBar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
interface NavButton {
path: string;
icon: JSX.Element;
}

interface NavBarProps {
iLikeTypeScript: boolean;
buttons: NavButton[];
}

const NavBar: React.FC<NavBarProps> = (props) => {
return <>I like TypeScript: {props.iLikeTypeScript.toString()}</>;
return (
<>
{props.buttons.map((button, index) => (
<button key={index}>{button.icon}</button>
))}
</>
);
};

export default NavBar;
4 changes: 3 additions & 1 deletion Sources/octockup.client/src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import { Routes, Route } from "react-router-dom";
import { Dashboard, NavBar, Profile } from "../components";

const HomePage: React.FC = () => {
const navButtons = [{ path: "/dashboard", icon: <button></button> }];

return (
<div className={styles.container}>
<Routes>
<Route path="/" element={<Dashboard />} />
<Route path="/profile" element={<Profile />} />
<Route path="/dashboard" element={<Dashboard />} />
</Routes>
<NavBar iLikeTypeScript={true} />
<NavBar buttons={navButtons} />
</div>
);
};
Expand Down

0 comments on commit 1c29e30

Please sign in to comment.