Files
dt-design-system/packages/react/src/components/DTFeatureLegend.tsx
michael e74c285b70 Add storefront component migration: cards, badges, progress bars, animations, and React wrapper package
Major feature migration from dt-shopify-storefront into the design system:

- Card system: per-card color modes (normal/emphasis/warning/success/other),
  progress bars, full-bleed card body (card-body-flush), image bevel clip-paths,
  and visible structural borders at bevel corners
- Badge system: dt-card-badge with position-aware offsets for cards vs media frames
- Media frames: dt-bevel-media with inner surface fill, image clipping, and
  "MISSING MEDIA" placeholder for empty containers
- Interactive bevel buttons: dt-btn with hover/selected states and pulse animation
- Menu items: dt-menu-item with active states and level indentation
- Animations: scale-in, fade-in, slide-up, pulse, ping, spin keyframes
- Feature legend: CSS grid for product feature icons with state colors
- Scrollbar styling for DT brand
- New @dangerousthings/react package wrapping web CSS components
- New @dangerousthings/tailwind-preset package
- New @dangerousthings/hex-background package
- Desktop showcase rewritten in React with Tailwind CSS
- Mobile showcase updated with new screens (animations, filters, advanced cards)
- Tokens: added mode color tokens, RGB variants, and selected-state tokens

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 10:18:39 -08:00

78 lines
2.2 KiB
TypeScript

/**
* DTFeatureLegend — Grid of product feature icons with rotated labels.
*
* CSS reference: feature-legend.css .dt-feature-legend, .dt-feature-legend-header,
* .dt-feature-legend-grid, .dt-feature-legend-item, .dt-feature-supported, etc.
*/
import type { ReactNode, CSSProperties } from 'react';
import type { DTVariant } from '@dangerousthings/tokens';
import { cx } from '../utils/cx';
import { getVariantClass, featureStateToVariant } from '../utils/variantClasses';
export interface DTFeatureItem {
key: string;
name: string;
icon: ReactNode;
state: 'supported' | 'disabled' | 'unsupported';
}
const stateClassMap: Record<DTFeatureItem['state'], string> = {
supported: 'dt-feature-supported',
disabled: 'dt-feature-disabled',
unsupported: 'dt-feature-unsupported',
};
interface DTFeatureLegendProps {
features: DTFeatureItem[];
title?: string;
/** Header variant @default 'normal' */
variant?: DTVariant;
/** Grid columns @default 5 */
columns?: number;
/** Icon size in px @default 42 */
iconSize?: number;
className?: string;
style?: CSSProperties;
}
export function DTFeatureLegend({
features,
title,
variant = 'normal',
columns = 5,
iconSize = 42,
className,
style,
}: DTFeatureLegendProps) {
// Suppress unused import warning — featureStateToVariant is available for consumers
void featureStateToVariant;
return (
<div
className={cx('dt-feature-legend', getVariantClass(variant), className)}
style={style}>
{title && (
<div className="dt-feature-legend-header">{title}</div>
)}
<div
className="dt-feature-legend-grid"
style={{ '--dt-feature-columns': columns } as CSSProperties}>
{features.map(feature => (
<div
key={feature.key}
className={cx('dt-feature-legend-item', stateClassMap[feature.state])}
style={{ width: `${100 / columns}%` }}>
<div
className="dt-feature-legend-icon"
style={{ width: `${iconSize}px`, height: `${iconSize}px` }}>
{feature.icon}
</div>
<div className="dt-feature-legend-label">{feature.name}</div>
</div>
))}
</div>
</div>
);
}