/** * ScriptInfoSection Component * * Displays script information in a card with header (title, description) * and detail cells (shell type, supported platforms, category, author). * Responsive layout: stacks cells on mobile, shows grid on desktop. */ import React from 'react' import { cn } from '../../utils/cn' import { getOSLabel } from '../../utils/os-utils' import { getShellLabel } from '../../utils/shell-utils' /** * Props for author avatar display */ export interface ScriptAuthor { /** Author name */ name: string /** Author initials (used when no photo) */ initials?: string /** URL to author's photo */ photoUrl?: string } /** * Props for ScriptInfoSection component */ export interface ScriptInfoSectionProps { /** Script title/name */ headline: string /** Script description */ subheadline?: string /** Shell type (POWERSHELL, BASH, CMD, etc.) */ shellType?: string /** Array of supported platform strings (windows, darwin, linux, etc.) */ supportedPlatforms?: string[] /** Script category */ category: string /** Author information */ author?: ScriptAuthor /** Additional CSS classes */ className?: string } /** * Formats supported platforms array into a display string * @param platforms - Array of platform strings (e.g., ['windows', 'darwin', 'linux']) * @returns Formatted string (e.g., 'Windows, macOS, Linux') */ function formatSupportedPlatforms(platforms?: string[]): string { if (!platforms || platforms.length === 0) { return 'All Platforms' } return platforms.map((platform) => getOSLabel(platform)).join(', ') } /** * Gets initials from a name * @param name - Full name * @returns Two-letter initials */ function getInitials(name: string): string { const parts = name.trim().split(/\s+/) if (parts.length >= 2) { return `${parts[0][0]}${parts[1][0]}`.toUpperCase() } return name.slice(0, 2).toUpperCase() } /** * InfoCell - Single info cell with label and value */ interface InfoCellProps { label: string value: string avatar?: ScriptAuthor className?: string } function InfoCell({ label, value, avatar, className }: InfoCellProps) { return (
{/* Avatar for author cell */} {avatar && (
{avatar.photoUrl ? ( {avatar.name} ) : (
{avatar.initials || getInitials(avatar.name)}
)}
)} {/* Text content */}
{value} {label}
) } /** * ScriptInfoSection - Displays script information in a structured card * * @example * ```tsx * * ``` */ export const ScriptInfoSection: React.FC = ({ headline, subheadline, shellType, supportedPlatforms, category, author, className }) => { const shellLabel = getShellLabel(shellType) const platformsLabel = formatSupportedPlatforms(supportedPlatforms) return (
{/* Header row with title and description */}

{headline}

{subheadline && (

{subheadline}

)}
{/* Details section with info cells - Mobile/Tablet ( {/* Desktop only: Category and Author in same row */} {author && ( )}
{/* Second row (mobile/tablet only): Category, Author */}
{author && ( )}
) } ScriptInfoSection.displayName = 'ScriptInfoSection'