UNPKG

@wordpress/components

Version:
1 lines • 1.75 kB
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/dashicon/index.tsx"],"sourcesContent":["/**\n * @typedef OwnProps\n *\n * @property {import('./types').IconKey} icon Icon name\n * @property {string} [className] Class name\n * @property {number} [size] Size of the icon\n */\nimport type { WordPressComponentProps } from '../context';\nimport type { DashiconProps } from './types';\n\nfunction Dashicon( {\n\ticon,\n\tclassName,\n\tsize = 20,\n\tstyle = {},\n\t...extraProps\n}: WordPressComponentProps< DashiconProps, 'span', false > ) {\n\tconst iconClass = [\n\t\t'dashicon',\n\t\t'dashicons',\n\t\t'dashicons-' + icon,\n\t\tclassName,\n\t]\n\t\t.filter( Boolean )\n\t\t.join( ' ' );\n\n\t// For retro-compatibility reasons (for example if people are overriding icon size with CSS), we add inline styles just if the size is different to the default\n\tconst sizeStyles =\n\t\t// using `!=` to catch both 20 and \"20\"\n\t\t// eslint-disable-next-line eqeqeq\n\t\t20 != size\n\t\t\t? {\n\t\t\t\t\tfontSize: `${ size }px`,\n\t\t\t\t\twidth: `${ size }px`,\n\t\t\t\t\theight: `${ size }px`,\n\t\t\t\t}\n\t\t\t: {};\n\n\tconst styles = {\n\t\t...sizeStyles,\n\t\t...style,\n\t};\n\n\treturn <span className={ iconClass } style={ styles } { ...extraProps } />;\n}\n\nexport default Dashicon;\n"],"mappings":";;;;;;;AAUA,SAAS,SAAU,EAClB,MACA,WACA,OAAO,IACP,QAAQ,CAAC,GACT,GAAG,cACyD;CAC5D,MAAM,YAAY;EACjB;EACA;EACA,eAAe;EACf;CACD,CAAC,CACC,OAAQ,OAAQ,CAAC,CACjB,KAAM,GAAI;CAcZ,MAAM,SAAS;EACd,GATA,MAAM,OACH;GACA,UAAU,GAAI,KAAM;GACpB,OAAO,GAAI,KAAM;GACjB,QAAQ,GAAI,KAAM;EACnB,IACC,CAAC;EAIJ,GAAG;CACJ;CAEA,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EAAM,WAAY;EAAY,OAAQ;EAAS,GAAK;CAAc,CAAA;AAC1E"}