@legion-ui-kit/react-core
Version:
<div align="center"> <img height="108" width="116" src="https://legion.digitaltelkom.id/favicon.svg?v=4643a71fb65fa61a5f2b266b769ea7b1" /> <h1 align="center">Legion UI Kit - React Core</h1> </div>
1 lines • 2.99 kB
Source Map (JSON)
{"version":3,"file":"index.cjs","sources":["../../../../src/components/Text/index.tsx"],"sourcesContent":["// Modules\r\nimport cn from 'classnames';\r\nimport { createElement } from 'react';\r\n\r\n// Types\r\nimport type { TTextColor, TTextProps } from './Text.type';\r\n\r\n// Styles\r\nimport styles from './styles.module.scss';\r\n\r\n// Helpers\r\nimport { snakeCase } from '../../helpers/typography';\r\n\r\n// Constants\r\nimport { TEXT_AS_LIST, TEXT_COLORS, TEXT_DEFAULT_PROPS, TEXT_VARIANT } from './Text.constant';\r\n\r\nconst Text = (props: TTextProps) => {\r\n const {\r\n as,\r\n children,\r\n className,\r\n color = TEXT_DEFAULT_PROPS.color,\r\n fontType = TEXT_DEFAULT_PROPS.fontType,\r\n size = TEXT_DEFAULT_PROPS.size,\r\n style,\r\n /* Will be used in the future once the the UI is ready */\r\n // variant = TEXT_DEFAULT_PROPS.variant,\r\n weight,\r\n ...restProps\r\n } = props;\r\n const isValidTag = TEXT_AS_LIST.includes(as!);\r\n const isDefinedColor = TEXT_COLORS.includes(color as TTextColor);\r\n const sizeCN = RegExp(/^h[1-6]$/).test(size as string) ? styles[size!] : styles[snakeCase(size!)];\r\n const componentTag = isValidTag ? as : RegExp(/^h[1-6]$/).test(size as string) ? size : TEXT_DEFAULT_PROPS.as;\r\n const textCN = cn(\r\n className,\r\n styles.legion_text,\r\n styles[fontType!],\r\n sizeCN,\r\n /* Will be used in the future once the the UI is ready */\r\n // styles[snakeCase(variant)],\r\n styles[snakeCase(TEXT_VARIANT.medEmphasis)],\r\n {\r\n [styles[color!]]: isDefinedColor\r\n }\r\n );\r\n const textStyle = {\r\n ...style,\r\n ...(!isDefinedColor ? { color } : {}),\r\n ...(weight ? { fontWeight: weight } : {})\r\n };\r\n\r\n return createElement(\r\n componentTag!,\r\n { className: textCN, style: textStyle, ...restProps },\r\n children\r\n );\r\n};\r\n\r\nexport default Text;\r\n"],"names":["props","as","children","className","color","TEXT_DEFAULT_PROPS","fontType","size","style","weight","restProps","isValidTag","TEXT_AS_LIST","includes","isDefinedColor","TEXT_COLORS","sizeCN","RegExp","test","styles","snakeCase","componentTag","textCN","cn","legion_text","TEXT_VARIANT","medEmphasis","textStyle","fontWeight","createElement"],"mappings":"kTAgBcA,IACZ,MAAMC,GACJA,EAAEC,SACFA,EAAQC,UACRA,EAASC,MACTA,EAAQC,EAAAA,mBAAmBD,MAAKE,SAChCA,EAAWD,EAAAA,mBAAmBC,SAAQC,KACtCA,EAAOF,EAAAA,mBAAmBE,KAAIC,MAC9BA,EAAKC,OAGLA,KACGC,GACDV,EACEW,EAAaC,EAAAA,aAAaC,SAASZ,GACnCa,EAAiBC,EAAAA,YAAYF,SAAST,GACtCY,EAASC,OAAO,YAAYC,KAAKX,GAAkBY,EAAAA,QAAOZ,GAASY,EAAAA,QAAOC,EAAAA,UAAUb,IACpFc,EAAeV,EAAaV,EAAKgB,OAAO,YAAYC,KAAKX,GAAkBA,EAAOF,EAAAA,mBAAmBJ,GACrGqB,EAASC,EAAAA,QACbpB,EACAgB,EAAAA,QAAOK,YACPL,EAAAA,QAAOb,GACPU,EAGAG,EAAAA,QAAOC,EAAAA,UAAUK,eAAaC,cAC9B,CACE,CAACP,EAAAA,QAAOf,IAAUU,IAGhBa,EAAY,IACbnB,KACEM,EAA6B,CAAA,EAAZ,CAAEV,YACpBK,EAAS,CAAEmB,WAAYnB,GAAW,CAAA,GAGxC,OAAOoB,EAAAA,cACLR,EACA,CAAElB,UAAWmB,EAAQd,MAAOmB,KAAcjB,GAC1CR"}