Skip to content

Commit

Permalink
refactor(web): pages
Browse files Browse the repository at this point in the history
  • Loading branch information
krystxf committed Dec 8, 2024
1 parent c34b34a commit b520402
Show file tree
Hide file tree
Showing 24 changed files with 84 additions and 79 deletions.
19 changes: 19 additions & 0 deletions apps/web/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ const nextConfig = {
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
},
async redirects() {
return [
{
source: "/docs",
destination: "/",
permanent: true,
},
{
source: "/docs/privacy-policy",
destination: "/privacy-policy",
permanent: true,
},
{
source: "/docs/terms-and-conditions",
destination: "/terms-and-conditions",
permanent: true,
},
];
},
};

const withNextra = nextra({
Expand Down
9 changes: 5 additions & 4 deletions apps/web/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { Metadata } from "next";
import "./globals.css";
import { poppins } from "./fonts";
import "@/styles/globals.css";
import { poppins } from "@/fonts";
import { Navbar } from "@/components/Navbar";
import { Footer } from "@/components/Footer";
import { getTitle } from "@/utils/metadata.utils";

const WEB_URL = new URL("https://metronow.dev");

Expand All @@ -13,7 +14,7 @@ const appleAppLink = {
} as const;

export const metadata: Metadata = {
title: "Metro Now",
title: getTitle(),
description: "Prague public transport app",
category: "Public transport",
keywords: ["prague", "praha", "public transport", "metro", "tram", "bus"],
Expand Down Expand Up @@ -49,7 +50,7 @@ export default function RootLayout({
return (
<html lang="en">
<body className={poppins.className}>
<div className="dark:bg-black min-h-screen">
<div className="dark:bg-black">
<Navbar variant="transparent" />

{children}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
"use client";

import MapGL, { Source, Layer } from "react-map-gl";
import { useState, useEffect } from "react";
import { useState } from "react";
import { pragueCoorinates } from "@/constants/coordinates";
import { getStopsGeojson } from "@/components/sections/MapSection/functions/getStopsGeojson";
import { pointsLayer } from "@/components/sections/MapSection/layers/point-layer";
import { heatmapLayer } from "@/components/sections/MapSection/layers/heatmap-layer";
import { pointsLayer } from "@/app/map/map-layers/point-layer";
import { heatmapLayer } from "@/app/map/map-layers/heatmap-layer";
import { PidLogo } from "@/components/PidLogo/PidLogo";

export const MapSection = () => {
const [allowZoom, setAllowZoom] = useState(false);
const [stopsGeojson, setStopsGeojson] = useState<null | object>(null);

const updateStopsGeojson = async () => {
const data = await getStopsGeojson();
setStopsGeojson(data);
};
export const MapClientPage = (props) => {
const { stopsGeojson } = props;

useEffect(() => {
updateStopsGeojson();
}, []);
const [allowZoom, setAllowZoom] = useState(false);

return (
<div
Expand All @@ -34,7 +25,7 @@ export const MapSection = () => {
</span>
</div>

<div className="h-[60vh] w-full">
<div className="h-[80vh] w-full relative">
<MapGL
initialViewState={{
...pragueCoorinates,
Expand All @@ -43,18 +34,19 @@ export const MapSection = () => {
dragRotate={false}
maxZoom={18}
minZoom={5}
boxZoom={false}
style={{
position: "relative",
display: "block",
}}
boxZoom={false}
keyboard={false}
scrollZoom={allowZoom}
mapStyle="mapbox://styles/mapbox/dark-v9"
mapboxAccessToken={process.env.NEXT_PUBLIC_MAPBOX_TOKEN}
attributionControl={false}
>
{stopsGeojson && (
<Source type="geojson" data={stopsGeojson}>
<Source type="geojson" data={stopsGeojson as any}>
<Layer {...heatmapLayer} />
<Layer {...pointsLayer} />
</Source>
Expand Down
15 changes: 15 additions & 0 deletions apps/web/src/app/map/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { getTitle } from "@/utils/metadata.utils";
import { Metadata } from "next";

export const metadata: Metadata = {
title: getTitle("Map"),
description: "Metro Now area coverage",
};

export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return children;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const heatmapLayer: LayerProps = {
"heatmap-radius": {
stops: [
[11, 5],
[15, 20],
[15, 50],
],
},
// decrease opacity to transition into the circle layer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
"use server";

import { MapClientPage } from "./client-page";

type Datapoint = {
latitude: number;
longitude: number;
name: string;
};
export const getStopsGeojson = async () => {

export default async function MapPage() {
const res = await fetch("https://api.metronow.dev/v1/platform/all");
const data: Datapoint[] = await res.json();

Expand All @@ -20,5 +23,5 @@ export const getStopsGeojson = async () => {
})),
};

return geojson;
};
return <MapClientPage stopsGeojson={geojson} />;
}
2 changes: 0 additions & 2 deletions apps/web/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import DownloadOnAppStoreLight from "../../public/download-on-appstore-light.svg
import MetroNowIcon from "../../public/metro-now-icon.png";
import MetroNowIphoneMockup from "../../public/iphone-mockup.png";
import { FeaturesSection } from "@/components/sections/FeaturesSection";
import { MapSection } from "@/components/sections/MapSection";

export default function LandingPage() {
return (
Expand Down Expand Up @@ -63,7 +62,6 @@ export default function LandingPage() {
</div>
</main>

<MapSection />
<FeaturesSection />
</>
);
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { HOMEPAGE_URL } from "../constants/api";
import { HOMEPAGE_URL } from "@/constants/api";
import type { MetadataRoute } from "next";

const docsPaths = [
"/map",
"/docs",
"/docs/backend",
"/docs/privacy-policy",
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ export const Footer = () => {
<FooterSectionHeading className="mt-8">
Legal
</FooterSectionHeading>
<FooterLink href="/docs/terms-and-conditions">
<FooterLink href="/terms-and-conditions">
Terms & conditions
</FooterLink>
<FooterLink href="/docs/privacy-policy">
<FooterLink href="/privacy-policy">
Privacy policy
</FooterLink>
</FooterSection>
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export const Navbar = (props: Props) => {
<div className="gap-12 sm:flex hidden">
<NavbarLink href={"/"}>About</NavbarLink>

<NavbarLink href={"/map"}>Map</NavbarLink>

<NavbarLink href={SOURCE_CODE_URL} target="_blank">
Source Code
</NavbarLink>
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/components/sections/MapSection/index.ts

This file was deleted.

File renamed without changes.
1 change: 1 addition & 0 deletions apps/web/src/fonts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { poppins } from "@/fonts/fonts";
18 changes: 9 additions & 9 deletions apps/web/src/pages/_meta.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"docs": {
"title": "Docs",
"type": "page"
{
"home":{
"title": "Home",
"href": "/",
"type": "link"
},

"api": {
"title": "API",
"title": "Home",
"type": "page",
"href": "/docs/api"
"href": "/"
},
"legal": {
"title": "Legal",
"type": "menu",
"items": {
"about": {
"title": "Privacy policy",
"href": "/docs/privacy-policy"
"href": "/privacy-policy"
},
"contact": {
"title": "Terms & conditions",
"href": "/docs/terms-and-conditions"
"href": "/terms-and-conditions"
}
}
}
Expand Down
12 changes: 0 additions & 12 deletions apps/web/src/pages/docs/_meta.json

This file was deleted.

4 changes: 0 additions & 4 deletions apps/web/src/pages/docs/api.mdx

This file was deleted.

9 changes: 0 additions & 9 deletions apps/web/src/pages/docs/backend.mdx

This file was deleted.

12 changes: 0 additions & 12 deletions apps/web/src/pages/docs/index.mdx

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
html {
scroll-behavior: smooth;
}

[mapboxgl-children] {
height: auto !important;
}
7 changes: 7 additions & 0 deletions apps/web/src/utils/metadata.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const getTitle = (title?: string | null) => {
if (!title) {
return "Metro Now";
}

`${title} | Metro Now`;
};
2 changes: 1 addition & 1 deletion apps/web/theme.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from "react";

const themeConfig = {
logo: <strong>🚇 metro-now</strong>,
docsRepositoryBase: `${SOURCE_CODE_URL}/tree/main/docs`,
docsRepositoryBase: `${SOURCE_CODE_URL}/tree/main/apps/web`,
project: {
link: SOURCE_CODE_URL,
},
Expand Down

1 comment on commit b520402

@vercel
Copy link

@vercel vercel bot commented on b520402 Dec 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.