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

feat: add navbar react workshop #626

Merged
merged 1 commit into from
Oct 2, 2024
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
52 changes: 52 additions & 0 deletions frontend-cert/react-projects/Navbar/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Reusable navbar component</title>
<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>

<!-- Don't use this in production: -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<link rel="stylesheet" href="./styles.css" />
</head>
<body>
<div id="root"></div>
<script type="text/babel">
function Navbar() {
return (
<nav className="navbar">
<ul>
<li className="nav-item">
<a href="#">Dashboard</a>
</li>
<li className="nav-item">
<a href="#">Widgets</a>
</li>
<li className="nav-item">
<a href="#" aria-haspopup="true">
Apps
</a>
<ul className="sub-menu" aria-label="submenu">
<li>
<a href="#">Calendar</a>
</li>
<li>
<a href="#">Chat</a>
</li>
<li>
<a href="#">Email</a>
</li>
</ul>
</li>
</ul>
</nav>
);
}

const container = document.getElementById("root");
const root = ReactDOM.createRoot(container);
root.render(<Navbar />);
</script>
</body>
</html>
73 changes: 73 additions & 0 deletions frontend-cert/react-projects/Navbar/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}

:root {
--white: #fff;
--light-grey: #e1e0e0;
--dark-purple: #7c0e7c;
--black: #000;
}

body {
background-color: var(--light-grey);
}

.navbar {
background-color: var(--white);
}

.navbar ul {
display: flex;
justify-content: space-around;
}

.navbar ul li {
list-style: none;
border-radius: 4px;
}

.navbar ul li a {
text-decoration: none;
color: var(--black);
padding: 10px;
display: inline-block;
width: 100%;
}

.navbar ul .nav-item a:hover {
background-color: var(--dark-purple);
color: var(--white);
}

.navbar ul .nav-item .sub-menu {
visibility: hidden;
opacity: 0;
position: absolute;
right: 5%;
transition: opacity 0.5s ease;
display: block;
background-color: var(--white);
}

@media (min-width: 768px) {
.navbar ul .nav-item .sub-menu {
right: 15%;
}
}

@media (min-width: 1024px) {
.navbar ul .nav-item .sub-menu {
right: 13%;
}
}

.navbar ul .nav-item:hover .sub-menu,
.navbar ul .nav-item:focus-within .sub-menu {
visibility: visible;
opacity: 1;
}
3 changes: 0 additions & 3 deletions frontend-cert/react-projects/test.md

This file was deleted.