Skip to content

armgit / mapcn

Public Imported from GitHub
0

Beautiful map components. 100% Free, Zero config, one command setup.

TypeScript

update: refine page header sizing and block preview layou

anmolcf3724cfc0a4
diff --git a/src/app/(main)/(home)/_components/get-started-actions.tsx b/src/app/(main)/(home)/_components/get-started-actions.tsx
index ee14f82..48d7ebc 100644
--- a/src/app/(main)/(home)/_components/get-started-actions.tsx
+++ b/src/app/(main)/(home)/_components/get-started-actions.tsx
@@ -51,7 +51,7 @@ export function GetStartedActions() {
</Button>
)}
- <ButtonGroupSeparator className="bg-primary-foreground" />
+ <ButtonGroupSeparator />
<DropdownMenu>
<DropdownMenuTrigger asChild>
@@ -95,7 +95,7 @@ export function GetStartedActions() {
</ButtonGroup>
{copied && (
- <p className="animate-fade-in text-muted-foreground absolute top-full left-0 mt-2 flex items-center gap-1.5 text-xs whitespace-nowrap">
+ <p className="animate-fade-up text-muted-foreground absolute top-full left-0 mt-2 flex items-center gap-1 text-xs whitespace-nowrap">
<Check className="size-3.5" />
Copied - paste this into your coding agent!
</p>
diff --git a/src/app/(main)/blocks/_components/block-preview.tsx b/src/app/(main)/blocks/_components/block-preview.tsx
index b6be2ef..99fb94a 100644
--- a/src/app/(main)/blocks/_components/block-preview.tsx
+++ b/src/app/(main)/blocks/_components/block-preview.tsx
@@ -1,7 +1,7 @@
"use client";
import { useState } from "react";
-import { Check, Fullscreen, Terminal } from "lucide-react";
+import { Check, Maximize, Terminal } from "lucide-react";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Button } from "@/components/ui/button";
import { RegistryBlockItem, type FileTree } from "@/lib/blocks";
@@ -41,9 +41,9 @@ export function BlockPreview({
}
>
<div>
- <h2 className="text-xl font-semibold tracking-tight">{title}</h2>
+ <h2 className="text-lg font-semibold tracking-tight">{title}</h2>
{description && (
- <p className="text-muted-foreground mt-1 text-sm">{description}</p>
+ <p className="text-muted-foreground mt-0.5 text-sm">{description}</p>
)}
</div>
@@ -58,27 +58,28 @@ export function BlockPreview({
</TabsTrigger>
</TabsList>
- <div className="hidden items-center gap-3 md:flex">
- <Button
- variant="outline"
- size="icon-sm"
- asChild
- aria-label="Open in new tab"
- >
- <Link href={`/view/${name}`} target="_blank">
- <Fullscreen />
- </Link>
- </Button>
- <Separator orientation="vertical" className="h-4!" />
+ <div className="hidden items-center gap-2.5 md:flex">
<Button
onClick={copyCli}
variant="outline"
aria-label="Copy CLI command"
size="sm"
+ className="font-mono text-xs"
>
{copiedType === "cli" ? <Check /> : <Terminal />}
npx shadcn add @mapcn/{name}
</Button>
+ <Separator orientation="vertical" className="h-4!" />
+ <Button
+ variant="outline"
+ size="icon-sm"
+ asChild
+ aria-label="Open in new tab"
+ >
+ <Link href={`/view/${name}`} target="_blank">
+ <Maximize />
+ </Link>
+ </Button>
</div>
</div>
diff --git a/src/app/(main)/blocks/page.tsx b/src/app/(main)/blocks/page.tsx
index cc6f364..acf24a2 100644
--- a/src/app/(main)/blocks/page.tsx
+++ b/src/app/(main)/blocks/page.tsx
@@ -1,11 +1,8 @@
import {
- PageActions,
PageHeader,
PageHeaderDescription,
PageHeaderHeading,
} from "@/components/page-header";
-import { Button } from "@/components/ui/button";
-import Link from "next/link";
import { Footer } from "@/components/footer";
import { Metadata } from "next";
import { getAllBlocks } from "@/lib/blocks";
@@ -13,7 +10,7 @@ import { BlockDisplay } from "./_components/block-display";
import { type CSSProperties } from "react";
export const metadata: Metadata = {
- title: "Map blocks for your application",
+ title: "Map Blocks",
description:
"Pre-built, ready-to-use map blocks. Browse, preview, and copy them into your app with one command.",
};
@@ -23,22 +20,12 @@ export default async function Page() {
return (
<>
- <PageHeader align="left">
- <PageHeaderHeading className="font-semibold md:text-5xl">
- Map blocks for your application
- </PageHeaderHeading>
- <PageHeaderDescription className="md:text-lg">
+ <PageHeader align="left" size="sm">
+ <PageHeaderHeading>Map Blocks</PageHeaderHeading>
+ <PageHeaderDescription>
Pre-built, ready-to-use map blocks. Browse, preview, and copy them
into your app with one command.
</PageHeaderDescription>
- <PageActions>
- <Button asChild>
- <a href="#blocks">Browse Blocks</a>
- </Button>
- <Button variant="outline" asChild>
- <Link href="/docs">View Documentation</Link>
- </Button>
- </PageActions>
</PageHeader>
<section
diff --git a/src/components/page-header.tsx b/src/components/page-header.tsx
index e9cb66f..5bf2c59 100644
--- a/src/components/page-header.tsx
+++ b/src/components/page-header.tsx
@@ -4,9 +4,14 @@ import { cn } from "@/lib/utils";
import { createContext, useContext, type CSSProperties } from "react";
type HeaderAlign = "center" | "left";
+type HeaderSize = "default" | "sm";
-const PageHeaderContext = createContext<{ align: HeaderAlign }>({
+const PageHeaderContext = createContext<{
+ align: HeaderAlign;
+ size: HeaderSize;
+}>({
align: "center",
+ size: "default",
});
function usePageHeaderContext() {
@@ -18,14 +23,24 @@ interface PageHeaderProps {
className?: string;
/** Header content alignment (default: center) */
align?: HeaderAlign;
+ /** Visual scale of the header (default: "default") */
+ size?: HeaderSize;
}
-function PageHeader({ children, className, align = "center" }: PageHeaderProps) {
+function PageHeader({
+ children,
+ className,
+ align = "center",
+ size = "default",
+}: PageHeaderProps) {
return (
- <PageHeaderContext.Provider value={{ align }}>
+ <PageHeaderContext.Provider value={{ align, size }}>
<section
className={cn(
- "container mx-auto flex w-full max-w-6xl flex-col gap-4 py-16 md:py-20 lg:py-24",
+ "container mx-auto flex w-full max-w-6xl flex-col",
+ size === "sm"
+ ? "gap-3 py-14 md:py-16"
+ : "gap-4 py-16 md:py-20 lg:py-24",
align === "center"
? "items-center text-center"
: "items-start text-left",
@@ -49,12 +64,15 @@ function PageHeaderHeading({
className,
as: Comp = "h1",
}: PageHeaderHeadingProps) {
- const { align } = usePageHeaderContext();
+ const { align, size } = usePageHeaderContext();
return (
<Comp
className={cn(
- "animate-fade-up animate-stagger max-w-4xl text-4xl font-bold tracking-tight sm:text-5xl md:text-6xl",
+ "animate-fade-up animate-stagger max-w-4xl font-bold tracking-tight",
+ size === "sm"
+ ? "text-3xl font-semibold md:text-4xl"
+ : "text-4xl sm:text-5xl md:text-6xl",
align === "center" ? "text-center" : "text-left",
className,
)}
@@ -80,12 +98,15 @@ function PageHeaderDescription({
children,
className,
}: PageHeaderDescriptionProps) {
- const { align } = usePageHeaderContext();
+ const { align, size } = usePageHeaderContext();
return (
<p
className={cn(
- "text-foreground/80 animate-fade-up animate-stagger max-w-2xl leading-relaxed sm:text-lg sm:leading-relaxed md:text-xl md:leading-relaxed",
+ "text-foreground/80 animate-fade-up animate-stagger max-w-2xl leading-relaxed",
+ size === "sm"
+ ? "text-muted-foreground text-base sm:text-lg"
+ : "sm:text-lg md:text-xl",
align === "center" ? "text-center" : "text-left",
className,
)}