@proximus/lavender-pokecard-native 1.2.4-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PxCardActions.d.ts +8 -0
- package/dist/PxCardActions.d.ts.map +1 -0
- package/dist/PxCardActions.js +22 -0
- package/dist/PxCardContainer.d.ts +59 -0
- package/dist/PxCardContainer.d.ts.map +1 -0
- package/dist/PxCardContainer.js +115 -0
- package/dist/PxCardHeading.d.ts +14 -0
- package/dist/PxCardHeading.d.ts.map +1 -0
- package/dist/PxCardHeading.js +30 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/package.json +21 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface PxCardActionsProps {
|
|
3
|
+
buttons?: React.ReactNode;
|
|
4
|
+
moreAction?: React.ReactNode;
|
|
5
|
+
testID?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function PxCardActions({ buttons, moreAction, testID, }: PxCardActionsProps): React.JSX.Element | null;
|
|
8
|
+
//# sourceMappingURL=PxCardActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PxCardActions.d.ts","sourceRoot":"","sources":["../src/PxCardActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,UAAU,EACV,MAAM,GACP,EAAE,kBAAkB,4BA6BpB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { useTheme } from '@proximus/lavender-styling-native';
|
|
4
|
+
import { e2eID } from '@proximus/lavender-common-native';
|
|
5
|
+
export function PxCardActions({ buttons, moreAction, testID, }) {
|
|
6
|
+
const { theme } = useTheme();
|
|
7
|
+
if (!buttons && !moreAction) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return (React.createElement(View, { ...e2eID(testID), style: {
|
|
11
|
+
flexDirection: 'row',
|
|
12
|
+
gap: theme.t('SpacingXsMobile').number,
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
} },
|
|
15
|
+
React.createElement(View, { style: {
|
|
16
|
+
flex: 1,
|
|
17
|
+
flexDirection: 'row',
|
|
18
|
+
gap: theme.t('SpacingSMobile').number,
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
} }, buttons),
|
|
21
|
+
moreAction));
|
|
22
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AccessibilityProps, ImageResizeMode, ImageSourcePropType, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { type MediaContainerAspectRatio } from '@proximus/lavender-mediacontainer-native';
|
|
4
|
+
export declare const PxCardBackgroundColor: {
|
|
5
|
+
readonly Light: "ColorBackgroundSurfaceLight";
|
|
6
|
+
readonly Default: "ColorBackgroundSurfaceDefault";
|
|
7
|
+
readonly Strong: "ColorBackgroundSurfaceStrong";
|
|
8
|
+
readonly Stronger: "ColorBackgroundSurfaceStronger";
|
|
9
|
+
readonly Dark: "ColorBackgroundSurfaceDark";
|
|
10
|
+
readonly Brand: "ColorBackgroundSurfaceBrand";
|
|
11
|
+
readonly BrandLight: "ColorBackgroundSurfaceBrandLight";
|
|
12
|
+
};
|
|
13
|
+
export type PxCardBackgroundColor = (typeof PxCardBackgroundColor)[keyof typeof PxCardBackgroundColor];
|
|
14
|
+
export interface PxCardContainerProps extends AccessibilityProps {
|
|
15
|
+
inverted?: boolean;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
18
|
+
testID?: string;
|
|
19
|
+
onPress?: () => void;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Image source for the card media.
|
|
23
|
+
* The container handles rendering and sizing the image based on `mediaPosition`.
|
|
24
|
+
*/
|
|
25
|
+
src?: ImageSourcePropType;
|
|
26
|
+
/**
|
|
27
|
+
* Controls where the `src` image is positioned inside the card.
|
|
28
|
+
* - `'none'` (default): no media is rendered.
|
|
29
|
+
* - `'top'`: image is rendered above the content in a full-width wrapper (respects `aspectRatio`).
|
|
30
|
+
* - `'left'`: image is rendered to the left of the content, taking up 33.33% width.
|
|
31
|
+
*/
|
|
32
|
+
mediaPosition?: 'none' | 'top' | 'left';
|
|
33
|
+
/**
|
|
34
|
+
* How the media image should be resized. Defaults to `'cover'`.
|
|
35
|
+
*/
|
|
36
|
+
resizeMode?: ImageResizeMode;
|
|
37
|
+
/**
|
|
38
|
+
* Alt text for the media image.
|
|
39
|
+
*/
|
|
40
|
+
alternativeText?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Image source for a small circular artwork icon rendered to the left of children.
|
|
43
|
+
*/
|
|
44
|
+
artwork?: ImageSourcePropType;
|
|
45
|
+
paddingSize?: 's' | 'm' | 'l';
|
|
46
|
+
aspectRatio?: MediaContainerAspectRatio;
|
|
47
|
+
/**
|
|
48
|
+
* Explicit numeric aspect ratio (width / height) for the media container.
|
|
49
|
+
* Used when `aspectRatio` is `'auto'` to provide a pre-known value
|
|
50
|
+
* (e.g. parsed from an image URL) instead of waiting for `Image.getSize`.
|
|
51
|
+
* Ignored when `aspectRatio` is a named preset.
|
|
52
|
+
*/
|
|
53
|
+
numericAspectRatio?: number;
|
|
54
|
+
hasBorder?: boolean;
|
|
55
|
+
backgroundColor?: PxCardBackgroundColor;
|
|
56
|
+
backgroundImage?: ImageSourcePropType;
|
|
57
|
+
}
|
|
58
|
+
export declare function PxCardContainer(props: PxCardContainerProps): React.JSX.Element;
|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AC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC,eAAe,CAAC,EAAE,mBAAmB,CAAC;CACvC;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,qBAwM1D"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Image, ImageBackground, StyleSheet, TouchableOpacity, View, } from 'react-native';
|
|
3
|
+
import { useTheme } from '@proximus/lavender-styling-native';
|
|
4
|
+
import { a11y, e2eID, useImageAspectRatio, } from '@proximus/lavender-common-native';
|
|
5
|
+
import { PxMediaContainer, } from '@proximus/lavender-mediacontainer-native';
|
|
6
|
+
export const PxCardBackgroundColor = {
|
|
7
|
+
Light: 'ColorBackgroundSurfaceLight',
|
|
8
|
+
Default: 'ColorBackgroundSurfaceDefault',
|
|
9
|
+
Strong: 'ColorBackgroundSurfaceStrong',
|
|
10
|
+
Stronger: 'ColorBackgroundSurfaceStronger',
|
|
11
|
+
Dark: 'ColorBackgroundSurfaceDark',
|
|
12
|
+
Brand: 'ColorBackgroundSurfaceBrand',
|
|
13
|
+
BrandLight: 'ColorBackgroundSurfaceBrandLight',
|
|
14
|
+
};
|
|
15
|
+
export function PxCardContainer(props) {
|
|
16
|
+
const { inverted = false, children, containerStyle, testID, onPress, disabled = false, accessibilityLabel, accessibilityHint, accessibilityRole, src, mediaPosition = 'none', resizeMode = 'cover', alternativeText, artwork, paddingSize = 's', aspectRatio, numericAspectRatio: numericAspectRatioProp, hasBorder = true, backgroundColor, backgroundImage, ...rest } = props;
|
|
17
|
+
const { theme } = useTheme();
|
|
18
|
+
const hasMedia = !!src && mediaPosition !== 'none';
|
|
19
|
+
const hasTopMedia = hasMedia && mediaPosition === 'top';
|
|
20
|
+
const hasLeftMedia = hasMedia && mediaPosition === 'left';
|
|
21
|
+
const needsInnerPadding = hasMedia || !!backgroundImage;
|
|
22
|
+
const isAutoAspectRatio = aspectRatio === 'auto';
|
|
23
|
+
const hookAspectRatio = useImageAspectRatio(isAutoAspectRatio && hasTopMedia && numericAspectRatioProp == null
|
|
24
|
+
? src
|
|
25
|
+
: undefined);
|
|
26
|
+
const resolvedImageAspectRatio = numericAspectRatioProp ?? hookAspectRatio;
|
|
27
|
+
const customBackgroundColor = backgroundColor
|
|
28
|
+
? theme.t(backgroundColor)
|
|
29
|
+
: theme.t(inverted
|
|
30
|
+
? 'ColorBackgroundSurfaceDark'
|
|
31
|
+
: 'ColorBackgroundSurfaceDefault');
|
|
32
|
+
const borderColor = theme.t(inverted ? 'ColorBorderMainInverted' : 'ColorBorderMainDefault');
|
|
33
|
+
const paddingToken = {
|
|
34
|
+
s: 'PaddingSMobile',
|
|
35
|
+
m: 'PaddingMMobile',
|
|
36
|
+
l: 'PaddingLMobile',
|
|
37
|
+
}[paddingSize];
|
|
38
|
+
const padding = theme.t(paddingToken).number;
|
|
39
|
+
const gap = theme.t('SpacingSMobile').number;
|
|
40
|
+
const style = useMemo(() => [
|
|
41
|
+
{
|
|
42
|
+
backgroundColor: customBackgroundColor,
|
|
43
|
+
borderRadius: theme.t('RadiusMain').number,
|
|
44
|
+
padding: needsInnerPadding ? 0 : padding,
|
|
45
|
+
gap: needsInnerPadding ? 0 : gap,
|
|
46
|
+
overflow: 'hidden',
|
|
47
|
+
borderWidth: hasBorder ? 1 : 0,
|
|
48
|
+
borderColor,
|
|
49
|
+
flexDirection: hasLeftMedia ? 'row' : 'column',
|
|
50
|
+
},
|
|
51
|
+
containerStyle,
|
|
52
|
+
], [
|
|
53
|
+
customBackgroundColor,
|
|
54
|
+
theme,
|
|
55
|
+
needsInnerPadding,
|
|
56
|
+
hasLeftMedia,
|
|
57
|
+
padding,
|
|
58
|
+
gap,
|
|
59
|
+
hasBorder,
|
|
60
|
+
borderColor,
|
|
61
|
+
containerStyle,
|
|
62
|
+
]);
|
|
63
|
+
const sharedA11yProps = a11y({
|
|
64
|
+
accessibilityRole: onPress
|
|
65
|
+
? accessibilityRole || 'button'
|
|
66
|
+
: accessibilityRole,
|
|
67
|
+
accessible: onPress ? true : !!accessibilityLabel,
|
|
68
|
+
...(onPress && { accessibilityState: { disabled } }),
|
|
69
|
+
accessibilityLabel,
|
|
70
|
+
accessibilityHint,
|
|
71
|
+
...rest,
|
|
72
|
+
});
|
|
73
|
+
const mediaImage = src ? (React.createElement(Image, { source: src, resizeMode: resizeMode, accessibilityLabel: alternativeText, style: hasLeftMedia ? StyleSheet.absoluteFill : styles.mediaImage, ...(testID && e2eID(`${testID}-media-image`)) })) : null;
|
|
74
|
+
const artworkImage = artwork ? (React.createElement(Image, { source: artwork, style: [styles.artwork, { borderRadius: theme.t('RadiusPill').number }], ...(testID && e2eID(`${testID}-artwork`)) })) : null;
|
|
75
|
+
const wrappedChildren = artworkImage ? (React.createElement(View, { style: styles.artworkRow },
|
|
76
|
+
artworkImage,
|
|
77
|
+
React.createElement(View, { style: styles.artworkContent }, children))) : (children);
|
|
78
|
+
const innerContent = (React.createElement(React.Fragment, null,
|
|
79
|
+
hasTopMedia && (React.createElement(PxMediaContainer, { aspectRatio: aspectRatio, numericAspectRatio: isAutoAspectRatio ? resolvedImageAspectRatio : undefined, testID: testID ? `${testID}-media-wrapper` : undefined }, mediaImage)),
|
|
80
|
+
hasLeftMedia && (React.createElement(View, { style: styles.leftMediaWrapper, ...(testID && e2eID(`${testID}-media-wrapper`)) }, mediaImage)),
|
|
81
|
+
hasMedia ? (React.createElement(View, { style: {
|
|
82
|
+
padding,
|
|
83
|
+
gap,
|
|
84
|
+
flex: hasLeftMedia ? 1 : undefined,
|
|
85
|
+
}, ...(testID && e2eID(`${testID}-content-wrapper`)) }, wrappedChildren)) : backgroundImage ? (React.createElement(View, { style: { padding, gap } }, wrappedChildren)) : (wrappedChildren)));
|
|
86
|
+
const content = backgroundImage ? (React.createElement(ImageBackground, { source: backgroundImage, resizeMode: "cover", style: styles.backgroundImage, ...(testID && e2eID(`${testID}-background-image`)) }, innerContent)) : (innerContent);
|
|
87
|
+
if (onPress) {
|
|
88
|
+
return (React.createElement(TouchableOpacity, { ...e2eID(testID), onPress: onPress, disabled: disabled, focusable: true, ...sharedA11yProps, style: style }, content));
|
|
89
|
+
}
|
|
90
|
+
return (React.createElement(View, { ...e2eID(testID), ...sharedA11yProps, style: style }, content));
|
|
91
|
+
}
|
|
92
|
+
const styles = StyleSheet.create({
|
|
93
|
+
backgroundImage: {
|
|
94
|
+
flex: 1,
|
|
95
|
+
},
|
|
96
|
+
leftMediaWrapper: {
|
|
97
|
+
width: '33.33%',
|
|
98
|
+
},
|
|
99
|
+
mediaImage: {
|
|
100
|
+
width: '100%',
|
|
101
|
+
height: '100%',
|
|
102
|
+
},
|
|
103
|
+
artwork: {
|
|
104
|
+
width: 48,
|
|
105
|
+
height: 48,
|
|
106
|
+
},
|
|
107
|
+
artworkRow: {
|
|
108
|
+
flexDirection: 'row',
|
|
109
|
+
gap: 12,
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
},
|
|
112
|
+
artworkContent: {
|
|
113
|
+
flex: 1,
|
|
114
|
+
},
|
|
115
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface PxCardHeaderProps {
|
|
3
|
+
title: string;
|
|
4
|
+
subtitle?: string;
|
|
5
|
+
inverted?: boolean;
|
|
6
|
+
testID?: string;
|
|
7
|
+
size?: 'default' | 'large';
|
|
8
|
+
}
|
|
9
|
+
/** @deprecated Use PxCardHeaderProps instead. */
|
|
10
|
+
export type CardHeadingProps = PxCardHeaderProps;
|
|
11
|
+
export declare function PxCardHeading({ title, subtitle, inverted, testID, size, }: PxCardHeaderProps): React.JSX.Element;
|
|
12
|
+
/** @deprecated Use PxCardHeader instead. */
|
|
13
|
+
export declare const CardHeading: typeof PxCardHeading;
|
|
14
|
+
//# sourceMappingURL=PxCardHeading.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PxCardHeading.d.ts","sourceRoot":"","sources":["../src/PxCardHeading.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;CAC5B;AAED,iDAAiD;AACjD,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAEjD,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,IAAgB,GACjB,EAAE,iBAAiB,qBA2CnB;AAED,4CAA4C;AAC5C,eAAO,MAAM,WAAW,sBAAgB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { Header, Body } from '@proximus/lavender-texts-native';
|
|
4
|
+
import { e2eID } from '@proximus/lavender-common-native';
|
|
5
|
+
import { useTheme } from '@proximus/lavender-styling-native';
|
|
6
|
+
export function PxCardHeading({ title, subtitle, inverted, testID, size = 'default', }) {
|
|
7
|
+
const { theme } = useTheme();
|
|
8
|
+
const isLarge = size === 'large';
|
|
9
|
+
const titleFontSize = isLarge
|
|
10
|
+
? theme.t('TextSizeHeading2xlMobile').number
|
|
11
|
+
: theme.t('TextSizeHeadingLMobile').number;
|
|
12
|
+
const subtitleFontSize = theme.t('TextSizeBodyLMobile').number;
|
|
13
|
+
const lineHeightRatio = theme.t('LineHeightRatioL');
|
|
14
|
+
const gap = theme.t('Spacing2xsMobile').number;
|
|
15
|
+
return (React.createElement(View, { style: {
|
|
16
|
+
gap,
|
|
17
|
+
alignItems: 'flex-start',
|
|
18
|
+
flex: 1,
|
|
19
|
+
} },
|
|
20
|
+
React.createElement(Header, { inverted: inverted, style: {
|
|
21
|
+
fontSize: titleFontSize,
|
|
22
|
+
lineHeight: titleFontSize * lineHeightRatio,
|
|
23
|
+
}, ...(testID && e2eID(`${testID}-title`)) }, title),
|
|
24
|
+
subtitle && (React.createElement(Body, { inverted: inverted, style: {
|
|
25
|
+
fontSize: subtitleFontSize,
|
|
26
|
+
lineHeight: subtitleFontSize * lineHeightRatio,
|
|
27
|
+
}, ...(testID && e2eID(`${testID}-subtitle`)) }, subtitle))));
|
|
28
|
+
}
|
|
29
|
+
/** @deprecated Use PxCardHeader instead. */
|
|
30
|
+
export const CardHeading = PxCardHeading;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proximus/lavender-pokecard-native",
|
|
3
|
+
"version": "1.2.4-alpha.10",
|
|
4
|
+
"description": "Pokecard component",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"@proximus/lavender-button-native": "*",
|
|
12
|
+
"@proximus/lavender-buttonicon-native": "*",
|
|
13
|
+
"@proximus/lavender-common-native": "*",
|
|
14
|
+
"@proximus/lavender-mediacontainer-native": "*",
|
|
15
|
+
"@proximus/lavender-styling-native": "*",
|
|
16
|
+
"@proximus/lavender-texts-native": "*"
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
}
|
|
21
|
+
}
|