Skip to content
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
44 changes: 27 additions & 17 deletions src/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { useState } from "react";
import { usePageTransitionContext } from "./page-transition-provider.tsx";
import { AppPage, AppPageLabels } from "./AppPageLabels.ts";

const isDev =
window.location.hostname === "localhost" ||
window.location.hostname === "127.0.0.1" ||
window.location.hostname.includes("dev") ||
window.location.hostname.includes("staging");

const availablePages = isDev ? Object.entries(AppPageLabels) : Object.entries(AppPageLabels).filter(([key]) => Number(key) !== AppPage.SVG_GENERATOR);

const Navbar = () => {
const { goToPage } = usePageTransitionContext();
Expand All @@ -10,29 +17,32 @@ const Navbar = () => {
return (
<nav className="bg-green-800 text-white">
<div className="flex items-center justify-between px-2 py-4">
<button className="md:hidden !bg-green-800 ml-auto" onClick={() => setOpen(!open)}>
<button
className="md:hidden !bg-green-800 ml-auto"
onClick={() => setOpen(!open)}
>
☰ Menu
</button>
<div className="hidden md:flex gap-6 mx-auto">
{Object.entries(AppPageLabels).map(([key, label]) => {
const page = Number(key) as AppPage;
return (
<a
className="min-w-[100px] px-2 py-4 hover:underline"
key={label}
href="#"
onClick={() => goToPage(page)}
>
{label}
</a>
);
})}
</div>
{availablePages.map(([key, label]) => {
const page = Number(key) as AppPage;
return (
<a
className="min-w-[100px] px-2 py-4 hover:underline"
key={label}
href="#"
onClick={() => goToPage(page)}
>
{label}
</a>
);
})}
</div>
</div>

{open && (
<div className="md:hidden flex flex-col gap-4 px-4 pb-4">
{Object.entries(AppPageLabels).map(([key, label]) => {
{availablePages.map(([key, label]) => {
const page = Number(key) as AppPage;
return (
<a
Expand Down
25 changes: 16 additions & 9 deletions src/popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ export const AutoscalingPopup: React.FC<{
);
};

const capitalize = (str: string) =>
str.charAt(0).toUpperCase() + str.slice(1);
const capitalize = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);

export const CountryInfoLayout: React.FC<{
countryName: string;
Expand Down Expand Up @@ -115,12 +114,19 @@ export const CountryInfoLayout: React.FC<{
</Dropdown>
)
)}
<h3 className="!text-black font-semibold mt-4">Involved Countries:</h3>
{links &&
{links && (
<h3 className="!text-black font-semibold mt-4">
Involved Countries:
</h3>
) &&
links
.filter(([title, _]) => title.length !== 0)
.map(([title, onClick]) => (
<button className="border !border-gray-300 mx-2 my-1" onClick={onClick} style={{backgroundColor: "#f0f0f0", color: "black"}}>
<button
className="border !border-gray-300 mx-2 my-1"
onClick={onClick}
style={{ backgroundColor: "#f0f0f0", color: "black" }}
>
{title}
</button>
))}
Expand Down Expand Up @@ -148,11 +154,12 @@ const Dropdown: React.FC<{ title: string; children: React.ReactNode }> = ({
<button
style={{ backgroundColor: categoryColors[title] || "#f0f0f0" }}
className="w-full flex justify-between items-center p-2"
onClick={() => {setIsOpen(!isOpen)
if(!isOpen) {
onClick={() => {
setIsOpen(!isOpen);
if (!isOpen) {
trackEvent("dropdown_opened", {
dropdown: title
});
dropdown: title,
});
}
}}
>
Expand Down