UNPKG

3.86 kBSource Map (JSON)View Raw
1{"version":3,"sources":["CardCover.tsx"],"names":["CardCover","index","total","style","theme","rest","roundness","coverStyle","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","styles","container","image","displayName","StyleSheet","create","height","backgroundColor","grey200","overflow","flex","undefined","width","padding","justifyContent"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,SAAS,GAAG,CAAC;AAAEC,EAAAA,KAAF;AAASC,EAAAA,KAAT;AAAgBC,EAAAA,KAAhB;AAAuBC,EAAAA,KAAvB;AAA8B,KAAGC;AAAjC,CAAD,KAAoD;AACpE,QAAM;AAAEC,IAAAA;AAAF,MAAgBF,KAAtB;AAEA,MAAIG,UAAJ;;AAEA,MAAIN,KAAK,KAAK,CAAd,EAAiB;AACf,QAAIC,KAAK,KAAK,CAAd,EAAiB;AACfK,MAAAA,UAAU,GAAG;AACXC,QAAAA,YAAY,EAAEF;AADH,OAAb;AAGD,KAJD,MAIO;AACLC,MAAAA,UAAU,GAAG;AACXE,QAAAA,mBAAmB,EAAEH,SADV;AAEXI,QAAAA,oBAAoB,EAAEJ;AAFX,OAAb;AAID;AACF,GAXD,MAWO,IAAI,OAAOJ,KAAP,KAAiB,QAAjB,IAA6BD,KAAK,KAAKC,KAAK,GAAG,CAAnD,EAAsD;AAC3DK,IAAAA,UAAU,GAAG;AACXI,MAAAA,sBAAsB,EAAEL;AADb,KAAb;AAGD;;AAED,sBACE,oBAAC,iBAAD;AAAM,IAAA,KAAK,EAAE,CAACM,MAAM,CAACC,SAAR,EAAmBN,UAAnB,EAA+BJ,KAA/B;AAAb,kBACE,oBAAC,kBAAD,eAAWE,IAAX;AAAiB,IAAA,KAAK,EAAE,CAACO,MAAM,CAACE,KAAR,EAAeP,UAAf;AAAxB,KADF,CADF;AAKD,CA3BD;;;AA6BAP,SAAS,CAACe,WAAV,GAAwB,YAAxB;;AACA,MAAMH,MAAM,GAAGI,wBAAWC,MAAX,CAAkB;AAC/BJ,EAAAA,SAAS,EAAE;AACTK,IAAAA,MAAM,EAAE,GADC;AAETC,IAAAA,eAAe,EAAEC,eAFR;AAGTC,IAAAA,QAAQ,EAAE;AAHD,GADoB;AAM/BP,EAAAA,KAAK,EAAE;AACLQ,IAAAA,IAAI,EAAE,CADD;AAELJ,IAAAA,MAAM,EAAEK,SAFH;AAGLC,IAAAA,KAAK,EAAED,SAHF;AAILE,IAAAA,OAAO,EAAE,EAJJ;AAKLC,IAAAA,cAAc,EAAE;AALX;AANwB,CAAlB,CAAf;;eAee,wBAAU1B,SAAV,C,EAEf","sourcesContent":["import * as React from 'react';\nimport { StyleSheet, View, ViewStyle, Image, StyleProp } from 'react-native';\nimport { withTheme } from '../../core/theming';\nimport { grey200 } from '../../styles/colors';\n\ntype Props = React.ComponentPropsWithRef<typeof Image> & {\n /**\n * @internal\n */\n index?: number;\n /**\n * @internal\n */\n total?: number;\n style?: StyleProp<ViewStyle>;\n /**\n * @optional\n */\n theme: ReactNativePaper.Theme;\n};\n\n/**\n * A component to show a cover image inside a Card.\n *\n * <div class=\"screenshots\">\n * <figure>\n * <img class=\"medium\" src=\"screenshots/card-cover.png\" />\n * </figure>\n * </div>\n *\n * ## Usage\n * ```js\n * import * as React from 'react';\n * import { Card } from 'react-native-paper';\n *\n * const MyComponent = () => (\n * <Card>\n * <Card.Cover source={{ uri: 'https://picsum.photos/700' }} />\n * </Card>\n * );\n *\n * export default MyComponent;\n * ```\n *\n * @extends Image props https://reactnative.dev/docs/image#props\n */\nconst CardCover = ({ index, total, style, theme, ...rest }: Props) => {\n const { roundness } = theme;\n\n let coverStyle;\n\n if (index === 0) {\n if (total === 1) {\n coverStyle = {\n borderRadius: roundness,\n };\n } else {\n coverStyle = {\n borderTopLeftRadius: roundness,\n borderTopRightRadius: roundness,\n };\n }\n } else if (typeof total === 'number' && index === total - 1) {\n coverStyle = {\n borderBottomLeftRadius: roundness,\n };\n }\n\n return (\n <View style={[styles.container, coverStyle, style]}>\n <Image {...rest} style={[styles.image, coverStyle]} />\n </View>\n );\n};\n\nCardCover.displayName = 'Card.Cover';\nconst styles = StyleSheet.create({\n container: {\n height: 195,\n backgroundColor: grey200,\n overflow: 'hidden',\n },\n image: {\n flex: 1,\n height: undefined,\n width: undefined,\n padding: 16,\n justifyContent: 'flex-end',\n },\n});\n\nexport default withTheme(CardCover);\n\n// @component-docs ignore-next-line\nexport { CardCover };\n"]}
\No newline at end of file