Skip to content

armgit / mapcn

Public Imported from GitHub
0

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

TypeScript

fix mobile screenshot view

Anmol116d3b18d77f
diff --git a/src/app/(main)/(home)/page.tsx b/src/app/(main)/(home)/page.tsx
index 0dc3c50..23fcfdf 100644
--- a/src/app/(main)/(home)/page.tsx
+++ b/src/app/(main)/(home)/page.tsx
@@ -1,6 +1,6 @@
import Link from "next/link";
import { CSSProperties } from "react";
-import { ArrowRight } from "lucide-react";
+import { ChevronRight } from "lucide-react";
import { HeroInstallCommand } from "./_components/hero-install-command";
import { MapWall } from "./_components/map-wall";
@@ -11,6 +11,7 @@ import {
PageHeaderDescription,
PageActions,
} from "@/components/page-header";
+import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
export default function Page() {
@@ -18,16 +19,19 @@ export default function Page() {
<>
<div className="flex-1">
<PageHeader animated className="pt-7 md:pt-12 lg:pt-18 lg:pb-16">
- <Link
- href="/docs/skill"
+ <Badge
+ asChild
+ variant="secondary"
style={{ "--stagger": 1 } as CSSProperties}
- className="animate-fade-up animate-stagger text-muted-foreground hover:text-foreground -mb-1 inline-flex items-center gap-1.5 text-[13px] font-medium transition-colors"
+ className="animate-fade-up animate-stagger bg-muted/50 text-foreground/80 ring-foreground/5 dark:bg-muted/30 [a&]:hover:bg-muted [a&]:hover:text-foreground dark:[a&]:hover:bg-muted/50 -mb-1 gap-0.5 py-1 pr-1.5 pl-2.5 ring-1"
>
- Agent skill for mapcn
- <ArrowRight className="size-3" />
- </Link>
+ <Link href="/docs/skill">
+ Agent skill for mapcn
+ <ChevronRight className="size-3.5" />
+ </Link>
+ </Badge>
<PageHeaderHeading>Beautiful maps, made simple</PageHeaderHeading>
- <PageHeaderDescription>
+ <PageHeaderDescription className="sm:text-wrap">
Ready to use, customizable map components for React.{" "}
<br className="hidden sm:block" />
Built on MapLibre. Styled with Tailwind.
diff --git a/src/app/(main)/blocks/[name]/page.tsx b/src/app/(main)/blocks/[name]/page.tsx
index 3e5fa70..cd026d1 100644
--- a/src/app/(main)/blocks/[name]/page.tsx
+++ b/src/app/(main)/blocks/[name]/page.tsx
@@ -71,11 +71,11 @@ export default async function BlockPage({ params }: BlockPageProps) {
variant="ghost"
size="sm"
asChild
- className="text-muted-foreground hover:text-foreground -ml-4 w-fit hover:bg-transparent!"
+ className="text-muted-foreground hover:text-foreground -ml-2.5 w-fit gap-1 hover:bg-transparent!"
>
<Link href="/blocks">
<ChevronLeft />
- Blocks
+ All Blocks
</Link>
</Button>
<PageHeaderHeading>{block.title}</PageHeaderHeading>
diff --git a/src/app/(main)/blocks/_components/block-preview.tsx b/src/app/(main)/blocks/_components/block-preview.tsx
index 89cc37a..c261ef0 100644
--- a/src/app/(main)/blocks/_components/block-preview.tsx
+++ b/src/app/(main)/blocks/_components/block-preview.tsx
@@ -2,6 +2,7 @@
import Link from "next/link";
import { Maximize } from "lucide-react";
+import { ThemedImage } from "@/components/themed-image";
import { Button } from "@/components/ui/button";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { type FileTree, type RegistryBlockItem } from "@/lib/blocks";
@@ -31,7 +32,7 @@ export function BlockPreview({
} as React.CSSProperties
}
>
- <div className="flex flex-wrap items-center justify-between gap-3">
+ <div className="flex flex-wrap items-center justify-between gap-3 max-md:hidden">
<TabsList className="bg-background dark:border-input dark:bg-input/30 h-8! gap-0.5 rounded-md border p-0.5 shadow-xs">
<TabsTrigger value="preview" className={tabTriggerClassName}>
Preview
@@ -57,15 +58,19 @@ export function BlockPreview({
</div>
<div className="bg-muted/50 ring-foreground/5 dark:bg-muted/30 rounded-2xl p-2 ring-1">
+ <div className="bg-background ring-foreground/5 relative aspect-[16/10] overflow-hidden rounded-lg shadow-xs ring-1 md:hidden">
+ <ThemedImage src={`/blocks/${block.name}`} sizes="100vw" />
+ </div>
+
<TabsContent
value="preview"
forceMount
- className="data-[state=inactive]:hidden"
+ className="data-[state=inactive]:hidden max-md:hidden"
>
{children}
</TabsContent>
- <TabsContent value="code">
+ <TabsContent value="code" className="max-md:hidden">
<BlockViewerCode tree={tree} highlightedFiles={highlightedFiles} />
</TabsContent>
</div>
diff --git a/src/app/(main)/blocks/_components/iframe-preview.tsx b/src/app/(main)/blocks/_components/iframe-preview.tsx
index fbc214c..a08bbf0 100644
--- a/src/app/(main)/blocks/_components/iframe-preview.tsx
+++ b/src/app/(main)/blocks/_components/iframe-preview.tsx
@@ -1,12 +1,39 @@
+"use client";
+
+import { useEffect, useRef } from "react";
+
interface IframePreviewProps {
src: string;
title: string;
}
export function IframePreview({ src, title }: IframePreviewProps) {
+ const ref = useRef<HTMLIFrameElement>(null);
+
+ useEffect(() => {
+ const iframe = ref.current;
+ if (
+ iframe?.contentDocument?.readyState === "complete" &&
+ iframe.contentWindow?.location.href !== "about:blank"
+ ) {
+ markLoaded(iframe);
+ }
+ }, []);
+
return (
<div className="bg-background ring-foreground/5 relative h-(--block-preview-height) w-full overflow-hidden rounded-lg shadow-xs ring-1">
- <iframe src={src} title={title} className="size-full border-0" />
+ <iframe
+ ref={ref}
+ src={src}
+ title={title}
+ loading="lazy"
+ onLoad={(event) => markLoaded(event.currentTarget)}
+ className="size-full border-0 opacity-0 transition-opacity duration-300 data-loaded:opacity-100"
+ />
</div>
);
}
+
+function markLoaded(iframe: HTMLIFrameElement) {
+ iframe.dataset.loaded = "";
+}
diff --git a/src/components/page-header.tsx b/src/components/page-header.tsx
index 134996c..f72f70a 100644
--- a/src/components/page-header.tsx
+++ b/src/components/page-header.tsx
@@ -74,7 +74,7 @@ function PageHeaderHeading({
return (
<Comp
className={cn(
- "text-primary max-w-4xl font-bold tracking-tight text-balance",
+ "text-foreground max-w-4xl font-bold tracking-tight text-balance",
animated && "animate-fade-up animate-stagger",
size === "sm"
? "text-4xl font-semibold md:text-5xl"