-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hamburger menu to navigation bar (#994)
- Loading branch information
Showing
15 changed files
with
284 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Iconenbibliotheek | ||
|
||
De iconenbibliotheek is te vinden in `frontend/lib/icon/`. Het bevat alle iconen die in de applicatie worden gebruikt. | ||
|
||
## Richtlijnen | ||
|
||
Sommige iconen kunnen zich anders gedragen, maar hier zijn enkele richtlijnen voor het toevoegen/maken van iconen | ||
|
||
### Verplicht | ||
|
||
- Geen inline stijlen | ||
- Geen ID-attribuut | ||
- Geen class-attribuut | ||
- Voeg `role="img"` toe | ||
|
||
### Richtlijnen | ||
|
||
- Monokleur (zwart) | ||
- Alleen gevulde paden | ||
- Converteer lijnpaden met Adobe Illustrator (Object > Path > Outline Stroke) of Inkscape (Path > Stroke to Path) | ||
- Grenzen van `0 0 24 24` | ||
|
||
## Bouwen | ||
|
||
Voer vanuit `frontend/` uit: | ||
|
||
```sh | ||
npm run gen:icons | ||
``` | ||
|
||
Dit zal `lib/icon/generated.tsx` maken met alle iconen. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import * as React from "react"; | ||
import { NavLink } from "react-router"; | ||
|
||
import { t } from "@kiesraad/i18n"; | ||
import { IconCompass, IconFile, IconHamburger, IconLaptop, IconUsers } from "@kiesraad/icon"; | ||
|
||
import styles from "./NavBar.module.css"; | ||
|
||
export function NavBarMenu() { | ||
return ( | ||
<div className={styles.navBarMenu}> | ||
<NavLink to={"/elections#administrator"}> | ||
<IconCompass /> | ||
{t("election.title.plural")} | ||
</NavLink> | ||
<NavLink to={"/users#administratorcoordinator"}> | ||
<IconUsers /> | ||
{t("users.users")} | ||
</NavLink> | ||
<NavLink to={"/workstations#administrator"}> | ||
<IconLaptop /> | ||
{t("workstations.workstations")} | ||
</NavLink> | ||
<NavLink to={"/logs#administratorcoordinator"}> | ||
<IconFile /> | ||
{t("logs")} | ||
</NavLink> | ||
</div> | ||
); | ||
} | ||
|
||
export function NavBarMenuButton() { | ||
const [isMenuVisible, setMenuVisible] = React.useState(false); | ||
|
||
React.useEffect(() => { | ||
if (isMenuVisible) { | ||
const handleClickOutside = (event: MouseEvent) => { | ||
if (!document.querySelector(`.${styles.navBarMenu}`)?.contains(event.target as Node)) { | ||
setMenuVisible(false); | ||
} | ||
}; | ||
|
||
document.addEventListener("mousedown", handleClickOutside); | ||
return () => { | ||
document.removeEventListener("mousedown", handleClickOutside); | ||
}; | ||
} | ||
}, [isMenuVisible]); | ||
|
||
const toggleMenu = () => { | ||
setMenuVisible(!isMenuVisible); | ||
}; | ||
|
||
return ( | ||
<button className={styles.navBarMenuContainer} onClick={toggleMenu} title={t("menu")}> | ||
<IconHamburger /> | ||
{isMenuVisible && <NavBarMenu />} | ||
</button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.