|
33 | 33 | - Search Console already shows zero-ui.dev receiving impressions for "icon sprite", so keep this as a real page instead of redirecting the legacy route. |
34 | 34 | */ |
35 | 35 |
|
36 | | -import type { ComponentType, CSSProperties } from "react"; |
37 | 36 | import type { Metadata } from "next"; |
38 | 37 | import Link from "next/link"; |
39 | | -import { |
40 | | - Activity, |
41 | | - Airplay, |
42 | | - AlarmClock, |
43 | | - Archive, |
44 | | - ArrowRight, |
45 | | - BadgeCheck, |
46 | | - Bell, |
47 | | - Calendar, |
48 | | - CheckCircle, |
49 | | - Code, |
50 | | - Download, |
51 | | - GitBranch, |
52 | | - GitMerge, |
53 | | - GitPullRequest, |
54 | | - Heart, |
55 | | - IconBrandGithub, |
56 | | - IconBrandTabler, |
57 | | - IconHeart, |
58 | | - Mail, |
59 | | - Package, |
60 | | - Rocket, |
61 | | - Search, |
62 | | - Settings, |
63 | | - Sparkles, |
64 | | - Zap, |
65 | | -} from "@react-zero-ui/icon-sprite"; |
| 38 | + |
66 | 39 | import { DynamicCodeBlock } from "fumadocs-ui/components/dynamic-codeblock"; |
67 | 40 | import { SITE_SLUGS } from "@/app/config/site-config"; |
68 | 41 | import { CopyCommand } from "../_components/CopyCommand"; |
69 | 42 | import { Footer, iconSpriteFooterCta } from "../_components/Footer"; |
| 43 | +import { HeroIconBackdrop, sampleIcons } from "./hero-icon-backdrop"; |
| 44 | +import { ArrowRight } from "@react-zero-ui/icon-sprite"; |
70 | 45 |
|
71 | 46 | export const metadata: Metadata = { |
72 | 47 | title: "React Icon Sprite for Lucide & Tabler | React Zero-UI", |
73 | 48 | description: "Use Lucide and Tabler React icons as components, then compile only the SVG icons you use into one cached sprite sheet at build time.", |
74 | 49 | alternates: { canonical: SITE_SLUGS.iconSprite }, |
75 | 50 | }; |
76 | 51 |
|
77 | | -type IconComponent = ComponentType<{ size?: number; className?: string; width?: number; height?: number; strokeWidth?: number }>; |
78 | | - |
79 | | -const sampleIcons: IconComponent[] = [ |
80 | | - Activity, |
81 | | - Airplay, |
82 | | - AlarmClock, |
83 | | - Archive, |
84 | | - BadgeCheck, |
85 | | - Bell, |
86 | | - Calendar, |
87 | | - CheckCircle, |
88 | | - Code, |
89 | | - Download, |
90 | | - GitBranch, |
91 | | - GitMerge, |
92 | | - GitPullRequest, |
93 | | - Heart, |
94 | | - IconBrandGithub, |
95 | | - IconBrandTabler, |
96 | | - IconHeart, |
97 | | - Mail, |
98 | | - Package, |
99 | | - Rocket, |
100 | | - Search, |
101 | | - Settings, |
102 | | - Sparkles, |
103 | | - Zap, |
104 | | -]; |
105 | | - |
106 | | -const heroIcons: IconComponent[] = Array.from({ length: 80 }, (_, index) => sampleIcons[index % sampleIcons.length]); |
107 | | - |
108 | | -const iconSpotlight: CSSProperties = { |
109 | | - WebkitMaskImage: "radial-gradient(circle 180px at var(--x, 50%) var(--y, 50%), #000 0%, transparent 70%)", |
110 | | - maskImage: "radial-gradient(circle 180px at var(--x, 50%) var(--y, 50%), #000 0%, transparent 70%)", |
111 | | -}; |
112 | | - |
113 | 52 | export default function IconSpritePage() { |
114 | 53 | return ( |
115 | 54 | <> |
@@ -178,48 +117,6 @@ function Hero() { |
178 | 117 | ); |
179 | 118 | } |
180 | 119 |
|
181 | | -function HeroIconBackdrop() { |
182 | | - return ( |
183 | | - <div |
184 | | - aria-hidden |
185 | | - className="pointer-events-none absolute inset-0 -z-10 overflow-hidden"> |
186 | | - <div className="absolute inset-y-0 left-[42%] right-[-18%] hidden md:block"> |
187 | | - <IconGrid className="absolute inset-0 text-fd-foreground/5" /> |
188 | | - <IconGrid |
189 | | - className="icon-spotlight-drift absolute inset-0 text-fd-primary/35" |
190 | | - style={iconSpotlight} |
191 | | - /> |
192 | | - </div> |
193 | | - <div className="absolute inset-x-[-18%] bottom-[-24%] top-[34%] md:hidden"> |
194 | | - <IconGrid className="absolute inset-0 text-fd-foreground/3" /> |
195 | | - <IconGrid |
196 | | - className="icon-spotlight-drift absolute inset-0 text-fd-primary/25" |
197 | | - style={iconSpotlight} |
198 | | - /> |
199 | | - </div> |
200 | | - </div> |
201 | | - ); |
202 | | -} |
203 | | - |
204 | | -function IconGrid({ className, style }: { className?: string; style?: CSSProperties }) { |
205 | | - return ( |
206 | | - <div |
207 | | - className={`grid h-full w-full grid-cols-[repeat(auto-fill,minmax(76px,1fr))] content-start ${className ?? ""}`} |
208 | | - style={style}> |
209 | | - {heroIcons.map((Icon, index) => ( |
210 | | - <span |
211 | | - key={index} |
212 | | - className="flex aspect-square items-center justify-center border-[0.5px] border-fd-border/10"> |
213 | | - <Icon |
214 | | - size={34} |
215 | | - strokeWidth={1} |
216 | | - /> |
217 | | - </span> |
218 | | - ))} |
219 | | - </div> |
220 | | - ); |
221 | | -} |
222 | | - |
223 | 120 | function Benchmark() { |
224 | 121 | const lucideSizeKb = 19.5; |
225 | 122 | const spriteSizeKb = 7.5; |
|
0 commit comments