import type { ReactNode } from 'react';
import { cn } from '@/lib/utils';
import { useHref } from './context';
/** Page-width wrapper used by every section. */
export function Container({
className,
children,
}: {
className?: string;
children: ReactNode;
}) {
return (
{children}
);
}
export function SfButton({
href,
variant = 'primary',
className,
children,
}: {
href: string;
variant?: 'primary' | 'outline';
className?: string;
children: ReactNode;
}) {
const resolved = useHref(href);
return (
{children}
);
}
/** A plain link whose address is worked out the same way as buttons. */
export function SfLink({
href,
className,
children,
}: {
href: string;
className?: string;
children: ReactNode;
}) {
return (
{children}
);
}
/** A minus button, the number, and a plus button. */
export function QuantityStepper({
value,
max,
min = 1,
disabled = false,
onChange,
decreaseLabel,
increaseLabel,
}: {
value: number;
max: number;
min?: number;
disabled?: boolean;
onChange: (value: number) => void;
decreaseLabel: string;
increaseLabel: string;
}) {
const button =
'flex size-9 items-center justify-center text-lg leading-none transition-colors hover:bg-(--sf-surface) disabled:cursor-not-allowed disabled:opacity-40';
return (
onChange(value - 1)}
>
−
{value}
= max}
onClick={() => onChange(value + 1)}
>
+
);
}
export function Eyebrow({ children }: { children: ReactNode }) {
return (
{children}
);
}
export function SectionHeading({
heading,
subheading,
align = 'left',
}: {
heading: string;
subheading?: string | null;
align?: 'left' | 'center';
}) {
return (
{heading}
{subheading && (
{subheading}
)}
);
}
const tilts = ['135deg', '200deg', '45deg', '310deg'];
/**
* Stands in for a photo when there is no real one.
* It is drawn from the theme colours so it always matches the store.
*/
export function ImagePlaceholder({
seed = 0,
label,
className,
}: {
seed?: number;
label?: string;
className?: string;
}) {
const tilt = tilts[seed % tilts.length];
return (
);
}