UNPKG

4.27 kBSource Map (JSON)View Raw
1{"version":3,"sources":["AvatarText.tsx"],"names":["defaultSize","AvatarText","label","size","style","theme","labelStyle","color","customColor","rest","backgroundColor","colors","primary","restStyle","StyleSheet","flatten","textColor","white","width","height","borderRadius","styles","container","text","fontSize","lineHeight","displayName","create","justifyContent","alignItems","textAlign","textAlignVertical"],"mappings":";;;;;;;AAAA;;AACA;;AAOA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,MAAMA,WAAW,GAAG,EAApB;;AA6BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAG,QAQN;AAAA,MARO;AAClBC,IAAAA,KADkB;AAElBC,IAAAA,IAAI,GAAGH,WAFW;AAGlBI,IAAAA,KAHkB;AAIlBC,IAAAA,KAJkB;AAKlBC,IAAAA,UALkB;AAMlBC,IAAAA,KAAK,EAAEC,WANW;AAOlB,OAAGC;AAPe,GAQP;AACX,QAAM;AAAEC,IAAAA,eAAe,GAAGL,KAAK,CAACM,MAAN,CAAaC,OAAjC;AAA0C,OAAGC;AAA7C,MACJC,wBAAWC,OAAX,CAAmBX,KAAnB,KAA6B,EAD/B;AAEA,QAAMY,SAAS,GACbR,WADa,aACbA,WADa,cACbA,WADa,GAEb,kCAAoBE,eAApB,EAAqCO,aAArC,EAA4C,oBAA5C,CAFF;AAIA,sBACE,oBAAC,iBAAD;AACE,IAAA,KAAK,EAAE,CACL;AACEC,MAAAA,KAAK,EAAEf,IADT;AAEEgB,MAAAA,MAAM,EAAEhB,IAFV;AAGEiB,MAAAA,YAAY,EAAEjB,IAAI,GAAG,CAHvB;AAIEO,MAAAA;AAJF,KADK,EAOLW,MAAM,CAACC,SAPF,EAQLT,SARK;AADT,KAWMJ,IAXN,gBAaE,oBAAC,aAAD;AACE,IAAA,KAAK,EAAE,CACLY,MAAM,CAACE,IADF,EAEL;AACEhB,MAAAA,KAAK,EAAES,SADT;AAEEQ,MAAAA,QAAQ,EAAErB,IAAI,GAAG,CAFnB;AAGEsB,MAAAA,UAAU,EAAEtB;AAHd,KAFK,EAOLG,UAPK,CADT;AAUE,IAAA,aAAa,EAAE;AAVjB,KAYGJ,KAZH,CAbF,CADF;AA8BD,CA7CD;;AA+CAD,UAAU,CAACyB,WAAX,GAAyB,aAAzB;;AAEA,MAAML,MAAM,GAAGP,wBAAWa,MAAX,CAAkB;AAC/BL,EAAAA,SAAS,EAAE;AACTM,IAAAA,cAAc,EAAE,QADP;AAETC,IAAAA,UAAU,EAAE;AAFH,GADoB;AAK/BN,EAAAA,IAAI,EAAE;AACJO,IAAAA,SAAS,EAAE,QADP;AAEJC,IAAAA,iBAAiB,EAAE;AAFf;AALyB,CAAlB,CAAf;;eAWe,wBAAU9B,UAAV,C","sourcesContent":["import * as React from 'react';\nimport {\n View,\n ViewStyle,\n StyleSheet,\n StyleProp,\n TextStyle,\n} from 'react-native';\nimport Text from '../Typography/Text';\nimport { withTheme } from '../../core/theming';\nimport { white } from '../../styles/colors';\nimport getContrastingColor from '../../utils/getContrastingColor';\n\nconst defaultSize = 64;\n\ntype Props = React.ComponentPropsWithRef<typeof View> & {\n /**\n * Initials to show as the text in the `Avatar`.\n */\n label: string;\n /**\n * Size of the avatar.\n */\n size?: number;\n /**\n * Custom color for the text.\n */\n color?: string;\n /**\n * Style for text container\n */\n style?: StyleProp<ViewStyle>;\n /**\n * Style for the title.\n */\n labelStyle?: StyleProp<TextStyle>;\n /**\n * @optional\n */\n theme: ReactNativePaper.Theme;\n};\n\n/**\n * Avatars can be used to represent people in a graphical way.\n *\n * <div class=\"screenshots\">\n * <figure>\n * <img class=\"medium\" src=\"screenshots/avatar-text.png\" />\n * </figure>\n * </div>\n *\n * ## Usage\n * ```js\n * import * as React from 'react';\n * import { Avatar } from 'react-native-paper';\n *\n * const MyComponent = () => (\n * <Avatar.Text size={24} label=\"XD\" />\n * );\n * ```\n */\nconst AvatarText = ({\n label,\n size = defaultSize,\n style,\n theme,\n labelStyle,\n color: customColor,\n ...rest\n}: Props) => {\n const { backgroundColor = theme.colors.primary, ...restStyle } =\n StyleSheet.flatten(style) || {};\n const textColor =\n customColor ??\n getContrastingColor(backgroundColor, white, 'rgba(0, 0, 0, .54)');\n\n return (\n <View\n style={[\n {\n width: size,\n height: size,\n borderRadius: size / 2,\n backgroundColor,\n },\n styles.container,\n restStyle,\n ]}\n {...rest}\n >\n <Text\n style={[\n styles.text,\n {\n color: textColor,\n fontSize: size / 2,\n lineHeight: size,\n },\n labelStyle,\n ]}\n numberOfLines={1}\n >\n {label}\n </Text>\n </View>\n );\n};\n\nAvatarText.displayName = 'Avatar.Text';\n\nconst styles = StyleSheet.create({\n container: {\n justifyContent: 'center',\n alignItems: 'center',\n },\n text: {\n textAlign: 'center',\n textAlignVertical: 'center',\n },\n});\n\nexport default withTheme(AvatarText);\n"]}
\No newline at end of file