Skip to content

Commit 5f2c780

Browse files
abdoutclaude
andcommitted
fix: restore original PageHeader with props-based API
- Restored original props-based API (heading, description, actions, announcement) - Added border-grid border-b-[0.5px] back to section - Restored hero.tsx to use TwoButtons component - Kept subcomponent exports for backward compatibility Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 747cb3b commit 5f2c780

2 files changed

Lines changed: 82 additions & 51 deletions

File tree

src/components/atom/page-header.tsx

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,75 @@
11
import { cn } from "@/lib/utils"
22
import React from "react"
33

4-
function PageHeader({
4+
interface PageHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
5+
heading?: string | React.ReactNode
6+
description?: string | React.ReactNode
7+
actions?: React.ReactNode
8+
announcement?: React.ReactNode
9+
headingClassName?: string
10+
descriptionClassName?: string
11+
actionsClassName?: string
12+
announcementClassName?: string
13+
}
14+
15+
export function PageHeader({
516
className,
17+
heading,
18+
description,
19+
actions,
20+
announcement,
21+
headingClassName,
22+
descriptionClassName,
23+
actionsClassName,
24+
announcementClassName,
625
children,
726
...props
8-
}: React.ComponentProps<"section">) {
27+
}: PageHeaderProps) {
928
return (
10-
<section className={cn(className)} {...props}>
29+
<section className={cn("border-grid border-b-[0.5px]", className)} {...props}>
1130
<div className="flex flex-col items-start gap-1 py-8 md:py-10 lg:py-12">
31+
{announcement && (
32+
<div className={cn(announcementClassName)}>
33+
{announcement}
34+
</div>
35+
)}
36+
{heading && (
37+
<h2
38+
className={cn(
39+
headingClassName
40+
)}
41+
>
42+
{heading}
43+
</h2>
44+
)}
45+
{description && (
46+
<p
47+
className={cn(
48+
"max-w-2xl text-balance text-base font-light text-foreground leading-7 sm:text-lg ",
49+
descriptionClassName
50+
)}
51+
>
52+
{description}
53+
</p>
54+
)}
55+
{actions && (
56+
<div
57+
className={cn(
58+
"flex w-full items-center justify-start gap-2 pt-2",
59+
actionsClassName
60+
)}
61+
>
62+
{actions}
63+
</div>
64+
)}
1265
{children}
1366
</div>
1467
</section>
1568
)
1669
}
1770

18-
function PageHeaderHeading({
71+
// Subcomponents for composition-based usage (backward compatibility)
72+
export function PageHeaderHeading({
1973
className,
2074
...props
2175
}: React.ComponentProps<"h1">) {
@@ -30,7 +84,7 @@ function PageHeaderHeading({
3084
)
3185
}
3286

33-
function PageHeaderDescription({
87+
export function PageHeaderDescription({
3488
className,
3589
...props
3690
}: React.ComponentProps<"p">) {
@@ -45,7 +99,7 @@ function PageHeaderDescription({
4599
)
46100
}
47101

48-
function PageActions({ className, ...props }: React.ComponentProps<"div">) {
102+
export function PageActions({ className, ...props }: React.ComponentProps<"div">) {
49103
return (
50104
<div
51105
className={cn(
@@ -56,5 +110,3 @@ function PageActions({ className, ...props }: React.ComponentProps<"div">) {
56110
/>
57111
)
58112
}
59-
60-
export { PageActions, PageHeader, PageHeaderDescription, PageHeaderHeading }

src/components/root/hero.tsx

Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,28 @@
1-
import Link from "next/link"
2-
import { Plus } from "lucide-react"
3-
4-
import { Announcement } from "@/components/atom/announcement"
5-
import {
6-
PageHeader,
7-
PageHeaderHeading,
8-
PageHeaderDescription,
9-
PageActions,
10-
} from "@/components/atom/page-header"
11-
import { Button } from "@/components/ui/button"
12-
import type { getDictionary } from "@/components/local/dictionaries"
13-
import type { Locale } from "@/components/local/config"
14-
15-
const title = "The Foundation for your Design System"
16-
const description =
17-
"A set of beautifully designed components that you can customize, extend, and build on. Start here then make it your own. Open Source. Open Code."
1+
import { PageHeader } from '@/components/atom/page-header';
2+
import { Announcement } from '@/components/atom/announcement';
3+
import { TwoButtons } from '@/components/atom/two-buttons';
4+
import type { getDictionary } from '@/components/local/dictionaries';
5+
import type { Locale } from '@/components/local/config';
186

197
interface HeroProps {
20-
dictionary: Awaited<ReturnType<typeof getDictionary>>
21-
params: { lang: Locale }
8+
dictionary: Awaited<ReturnType<typeof getDictionary>>;
9+
params: { lang: Locale };
2210
}
2311

2412
export default function Hero({ dictionary, params }: HeroProps) {
25-
return (
26-
<PageHeader>
27-
<Announcement dictionary={dictionary} />
28-
<PageHeaderHeading className="max-w-4xl">
29-
{dictionary.homepage?.heading || title}
30-
</PageHeaderHeading>
31-
<PageHeaderDescription>
32-
{dictionary.homepage?.description || description}
33-
</PageHeaderDescription>
34-
<PageActions>
35-
<Button asChild size="sm" className="h-[31px] rounded-lg">
36-
<Link href={`/${params.lang}/docs`}>
37-
<Plus className="size-4" />
38-
{dictionary.actions?.newProject || "New Project"}
39-
</Link>
40-
</Button>
41-
<Button asChild size="sm" variant="ghost" className="rounded-lg">
42-
<Link href={`/${params.lang}/docs/components`}>
43-
{dictionary.actions?.viewComponents || "View Components"}
44-
</Link>
45-
</Button>
46-
</PageActions>
47-
</PageHeader>
48-
)
13+
return (
14+
<PageHeader
15+
announcement={<Announcement dictionary={dictionary} />}
16+
heading={dictionary.homepage?.heading || "Build your code library"}
17+
description={dictionary.homepage?.description || "A set of beautifully-designed, blazing-fast code. Works with your favorite frameworks. Open Source. Open Code."}
18+
actions={
19+
<TwoButtons
20+
primaryLabel={dictionary.actions?.getStarted || "Get Started"}
21+
primaryHref={`/${params.lang}/docs`}
22+
secondaryLabel={dictionary.actions?.documentation || "Documentation"}
23+
secondaryHref={`/${params.lang}/docs`}
24+
/>
25+
}
26+
/>
27+
);
4928
}

0 commit comments

Comments
 (0)