Skip to content

Commit 5530faa

Browse files
committed
basic styling redesign
1 parent e0f300e commit 5530faa

21 files changed

+487
-93
lines changed

src/app/(home)/_components/pagination.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const Card = ({
1818
}) => {
1919
if (disable) {
2020
return (
21-
<div className="rounded-full border bg-card p-2 text-muted-foreground">
21+
<div className="rounded-full border bg-card p-2 text-muted-foreground opacity-30">
2222
{children}
2323
</div>
2424
);
@@ -42,29 +42,21 @@ export const Pagination = ({
4242
path: string;
4343
}) => {
4444
return (
45-
<div className="flex justify-center gap-2">
45+
<div className="flex justify-center gap-4">
4646
<Card num={1} disable={current === 1}>
47-
<h2 className="text-xl font-medium">
48-
<ChevronsLeft />
49-
</h2>
47+
<ChevronsLeft />
5048
</Card>
5149
<Card num={current - 1} disable={current === 1}>
52-
<h2 className="text-xl font-medium">
53-
<ChevronLeft />
54-
</h2>
50+
<ChevronLeft />
5551
</Card>
56-
<div className="my-auto text-xl mx-2">
57-
{current} / {end}
52+
<div className="my-auto mx-4 font-normal text-md text-fd-muted-foreground">
53+
Page {current} of {end}
5854
</div>
5955
<Card num={current + 1} disable={current === end}>
60-
<h2 className="text-xl font-medium">
61-
<ChevronRight />
62-
</h2>
56+
<ChevronRight />
6357
</Card>
6458
<Card num={end} disable={current === end}>
65-
<h2 className="text-xl font-medium">
66-
<ChevronsRight />
67-
</h2>
59+
<ChevronsRight />
6860
</Card>
6961
</div>
7062
);

src/app/(home)/_components/post-card.tsx

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Link from "next/link";
22
import Image from "next/image";
3-
import { formatDistance } from "date-fns";
3+
import { cn } from "@/utils";
4+
import { AbsoluteDate } from "@/app/_components/date-time";
5+
import { Subtitle } from "@/app/_components/typography";
46

57
export const PostCard = ({
68
title,
@@ -20,25 +22,40 @@ export const PostCard = ({
2022
return (
2123
<Link
2224
href={url}
23-
className="rounded-lg border bg-card p-4 text-card-foreground transition-colors hover:bg-accent hover:text-accent-foreground w-full"
25+
className={cn(
26+
"block w-full relative p-px bg-fd-background text-zinc-600 dark:text-zinc-300",
27+
"border border-solid border-zinc-400 dark:border-zinc-500",
28+
"hover:border-zinc-900 hover:dark:border-zinc-100",
29+
"shadow-[1.5px_1.5px_theme('colors.zinc.300')] hover:shadow-[3px_3px_theme('colors.zinc.300')]",
30+
"dark:shadow-[1.5px_1.5px_theme('colors.zinc.600')] dark:hover:shadow-[3px_3px_theme('colors.zinc.600')]",
31+
"hover:-translate-x-px hover:-translate-y-px",
32+
"active:translate-x-px active:translate-y-px active:opacity-70",
33+
"transition-all duration-150 ease-out",
34+
"overflow-clip grid md:grid-cols-4"
35+
)}
2436
>
25-
<div className="space-x-4 justify-between p-2">
26-
<div className="flex flex-col space-y-4">
27-
<h2 className="mt-2 text-xl font-medium">{title}</h2>
28-
<p className="overflow-hidden overflow-ellipsis whitespace-nowrap text-medium text-muted-foreground text-wrap">
29-
{description}
30-
</p>
31-
<h3 className="text-left font-medium pt-2">{`${formatDistance(new Date(), date)} ago`}</h3>
32-
</div>
33-
{/* <div className="hidden lg:block">
34-
<Image
35-
src={image}
36-
alt={alt}
37-
height={400}
38-
width={400}
39-
className="mx-auto"
40-
></Image>
41-
</div> */}
37+
<div
38+
className={cn(
39+
"md:col-span-2 place-items-center",
40+
"border-solid border-r-fd-background border-r"
41+
)}
42+
>
43+
<Image
44+
draggable={false}
45+
src={image}
46+
alt={alt}
47+
height={400}
48+
width={400}
49+
className="object-cover object-center md:object-fit w-full h-auto"
50+
/>
51+
</div>
52+
<div className={cn("md:col-span-2 space-y-3", "px-6 py-8 md:px-8 md:py-6")}>
53+
<Subtitle style="!text-2xl !leading-[1.15]">{title}</Subtitle>
54+
<p className="text-medium leading-tight line-clamp-4">{description}</p>
55+
<AbsoluteDate
56+
date={date}
57+
className="block text-fd-muted-foreground font-medium"
58+
/>
4259
</div>
4360
</Link>
4461
);

src/app/(home)/layout.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,43 @@
11
import { HomeLayout as HL } from "fumadocs-ui/home-layout";
22
import type { ReactNode } from "react";
33
import FullLogo from "./_components/full-logo";
4+
import { Footer } from "../_components/footer";
45

56
const HomeLayout = ({ children }: { children: ReactNode }) => {
67
return (
78
<HL
89
nav={{
910
title: (
10-
<div className="invert-0 group-hover:invert py-2 rounded backdrop-blur px-2 group space-x-2 flex items-center">
11-
<FullLogo height={28} />
11+
<div className="py-4 text-fd-primary">
12+
<FullLogo height={22} />
1213
</div>
1314
),
14-
url: "https://substrate.run/",
15+
url:
16+
process.env.VERCEL_ENV === "production" ||
17+
process.env.VERCEL_ENV === "preview"
18+
? "https://www.substrate.run/"
19+
: "/",
1520
}}
16-
githubUrl="https://github.com/SubstrateLabs/blog"
21+
// Previously, this added a prominent GitHub link to the header nav.
22+
// It was confusing because that link points to the blog repo,
23+
// an open-source repo for the Substrate codebase, as one may expect.
24+
// The blog repo is less useful to link to, now that there are links
25+
// to GitHub from the "Edit this page" links at the bottom of each
26+
// blog post page.
27+
// githubUrl="https://github.com/SubstrateLabs/blog"
1728
links={[
1829
{ text: "Docs", url: "https://docs.substrate.run" },
1930
{ text: "Nodes", url: "https://substrate.run/nodes" },
2031
{ text: "Pricing", url: "https://substrate.run/pricing" },
2132
{ text: "Company", url: "https://substrate.run/company" },
22-
{ text: "Blog", url: "https://substrate.run/blog" },
33+
// Highlight the "Blog" nav link when the URL is `/blog` or a child route.
34+
{ text: "Blog", url: "/", active: "nested-url" },
2335
]}
2436
>
2537
{children}
38+
<div className="px-4 pt-10 md:px-6 md:pt-12">
39+
<Footer />
40+
</div>
2641
</HL>
2742
);
2843
};

src/app/(home)/page.tsx

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { getPages } from "@/app/source";
2+
import { cn } from "@/utils";
3+
import { H1 } from "../_components/typography";
24
import { PostCard } from "./_components/post-card";
35
import { Pagination } from "./_components/pagination";
46
import { notFound } from "next/navigation";
@@ -14,7 +16,10 @@ const HomePage = ({
1416
params: { slug: string };
1517
searchParams?: { [key: string]: string | string[] | undefined };
1618
}) => {
17-
const pageIndex = searchParams && typeof searchParams["page"] == "string" ? Number.parseInt(searchParams["page"]) : 0;
19+
const pageIndex =
20+
searchParams && typeof searchParams["page"] == "string"
21+
? Number.parseInt(searchParams["page"])
22+
: 0;
1823

1924
if (pageIndex < 0 || pageIndex >= pageCount) notFound();
2025

@@ -25,12 +30,21 @@ const HomePage = ({
2530
.slice(startIndex, endIndex);
2631

2732
return (
28-
<main>
29-
<div className="mx-4 my-6 lg:mx-auto lg:w-[992px]">
30-
<div className="my-6 text-3xl">
31-
<p>Blog</p>
32-
</div>
33-
<div className="flex flex-col gap-4 text-left">
33+
<main
34+
className={cn(
35+
"max-w-[60rem] mx-auto my-14",
36+
"px-4 pt-10 md:px-6 md:pt-12"
37+
)}
38+
>
39+
<H1>Substrate Blog</H1>
40+
<div
41+
className={cn(
42+
"mt-12 mb-8 p-4 -mx-4 relative",
43+
"transform-gpu" // Fixes a Safari rendering quirk with PostCard's :hover/:active transforms
44+
)}
45+
>
46+
<div className="absolute inset-0 bg-[radial-gradient(theme('colors.zinc.400')_0.5px,transparent_0.5px)] dark:bg-[radial-gradient(theme('colors.zinc.600')_0.5px,transparent_0.5px)] bg-[length:3.75px_3.75px]" />
47+
<div className="space-y-5">
3448
{posts.map((post) => {
3549
const date = new Date(post.data.date).toLocaleDateString();
3650
return (
@@ -46,10 +60,8 @@ const HomePage = ({
4660
);
4761
})}
4862
</div>
49-
<div className="my-6">
50-
<Pagination current={pageIndex + 1} end={pageCount} path="" />
51-
</div>
5263
</div>
64+
<Pagination current={pageIndex + 1} end={pageCount} path="" />
5365
</main>
5466
);
5567
};

src/app/_components/date-time.tsx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { formatDistance } from "date-fns";
2+
3+
// Format the date in format of "Jul 1, 2024" -
4+
// using the default locale of the visitor (or system on the server).
5+
const formatDate = (date: string) =>
6+
new Date(date).toLocaleDateString([], {
7+
year: "numeric",
8+
month: "short",
9+
day: "numeric",
10+
});
11+
12+
// Format the date in format of "Jul 1, 2024 1:00 PM".
13+
const formatDateTime = (date: string) =>
14+
new Date(date).toLocaleDateString([], {
15+
year: "numeric",
16+
month: "short",
17+
day: "numeric",
18+
hour: "numeric",
19+
hour12: true,
20+
minute: "numeric",
21+
});
22+
23+
export const RelativeDate = ({
24+
date,
25+
className,
26+
...props
27+
}: {
28+
date: string;
29+
className?: string;
30+
props?: React.ComponentProps<"time">;
31+
}) => {
32+
return (
33+
<time {...props} title={formatDateTime(date)} className={className}>
34+
{formatDistance(new Date(), date)} ago
35+
</time>
36+
);
37+
};
38+
39+
export const AbsoluteDate = ({
40+
date,
41+
className,
42+
...props
43+
}: {
44+
date: string;
45+
className?: string;
46+
props?: React.ComponentProps<"time">;
47+
}) => {
48+
return (
49+
<time {...props} title={formatDateTime(date)} className={className}>
50+
{formatDate(date)}
51+
</time>
52+
);
53+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { type AnchorHTMLAttributes, forwardRef } from "react";
2+
import { Edit } from "lucide-react";
3+
import { cn } from "@/utils";
4+
5+
// Adapted from fumadocs source:
6+
// https://github.com/fuma-nama/fumadocs/blob/main/packages/ui/src/components/layout/edit-on-github.tsx
7+
interface EditOnGitHubOptions
8+
extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "href" | "children"> {
9+
owner: string;
10+
repo: string;
11+
12+
/**
13+
* SHA or ref (branch or tag) name.
14+
*
15+
* @defaultValue main
16+
*/
17+
sha?: string;
18+
19+
/**
20+
* File path in the repo
21+
*/
22+
path: string;
23+
}
24+
25+
export const EditOnGitHub = forwardRef<HTMLAnchorElement, EditOnGitHubOptions>(
26+
({ owner, repo, sha = "main", path, ...props }, ref) => {
27+
return (
28+
<a
29+
ref={ref}
30+
href={`https://github.com/${owner}/${repo}/blob/${sha}/${
31+
path.startsWith("/") ? path.slice(1) : path
32+
}`}
33+
target="_blank"
34+
rel="noreferrer noopener"
35+
{...props}
36+
className={cn(
37+
"items-center inline-flex w-auto gap-2 rounded border bg-fd-background py-1.5 px-3 text-xs text-fd-muted-foreground transition-colors hover:bg-fd-muted/80 hover:text-fd-accent-foreground",
38+
"transform-gpu no-underline",
39+
props.className
40+
)}
41+
>
42+
<Edit className="size-3.5" />
43+
Edit on GitHub
44+
</a>
45+
);
46+
}
47+
);

0 commit comments

Comments
 (0)