type PreviewDeviceOption = { key: string; label: string; Icon: ( props: { className?: string } ) => JSX.Element; }; type PreviewDeviceSwitcherProps = { options: PreviewDeviceOption[]; value: string; onChange: ( next: string ) => void; className?: string; }; const getEdgeBorderClass = ( index: number, total: number ): string => { if ( index === 0 ) { return 'border border-slate-200 border-r-0'; } if ( index === total - 1 ) { return 'border border-slate-200 border-l-0'; } return 'border border-slate-200'; }; const PreviewDeviceSwitcher = ( { options, value, onChange, className = '', }: PreviewDeviceSwitcherProps ) => (
{ options.map( ( option, index ) => { const active = value === option.key; const Icon = option.Icon; const edgeBorderClass = getEdgeBorderClass( index, options.length ); return ( ); } ) }
); export type { PreviewDeviceOption, PreviewDeviceSwitcherProps }; export default PreviewDeviceSwitcher;