import * as React from 'react' ; import { REGEX } from 'shared/Regex' ; import { CardThemeType } from '../../../../reducers/StateTypes' ; export function generateIconElements ( content , theme ) { content = ( content || '' ) . replace ( new RegExp ( REGEX . ICON . source , 'g' ) , ( match , group ) : string => { const icon = group . toLowerCase ( ) ; const suffix = ( theme === 'dark' && icon . indexOf ( '_white' ) === - 1 ) ? '_white' : '' ; return `<img class="inline_icon" src="images/${ icon }${ suffix }_small.svg" />` ; } ) . replace ( new RegExp ( REGEX . ART . source , 'g' ) , ( match , group ) : string => { let imgName = `images/${ group }` ; let imgClass = 'artHalf' ; if ( group . slice ( - 5 ) === '_full' ) { imgName = imgName . slice ( 0 , - 5 ) ; imgClass = 'artFull' ; } if ( imgName . slice ( - 4 ) === '_png' ) { imgName = imgName . slice ( 0 , - 4 ) + '.png' ; } else { imgName = imgName + '.svg' ; } return `<div class="${ imgClass }">
        <img class="art" src="${ imgName . toLowerCase ( ) }" onerror="this.style.display='none'" />
      </div>` ; } ) ; return < span dangerouslySetInnerHTML = { { __html : content } } />; } export const NUMERALS = { 1 : 'I' , 2 : 'II' , 3 : 'III' , 4 : 'IV' , 5 : 'V' , 6 : 'VI' , 7 : 'VII' , 8 : 'VIII' , 9 : 'IX' , 10 : 'X' , } ; export function numberToWord ( input ) { switch ( input ) { case 0 : return 'zero' ; case 1 : return 'one' ; case 2 : return 'two' ; case 3 : return 'three' ; case 4 : return 'four' ; case 5 : return 'five' ; case 6 : return 'six' ; case 7 : return 'seven' ; case 8 : return 'eight' ; case 9 : return 'nine' ; case 10 : return 'ten' ; default : return input . toString ( ) ; } } export function capitalizeFirstLetter ( input = '' ) { return input . charAt ( 0 ) . toUpperCase ( ) + input . slice ( 1 ) ; } export function formatImg ( img , theme , small ? ) { if ( theme === 'dark' ) { img += '_white' ; } if ( small === undefined || small ) { img += '_small' ; } return img ; }