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

[CHORE]: Move ecosystem page to App router #724

Merged
merged 1 commit into from
Jul 30, 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
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import { Button, ButtonVariants } from 'apps/web/src/components/Button/Button';
import EcosystemHeroLogos from 'apps/web/public/images/ecosystem-hero-logos-new.png';
import { Divider } from 'apps/web/src/components/Divider/Divider';
import { List } from 'apps/web/src/components/Ecosystem/List';
import { Button, ButtonVariants } from 'apps/web/src/components/Button/Button';
import Head from 'next/head';
import type { Metadata } from 'next';
import Image from 'next/image';

function EcosystemHero() {
export const metadata: Metadata = {
metadataBase: new URL('https://base.org'),
title: `Base | About`,
openGraph: {
title: `Base | About`,
url: `/about`,
},
};

async function EcosystemHero() {
return (
<div className="mt-[-96px] flex w-full flex-col items-center bg-black pb-[96px]">
<div className="flex w-full max-w-[1440px] flex-col items-center justify-center gap-12 px-8 py-8 pt-28 md:flex-row">
Expand Down Expand Up @@ -34,30 +43,12 @@ function EcosystemHero() {
);
}

export default function Ecosystem() {
const ogData = {
title: 'Base | Ecosystem',
description: 'An overview of apps and integrations in the Base ecosystem.',

url: 'https://base.org/base-ecosystem',
};
export default async function Ecosystem() {
return (
<div>
<Head>
{/* Open-graph */}
<meta key="og:url" property="og:url" content={ogData.url} />
<meta key="og:title" property="og:title" content={ogData.title} />
<meta key="og:description" property="og:description" content={ogData.description} />

{/* Default */}
<title key="title">{ogData.title}</title>
<meta key="description" content={ogData.description} name="description" />
</Head>
<main className="flex w-full flex-col items-center bg-black">
<EcosystemHero />
<Divider />
<List />
</main>
</div>
<main className="flex w-full flex-col items-center bg-black">
<EcosystemHero />
<Divider />
<List />
</main>
);
}
31 changes: 15 additions & 16 deletions apps/web/src/components/Ecosystem/List.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
'use client';

import { useCallback, useMemo, useState } from 'react';
import ErrorImg from 'apps/web/public/images/error.png';
import data from 'apps/web/src/data/ecosystem.json';
import Image from 'next/image';

import { Button } from '../Button/Button';

import { Card } from './Card';
import { SearchBar } from './SearchBar';
import { TagChip } from './TagChip';
import { useRouter } from 'next/router';
import { usePathname, useRouter, useSearchParams } from 'next/navigation';

const TagList = [
'all',
Expand Down Expand Up @@ -44,23 +44,22 @@ const decoratedData = orderedDataAsc().map((d) => ({
}));

export function List() {
const [selectedTag, setSelectedTag] = useState('all');
const router = useRouter();

const pathname = usePathname();
const searchParams = useSearchParams();
const selectedTag = searchParams?.get('tag') ?? 'all';

const [searchText, setSearchText] = useState('');
const [showNum, setShowNum] = useState(16);

// Read select tag query parameter from URL
const router = useRouter();
useEffect(() => {
if (router.query.tag) {
setSelectedTag(router.query.tag as string);
}
}, [router.query.tag]);

const selectTag = useCallback(
(tag: string) => {
void router.push({ query: { tag } });
const params = new URLSearchParams();
params.set('tag', tag);
router.push(pathname + '?' + params.toString(), { scroll: false });
},
[router],
[pathname, router],
);

const filteredApps = useMemo(
Expand All @@ -82,7 +81,7 @@ export function List() {
const showMore = useCallback(() => setShowNum((num) => num + 16), [setShowNum]);

return (
<div className="min-h-32 flex w-full max-w-[1440px] flex-col gap-10 px-8 pb-32">
<div className="flex min-h-32 w-full max-w-[1440px] flex-col gap-10 px-8 pb-32">
<div className="flex flex-col justify-between gap-8 lg:flex-row lg:gap-12">
<div className="flex flex-row flex-wrap gap-3">
{TagList.map((tag) => (
Expand Down
10 changes: 7 additions & 3 deletions apps/web/src/components/Ecosystem/TagChip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ type Props = {
};

export function TagChip({ tag, isSelected, setSelectedTag }: Props) {
const select = useCallback(() => {
setSelectedTag(tag);
}, [tag, setSelectedTag]);
const select = useCallback(
(event: React.MouseEvent<HTMLButtonElement>) => {
event.preventDefault();
setSelectedTag(tag);
},
[tag, setSelectedTag],
);

return (
<button type="button" onClick={select}>
Expand Down
Loading