Template
Next.js 16 + React 19 storefront template with Shopify Storefront API integration, Tailwind v4, and shadcn/ui components. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0111qSr3KopyGRsJ6LznR1xZ
45 lines
993 B
TypeScript
45 lines
993 B
TypeScript
'use client';
|
|
|
|
import React from 'react';
|
|
import * as RemixIcons from '@remixicon/react';
|
|
|
|
interface RemixIconProps {
|
|
name: string; // e.g. "RiTruckLine"
|
|
className?: string;
|
|
size?: number;
|
|
}
|
|
|
|
const RemixIcon: React.FC<RemixIconProps> = ({
|
|
name,
|
|
className,
|
|
size = 16,
|
|
}) => {
|
|
if (!name) return null;
|
|
|
|
// Normalise: accept "RiTruckLine", "ri-truck-line", or "riTruckLine"
|
|
const normalised = name
|
|
// ri-truck-line → RiTruckLine
|
|
.replace(/^ri-/, 'Ri')
|
|
.replace(/-([a-z])/g, (_, c) => c.toUpperCase())
|
|
// ensure first char is uppercase
|
|
.replace(/^./, (c) => c.toUpperCase());
|
|
|
|
const IconComponent = (
|
|
RemixIcons as Record<
|
|
string,
|
|
React.FC<{ className?: string; size?: number }>
|
|
>
|
|
)[normalised];
|
|
|
|
if (!IconComponent) {
|
|
console.warn(
|
|
`[RemixIcon] Icon "${name}" (resolved: "${normalised}") not found.`
|
|
);
|
|
return null;
|
|
}
|
|
|
|
return <IconComponent className={className} size={size} />;
|
|
};
|
|
|
|
export default RemixIcon;
|