Skip to content

Commit

Permalink
Layout, sidebar and navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarrenechea committed Oct 23, 2023
1 parent 81167a6 commit 4e105fb
Show file tree
Hide file tree
Showing 18 changed files with 165 additions and 25 deletions.
9 changes: 9 additions & 0 deletions client/public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions client/src/app/(app)/layout-providers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use client";

import { PropsWithChildren } from "react";

import { MapProvider } from "react-map-gl";

export default function LayoutProviders({ children }: PropsWithChildren) {
return <MapProvider>{children}</MapProvider>;
}
33 changes: 33 additions & 0 deletions client/src/app/(app)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { PropsWithChildren } from "react";

import MapSettingsManagerPanel from "@/containers/map-settings";
import MapSettingsManager from "@/containers/map-settings/manager";
import Navigation from "@/containers/navigation";
import Sidebar from "@/containers/sidebar";

import Map from "@/components/map";
import Controls from "@/components/map/controls";
import SettingsControl from "@/components/map/controls/settings";
import ZoomControl from "@/components/map/controls/zoom";

import LayoutProviders from "./layout-providers";

export default async function AppLayout({ children }: PropsWithChildren) {
return (
<LayoutProviders>
<main className="flex h-[100svh] w-full justify-between">
<Navigation />
<Sidebar>{children}</Sidebar>
<Map>
<Controls className="absolute right-6 top-4">
<ZoomControl />
<SettingsControl>
<MapSettingsManagerPanel />
</SettingsControl>
</Controls>
<MapSettingsManager />
</Map>
</main>
</LayoutProviders>
);
}
File renamed without changes.
5 changes: 5 additions & 0 deletions client/src/app/(app)/projects/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Projects from "@/containers/projects";

export default function ProjectsPage() {
return <Projects />;
}
6 changes: 1 addition & 5 deletions client/src/app/layout-providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import { PropsWithChildren, useState } from "react";

import { MapProvider } from "react-map-gl";

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

import { TooltipProvider } from "@/components/ui/tooltip";
Expand All @@ -13,9 +11,7 @@ export default function LayoutProviders({ children }: PropsWithChildren) {

return (
<QueryClientProvider client={queryClient}>
<MapProvider>
<TooltipProvider>{children}</TooltipProvider>
</MapProvider>
<TooltipProvider>{children}</TooltipProvider>
</QueryClientProvider>
);
}
6 changes: 4 additions & 2 deletions client/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import "./globals.css";
import "mapbox-gl/dist/mapbox-gl.css";

import { PropsWithChildren } from "react";

import type { Metadata } from "next";

import { Inter } from "next/font/google";

import LayoutProviders from "@/app/layout-providers";
import LayoutProviders from "./layout-providers";

const inter = Inter({ subsets: ["latin"] });

Expand All @@ -14,7 +16,7 @@ export const metadata: Metadata = {
description: "Generated by create next app",
};

export default async function RootLayout({ children }: { children: React.ReactNode }) {
export default async function RootLayout({ children }: PropsWithChildren) {
return (
<LayoutProviders>
<html lang="en">
Expand Down
22 changes: 4 additions & 18 deletions client/src/containers/home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
"use client";

import MapSettingsManagerPanel from "@/containers/home/map-settings";
import MapSettingsManager from "@/containers/home/map-settings/manager";

import Map from "@/components/map";
import Controls from "@/components/map/controls";
import SettingsControl from "@/components/map/controls/settings";
import ZoomControl from "@/components/map/controls/zoom";

const Home = (): JSX.Element => {
return (
<div className="h-screen w-full">
<Map>
<Controls className="absolute right-6 top-4">
<ZoomControl />
<SettingsControl>
<MapSettingsManagerPanel />
</SettingsControl>
</Controls>
<MapSettingsManager />
</Map>
<div className="flex h-full overflow-auto">
<div className="p-5">
<h1 className="text-3xl">Explore datasets</h1>
</div>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { BASEMAPS } from "@/components/map/constants";

import BasemapItem from "./item";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { useCallback } from "react";

import Image from "next/image";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { useCallback } from "react";

import { useSyncMapSettings } from "@/app/url-query-params";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import Basemaps from "./basemaps";
import Boundaries from "./boundaries";
import Labels from "./labels";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { useCallback } from "react";

import { useSyncMapSettings } from "@/app/url-query-params";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { useCallback, useEffect } from "react";

import { useMap } from "react-map-gl";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import { useCallback } from "react";

import { useSyncMapSettings } from "@/app/url-query-params";
Expand Down
34 changes: 34 additions & 0 deletions client/src/containers/navigation/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"use client";

import Image from "next/image";
import Link from "next/link";

import { LuList, LuMap } from "react-icons/lu";

const Navigation = (): JSX.Element => {
return (
<nav className="relative z-20 block h-full w-20 shrink-0 border-r-2 border-gray-300/20 bg-white">
<ul className="w-full text-xs">
<li className="py-5 text-center">
<Link className="flex flex-col items-center justify-center gap-1" href="/">
<Image alt="CCSA Logo" width={72} height={59} src="/logo.svg" />
</Link>
</li>
<li className="py-5 text-center">
<Link className="flex flex-col items-center justify-center gap-1" href="/">
<LuMap className="h-6 w-6" />
Explore datasets
</Link>
</li>
<li className="py-5 text-center">
<Link className="flex flex-col items-center justify-center gap-1" href="/projects">
<LuList className="h-6 w-6" />
Projects
</Link>
</li>
</ul>
</nav>
);
};

export default Navigation;
13 changes: 13 additions & 0 deletions client/src/containers/projects/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use client";

const Projects = (): JSX.Element => {
return (
<div className="flex h-full overflow-auto">
<div className="p-5">
<h1 className="text-3xl">Projects</h1>
</div>
</div>
);
};

export default Projects;
39 changes: 39 additions & 0 deletions client/src/containers/sidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"use client";

import { PropsWithChildren, useState } from "react";

import { LuChevronLeft } from "react-icons/lu";

import { cn } from "@/lib/classnames";

const Sidebar = ({ children }: PropsWithChildren): JSX.Element => {
const [open, setOpen] = useState(true);

const toggleOpen = () => setOpen((prev) => !prev);

return (
<aside
className={cn({
"absolute left-20 top-0 z-10 h-full w-full max-w-md bg-white transition-transform duration-300 ease-in-out":
true,
"-translate-x-full": !open,
})}
>
{children}

<button
className="absolute left-full top-0 rounded-r-lg bg-white py-2.5"
onClick={toggleOpen}
>
<LuChevronLeft
className={cn({
"h-5 w-5 transition-transform delay-300 duration-300 ease-in-out": true,
"rotate-180": !open,
})}
/>
</button>
</aside>
);
};

export default Sidebar;

0 comments on commit 4e105fb

Please sign in to comment.