import type { IconName } from '../Icon'; import type { InlineLoaderState, InlineLoaderIntent, InlineLoaderTextSize, InlineLoaderTextSizeName, } from './types'; const TEXT_SIZE_NAMES: Record = { 10: 'xsmall', 12: 'small', 14: 'medium', 16: 'large', 18: 'xlarge', }; export const getTextSizeName = ( size: InlineLoaderTextSize ): InlineLoaderTextSizeName => TEXT_SIZE_NAMES[size]; export const getIconName = (state: InlineLoaderState): IconName => { switch (state) { case 'idle': return 'circle-ok-outlined'; case 'loading': return 'loading'; case 'success': return 'circle-check'; case 'error': return 'circle-cancel-outlined'; } }; export const getIconIntent = ( state: InlineLoaderState, intent: InlineLoaderIntent ): 'inactive' | 'primary' | 'ai' | 'success' | 'danger' => { switch (state) { case 'idle': return 'inactive'; case 'loading': return intent === 'ai' ? 'ai' : 'primary'; case 'success': return 'success'; case 'error': return 'danger'; } }; export const getIconSize = ( textSize: InlineLoaderTextSize ): { size: 'xxxsmall' | 'xsmall' | 'small'; styleFontSize?: number } => { switch (textSize) { case 10: return { size: 'xxxsmall' }; case 12: return { size: 'xxxsmall', styleFontSize: 14 }; case 14: return { size: 'xxxsmall', styleFontSize: 14 }; case 16: return { size: 'xsmall' }; case 18: return { size: 'small' }; } };