UNPKG

@wordpress/block-editor

Version:
8 lines (7 loc) 1.29 kB
{ "version": 3, "sources": ["../../src/utils/format-font-style.js"], "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Formats font styles to human readable names.\n *\n * @param {string} fontStyle font style string\n * @return {Object} new object with formatted font style\n */\nexport function formatFontStyle( fontStyle ) {\n\tif ( ! fontStyle ) {\n\t\treturn {};\n\t}\n\n\tif ( typeof fontStyle === 'object' ) {\n\t\treturn fontStyle;\n\t}\n\n\tlet name;\n\n\tswitch ( fontStyle ) {\n\t\tcase 'normal':\n\t\t\tname = _x( 'Regular', 'font style' );\n\t\t\tbreak;\n\t\tcase 'italic':\n\t\t\tname = _x( 'Italic', 'font style' );\n\t\t\tbreak;\n\t\tcase 'oblique':\n\t\t\tname = _x( 'Oblique', 'font style' );\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tname = fontStyle;\n\t\t\tbreak;\n\t}\n\n\treturn { name, value: fontStyle };\n}\n"], "mappings": ";AAGA,SAAS,UAAU;AAQZ,SAAS,gBAAiB,WAAY;AAC5C,MAAK,CAAE,WAAY;AAClB,WAAO,CAAC;AAAA,EACT;AAEA,MAAK,OAAO,cAAc,UAAW;AACpC,WAAO;AAAA,EACR;AAEA,MAAI;AAEJ,UAAS,WAAY;AAAA,IACpB,KAAK;AACJ,aAAO,GAAI,WAAW,YAAa;AACnC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,UAAU,YAAa;AAClC;AAAA,IACD,KAAK;AACJ,aAAO,GAAI,WAAW,YAAa;AACnC;AAAA,IAED;AACC,aAAO;AACP;AAAA,EACF;AAEA,SAAO,EAAE,MAAM,OAAO,UAAU;AACjC;", "names": [] }