UNPKG

@metamask/design-system-react-native

Version:
1 lines 1.58 kB
{"version":3,"file":"Icon.utilities.mjs","sourceRoot":"","sources":["../../../src/components/Icon/Icon.utilities.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,wCAAwC;AACxC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,8BAAoB;AAIlD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACrC,KAAK,GAAG,SAAS,CAAC,WAAW,EAC7B,IAAI,GAAG,QAAQ,CAAC,EAAE,EAClB,WAAW,GAAG,EAAE,GACG,EAAU,EAAE;IAC/B,MAAM,gBAAgB,GAAG,GAAG,KAAK,OAAO,IAAI,UAAU,IAAI,OAAO,WAAW,EAAE,CAAC;IAC/E,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC","sourcesContent":["/* eslint-disable jsdoc/check-param-names */\n/* eslint-disable jsdoc/require-param */\nimport { IconColor, IconSize } from '../../types';\n\nimport type { IconProps } from './Icon.types';\n\n/**\n * Generates a Tailwind class name for the icon based on color and optional additional classes.\n *\n * @param color - The color of the icon, mapped to a Tailwind class.\n * @param size - Different sizes map to specific pixel dimensions\n * @param twClassName - Additional Tailwind class names for customization.\n * @returns A combined string of class names.\n *\n * Example:\n * ```\n * const classNames = generateIconClassNames({\n * color: IconColor.IconDefault,\n * size: IconSize.Md\n * });\n *\n * console.log(classNames);\n * // Output: \"text-icon-default w-[20px] h-[20px]\"\n * ```\n */\nexport const generateIconClassNames = ({\n color = IconColor.IconDefault,\n size = IconSize.Md,\n twClassName = '',\n}: Partial<IconProps>): string => {\n const mergedClassnames = `${color} w-[${size}px] h-[${size}px] ${twClassName}`;\n return mergedClassnames;\n};\n"]}