@proximus/lavender-button-native 0.1.0-alpha.1 → 0.1.0-alpha.13
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/PxButton.d.ts +3 -2
- package/dist/PxButton.d.ts.map +1 -1
- package/dist/PxButton.js +142 -0
- package/package.json +10 -31
- package/CHANGELOG.md +0 -25
- package/src/PxButton.tsx +0 -258
- package/tsconfig.json +0 -8
- /package/{src/index.ts → dist/index.js} +0 -0
package/dist/PxButton.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ReactNode } from 'react';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { AccessibilityProps, StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
4
4
|
import type { ITheme } from '@proximus/lavender-styling-native';
|
|
5
|
-
export type Variant = 'primary' | 'secondary' | 'tertiary'
|
|
5
|
+
export type Variant = 'primary' | 'secondary' | 'tertiary';
|
|
6
6
|
export interface IProps extends AccessibilityProps {
|
|
7
7
|
title: string;
|
|
8
8
|
titleStyle?: StyleProp<TextStyle>;
|
|
@@ -15,6 +15,7 @@ export interface IProps extends AccessibilityProps {
|
|
|
15
15
|
testID?: string;
|
|
16
16
|
prefix?: ReactNode;
|
|
17
17
|
suffix?: ReactNode;
|
|
18
|
+
inverted?: boolean;
|
|
18
19
|
}
|
|
19
|
-
export declare function PxButton(
|
|
20
|
+
export declare function PxButton({ title, wrapperStyle, titleStyle, isRoundedBottomCorner, testID, disabled, prefix, suffix, onPress, type, accessibilityLabel, accessibilityHint, inverted, }: IProps): React.JSX.Element;
|
|
20
21
|
//# sourceMappingURL=PxButton.d.ts.map
|
package/dist/PxButton.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PxButton.d.ts","sourceRoot":"","sources":["../src/PxButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EACV,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAIhE,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,
|
|
1
|
+
{"version":3,"file":"PxButton.d.ts","sourceRoot":"","sources":["../src/PxButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EACV,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,SAAS,EACV,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAIhE,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;AAE3D,MAAM,WAAW,MAAO,SAAQ,kBAAkB;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAkFD,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,YAAY,EACZ,UAAU,EACV,qBAA4B,EAC5B,MAAM,EACN,QAAgB,EAChB,MAAM,EACN,MAAM,EACN,OAAO,EACP,IAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,GACT,EAAE,MAAM,qBA2GR"}
|
package/dist/PxButton.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import { a11y, e2eID } from '@proximus/lavender-common-native';
|
|
4
|
+
import { useTheme } from '@proximus/lavender-styling-native';
|
|
5
|
+
import { Header } from '@proximus/lavender-texts-native';
|
|
6
|
+
function getButtonColors(props, theme) {
|
|
7
|
+
const { type, inverted = false } = props;
|
|
8
|
+
const invertedSuffix = inverted ? 'Inverted' : 'Default';
|
|
9
|
+
switch (type) {
|
|
10
|
+
case 'secondary': {
|
|
11
|
+
return {
|
|
12
|
+
backgroundColor: theme.t(`ColorBackgroundContainerSecondary${invertedSuffix}`),
|
|
13
|
+
textColor: theme.t(`ColorTextBrand${invertedSuffix}`),
|
|
14
|
+
disabledBackgroundColor: theme.t(`ColorBackgroundStateDisabled${invertedSuffix}`),
|
|
15
|
+
disabledText: theme.t(`ColorTextStateDisabled${invertedSuffix}`),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
case 'tertiary': {
|
|
19
|
+
return {
|
|
20
|
+
backgroundColor: 'transparent',
|
|
21
|
+
disabledBackgroundColor: 'transparent',
|
|
22
|
+
textColor: theme.t(`ColorTextBrand${invertedSuffix}`),
|
|
23
|
+
disabledText: theme.t(`ColorTextStateDisabled${invertedSuffix}`),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
default: {
|
|
27
|
+
return {
|
|
28
|
+
backgroundColor: theme.t(`ColorBackgroundContainerPrimary${invertedSuffix}`),
|
|
29
|
+
textColor: inverted
|
|
30
|
+
? theme.t('ColorTextBrandDefault')
|
|
31
|
+
: theme.t('ColorTextBrandInverted'),
|
|
32
|
+
disabledBackgroundColor: theme.t(`ColorBackgroundStateDisabled${invertedSuffix}`),
|
|
33
|
+
disabledText: theme.t(`ColorTextStateDisabled${invertedSuffix}`),
|
|
34
|
+
borderColor: theme.t('ColorBorderNoneDefault'),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function getIconColor(props, theme) {
|
|
40
|
+
const { type, disabled, inverted } = props;
|
|
41
|
+
const invertedSuffix = inverted ? 'Inverted' : 'Default';
|
|
42
|
+
switch (type) {
|
|
43
|
+
case 'primary':
|
|
44
|
+
return disabled
|
|
45
|
+
? theme.t(`ColorIconStateDisabled${invertedSuffix}`)
|
|
46
|
+
: inverted
|
|
47
|
+
? theme.t('ColorIconBrandDefault')
|
|
48
|
+
: theme.t('ColorIconBrandInverted');
|
|
49
|
+
default:
|
|
50
|
+
return disabled
|
|
51
|
+
? theme.t(`ColorIconStateDisabled${invertedSuffix}`)
|
|
52
|
+
: theme.t(`ColorIconBrand${invertedSuffix}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function getIconBackgroundColor(props, theme) {
|
|
56
|
+
const { type, disabled, inverted } = props;
|
|
57
|
+
const invertedSuffix = inverted ? 'Inverted' : 'Default';
|
|
58
|
+
switch (type) {
|
|
59
|
+
case 'tertiary':
|
|
60
|
+
return disabled
|
|
61
|
+
? theme.t(`ColorBackgroundStateDisabled${invertedSuffix}`)
|
|
62
|
+
: theme.t(`ColorBackgroundContainerSecondary${invertedSuffix}`);
|
|
63
|
+
default:
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function PxButton({ title, wrapperStyle, titleStyle, isRoundedBottomCorner = true, testID, disabled = false, prefix, suffix, onPress, type = 'primary', accessibilityLabel, accessibilityHint, inverted, }) {
|
|
68
|
+
const { theme } = useTheme();
|
|
69
|
+
const buttonColors = getButtonColors({ type, inverted }, theme);
|
|
70
|
+
const iconStyles = {
|
|
71
|
+
size: theme.t('SizeIconXs').number,
|
|
72
|
+
color: getIconColor({ type, disabled, inverted }, theme),
|
|
73
|
+
padding: theme.t('Padding2xsMobile').number,
|
|
74
|
+
};
|
|
75
|
+
const iconBackgroundStyles = {
|
|
76
|
+
backgroundColor: getIconBackgroundColor({ type, disabled, inverted }, theme),
|
|
77
|
+
borderRadius: theme.t('RadiusPill').number,
|
|
78
|
+
marginHorizontal: theme.t('SpacingXsMobile').number,
|
|
79
|
+
};
|
|
80
|
+
let adaptedPrefix = prefix && React.cloneElement(prefix, iconStyles);
|
|
81
|
+
adaptedPrefix =
|
|
82
|
+
prefix && type === 'tertiary' ? (React.createElement(View, { style: iconBackgroundStyles }, adaptedPrefix)) : (adaptedPrefix);
|
|
83
|
+
let adaptedSuffix = suffix && React.cloneElement(suffix, iconStyles);
|
|
84
|
+
adaptedSuffix =
|
|
85
|
+
suffix && type === 'tertiary' ? (React.createElement(View, { style: iconBackgroundStyles }, adaptedSuffix)) : (adaptedSuffix);
|
|
86
|
+
return (React.createElement(TouchableOpacity, { ...e2eID(testID), onPress: onPress, focusable: true, disabled: disabled, ...a11y({
|
|
87
|
+
accessibilityRole: 'button',
|
|
88
|
+
accessible: true,
|
|
89
|
+
accessibilityState: {
|
|
90
|
+
disabled,
|
|
91
|
+
},
|
|
92
|
+
accessibilityLabel: accessibilityLabel || title,
|
|
93
|
+
accessibilityHint,
|
|
94
|
+
}), style: wrapperStyle },
|
|
95
|
+
React.createElement(View, { style: [
|
|
96
|
+
styles.button,
|
|
97
|
+
{
|
|
98
|
+
backgroundColor: buttonColors.backgroundColor,
|
|
99
|
+
borderColor: buttonColors.borderColor,
|
|
100
|
+
borderRadius: theme.t('RadiusButtonSmall').number,
|
|
101
|
+
...(isRoundedBottomCorner && {
|
|
102
|
+
borderBottomEndRadius: theme.t('RadiusButtonBig').number,
|
|
103
|
+
}),
|
|
104
|
+
paddingHorizontal: type === 'tertiary' ? 0 : theme.t('PaddingMMobile').number,
|
|
105
|
+
paddingVertical: type === 'tertiary'
|
|
106
|
+
? theme.t('Padding2xsMobile').number
|
|
107
|
+
: theme.t('PaddingXsMobile').number,
|
|
108
|
+
gap: theme.t('Spacing2xsMobile').number,
|
|
109
|
+
...(type !== 'tertiary' && {
|
|
110
|
+
minHeight: theme.t('SpacingLMobile').number,
|
|
111
|
+
}),
|
|
112
|
+
},
|
|
113
|
+
disabled && {
|
|
114
|
+
backgroundColor: buttonColors.disabledBackgroundColor,
|
|
115
|
+
},
|
|
116
|
+
type === 'tertiary' && {
|
|
117
|
+
paddingVertical: 4,
|
|
118
|
+
paddingHorizontal: 0,
|
|
119
|
+
},
|
|
120
|
+
] },
|
|
121
|
+
adaptedPrefix,
|
|
122
|
+
React.createElement(Header, { style: [
|
|
123
|
+
{
|
|
124
|
+
color: buttonColors.textColor,
|
|
125
|
+
},
|
|
126
|
+
disabled && {
|
|
127
|
+
color: buttonColors.disabledText,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
lineHeight: 21,
|
|
131
|
+
},
|
|
132
|
+
titleStyle,
|
|
133
|
+
] }, title),
|
|
134
|
+
adaptedSuffix)));
|
|
135
|
+
}
|
|
136
|
+
const styles = StyleSheet.create({
|
|
137
|
+
button: {
|
|
138
|
+
alignItems: 'center',
|
|
139
|
+
flexDirection: 'row',
|
|
140
|
+
justifyContent: 'center',
|
|
141
|
+
},
|
|
142
|
+
});
|
package/package.json
CHANGED
|
@@ -1,40 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proximus/lavender-button-native",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.13",
|
|
4
4
|
"description": "Button component",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"main": "
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"prepublish": "yarn clean && yarn build",
|
|
11
|
-
"build": "npx tsc -p tsconfig.json"
|
|
12
|
-
},
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
13
10
|
"peerDependencies": {
|
|
14
|
-
"@proximus/lavender-common-native": "
|
|
15
|
-
"@proximus/lavender-icon-native": "
|
|
16
|
-
"@proximus/lavender-styling-native": "
|
|
17
|
-
"@proximus/lavender-texts-native": "
|
|
18
|
-
},
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"@proximus/lavender-common-native": "0.1.0-alpha.0",
|
|
21
|
-
"@proximus/lavender-icon-native": "0.1.0-alpha.0",
|
|
22
|
-
"@proximus/lavender-styling-native": "0.1.0-alpha.0",
|
|
23
|
-
"@proximus/lavender-texts-native": "0.1.0-alpha.0"
|
|
11
|
+
"@proximus/lavender-common-native": "*",
|
|
12
|
+
"@proximus/lavender-icon-native": "*",
|
|
13
|
+
"@proximus/lavender-styling-native": "*",
|
|
14
|
+
"@proximus/lavender-texts-native": "*"
|
|
24
15
|
},
|
|
25
16
|
"publishConfig": {
|
|
26
17
|
"access": "public"
|
|
27
|
-
}
|
|
28
|
-
"lerna": {
|
|
29
|
-
"command": {
|
|
30
|
-
"publish": {
|
|
31
|
-
"assets": [
|
|
32
|
-
"dist",
|
|
33
|
-
"src",
|
|
34
|
-
"package.json"
|
|
35
|
-
]
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
"gitHead": "59b3436b786cc1c73b4a20a98b2a85139e75b72e"
|
|
18
|
+
}
|
|
40
19
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
# [0.1.0-alpha.1](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-button-native@0.1.0-alpha.0...@proximus/lavender-button-native@0.1.0-alpha.1) (2025-08-13)
|
|
7
|
-
|
|
8
|
-
### Features
|
|
9
|
-
|
|
10
|
-
- **BCRI-4210372:** automatic versionning ([9c1f0a0](https://github.com/Pxs-Corporate/react-native-lavender/commit/9c1f0a00e19a9d1a277044ea627632032a674102))
|
|
11
|
-
|
|
12
|
-
# 0.1.0-alpha.0 (2025-08-12)
|
|
13
|
-
|
|
14
|
-
### Features
|
|
15
|
-
|
|
16
|
-
- **BCRI-000000:** lerna setup ([1d24b00](https://github.com/Pxs-Corporate/react-native-lavender/commit/1d24b00a9ca917d873e9c497bfebf6a0cc570d13))
|
|
17
|
-
- **BCRI-000000:** lerna setup ([f7fa837](https://github.com/Pxs-Corporate/react-native-lavender/commit/f7fa837fb15e0fd1ee838f99f421ff23a52c0403))
|
|
18
|
-
- **BCRI-000000:** remove default E2E on DEV env build for all components ([a5d27bf](https://github.com/Pxs-Corporate/react-native-lavender/commit/a5d27bfaaebf5b75f3160f31c64b590b7bd00b93))
|
|
19
|
-
- **BCRI-3619796:** top navigation bar ([0b2bcae](https://github.com/Pxs-Corporate/react-native-lavender/commit/0b2bcaee7243b9f00f88e2b2fb97d86cf0cf5b77))
|
|
20
|
-
- **BCRI-3651606:** mono repo creation ([d19f852](https://github.com/Pxs-Corporate/react-native-lavender/commit/d19f852a710963ff85b1a9d31d18188217aa23ab))
|
|
21
|
-
- **BCRI-3689585:** icon module ([f13230d](https://github.com/Pxs-Corporate/react-native-lavender/commit/f13230d9c7643680089a0db2c69b96cd73ff246e))
|
|
22
|
-
- **BCRI-3702949:** tertiary button ([4999cea](https://github.com/Pxs-Corporate/react-native-lavender/commit/4999cea4d7866084d0f8c1cba37070c6cdaa7601))
|
|
23
|
-
- **BCRI-3702949:** tertiary button ([db24455](https://github.com/Pxs-Corporate/react-native-lavender/commit/db24455bd9687d80920be3e42c9e1fc14703a571))
|
|
24
|
-
- **BCRI-3749589:** button icon component ([62cfd94](https://github.com/Pxs-Corporate/react-native-lavender/commit/62cfd945420c26cf6da6dfb802cc998c613e9687))
|
|
25
|
-
- **BCRI-3810979:** tile components ([46fc5c7](https://github.com/Pxs-Corporate/react-native-lavender/commit/46fc5c7a0ddff6c2db43fba0de9929626092f265))
|
package/src/PxButton.tsx
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import type {
|
|
4
|
-
AccessibilityProps,
|
|
5
|
-
StyleProp,
|
|
6
|
-
TextStyle,
|
|
7
|
-
ViewStyle,
|
|
8
|
-
} from 'react-native';
|
|
9
|
-
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
10
|
-
import { a11y, e2eID } from '@proximus/lavender-common-native';
|
|
11
|
-
import type { ITheme } from '@proximus/lavender-styling-native';
|
|
12
|
-
import { Colors, ThemeName, useTheme } from '@proximus/lavender-styling-native';
|
|
13
|
-
import { Header } from '@proximus/lavender-texts-native';
|
|
14
|
-
|
|
15
|
-
export type Variant = 'primary' | 'secondary' | 'tertiary' | 'order';
|
|
16
|
-
|
|
17
|
-
export interface IProps extends AccessibilityProps {
|
|
18
|
-
title: string;
|
|
19
|
-
titleStyle?: StyleProp<TextStyle>;
|
|
20
|
-
wrapperStyle?: StyleProp<ViewStyle>;
|
|
21
|
-
onPress?: () => void;
|
|
22
|
-
type?: Variant;
|
|
23
|
-
isRoundedBottomCorner?: boolean;
|
|
24
|
-
theme?: ITheme;
|
|
25
|
-
disabled?: boolean;
|
|
26
|
-
testID?: string;
|
|
27
|
-
prefix?: ReactNode;
|
|
28
|
-
suffix?: ReactNode;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function getButtonColors(props: IProps, theme: ITheme) {
|
|
32
|
-
switch (props.type) {
|
|
33
|
-
case 'order': {
|
|
34
|
-
if (theme.name === ThemeName.SCARLET) {
|
|
35
|
-
return {
|
|
36
|
-
color: Colors.status.order,
|
|
37
|
-
textColor: Colors.black,
|
|
38
|
-
disabledColor: Colors.v7.shadesOfGrey.whiteOpacity8,
|
|
39
|
-
disabledText: Colors.v7.shadesOfGrey.whiteOpacity16,
|
|
40
|
-
disabledBorderColor: Colors.v7.shadesOfGrey.whiteOpacity8,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
color: Colors.status.order,
|
|
45
|
-
textColor: Colors.black,
|
|
46
|
-
disabledColor: Colors.v8_1.shadesOfGrey.dark4,
|
|
47
|
-
disabledText: Colors.v7.shadesOfGrey.black0Opacity12,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
case 'secondary': {
|
|
52
|
-
if (theme.name === ThemeName.SCARLET) {
|
|
53
|
-
return {
|
|
54
|
-
color: Colors.v7.shadesOfGrey.whiteOpacity24,
|
|
55
|
-
textColor: Colors.shadesOfGrey.white,
|
|
56
|
-
borderColor: Colors.v7.shadesOfGrey.whiteOpacity24,
|
|
57
|
-
disabledColor: Colors.v7.shadesOfGrey.whiteOpacity8,
|
|
58
|
-
disabledText: Colors.v7.shadesOfGrey.whiteOpacity16,
|
|
59
|
-
disabledBorderColor: Colors.v7.shadesOfGrey.whiteOpacity8,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
color: Colors.v7.shadesOfPurple.purple1,
|
|
64
|
-
textColor: Colors.v7.shadesOfPurple.purple2,
|
|
65
|
-
disabledColor: Colors.v7.shadesOfGrey.black0Opacity4,
|
|
66
|
-
disabledText: Colors.v7.shadesOfGrey.black0Opacity12,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
case 'tertiary': {
|
|
71
|
-
return {
|
|
72
|
-
color: 'transparent',
|
|
73
|
-
disabledColor: 'transparent',
|
|
74
|
-
textColor: Colors.v8_1.shadesOfPurple.purple,
|
|
75
|
-
disabledText: Colors.v8_1.shadesOfGrey.dark160,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
default: {
|
|
79
|
-
if (theme.name === ThemeName.SCARLET) {
|
|
80
|
-
return {
|
|
81
|
-
color: Colors.v7.shadesOfGrey.whiteOpacity24,
|
|
82
|
-
textColor: Colors.shadesOfGrey.white,
|
|
83
|
-
borderColor: Colors.v7.shadesOfGrey.whiteOpacity24,
|
|
84
|
-
disabledColor: Colors.v7.shadesOfGrey.whiteOpacity8,
|
|
85
|
-
disabledText: Colors.v7.shadesOfGrey.whiteOpacity16,
|
|
86
|
-
disabledBorderColor: Colors.v7.shadesOfGrey.whiteOpacity8,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
color: theme.t('BackgroundColorActionPrimaryDefault'),
|
|
91
|
-
textColor: theme.t('TextColorActionBrandInverted'),
|
|
92
|
-
disabledColor: theme.t('BackgroundColorActionDisabledDefault'),
|
|
93
|
-
disabledText: Colors.v7.shadesOfGrey.black0Opacity12,
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function getIconColor(type: Variant, disabled: boolean) {
|
|
100
|
-
switch (type) {
|
|
101
|
-
case 'primary':
|
|
102
|
-
return disabled ? Colors.v8_1.shadesOfGrey.dark120 : Colors.white;
|
|
103
|
-
default:
|
|
104
|
-
return disabled
|
|
105
|
-
? Colors.v8_1.shadesOfGrey.dark120
|
|
106
|
-
: Colors.v8_1.shadesOfPurple.purple;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function getIconBackgroundColor(type: Variant, disabled: boolean) {
|
|
111
|
-
switch (type) {
|
|
112
|
-
case 'tertiary':
|
|
113
|
-
return disabled
|
|
114
|
-
? Colors.v8_1.shadesOfGrey.dark4
|
|
115
|
-
: Colors.v8_1.shadesOfPurple.purpleLight;
|
|
116
|
-
default:
|
|
117
|
-
return undefined;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export function PxButton(props: IProps) {
|
|
122
|
-
const {
|
|
123
|
-
title,
|
|
124
|
-
wrapperStyle,
|
|
125
|
-
titleStyle,
|
|
126
|
-
isRoundedBottomCorner = true,
|
|
127
|
-
testID,
|
|
128
|
-
disabled = false,
|
|
129
|
-
prefix,
|
|
130
|
-
suffix,
|
|
131
|
-
type = 'primary',
|
|
132
|
-
accessibilityLabel,
|
|
133
|
-
accessibilityHint,
|
|
134
|
-
} = props;
|
|
135
|
-
|
|
136
|
-
const themeContext = useTheme();
|
|
137
|
-
const theme = props.theme || themeContext.theme;
|
|
138
|
-
const buttonColors = getButtonColors(props, theme);
|
|
139
|
-
|
|
140
|
-
let adaptedPrefix =
|
|
141
|
-
prefix &&
|
|
142
|
-
React.cloneElement(prefix as ReactElement, {
|
|
143
|
-
size: 16,
|
|
144
|
-
color: getIconColor(type, disabled),
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
adaptedPrefix =
|
|
148
|
-
prefix && type === 'tertiary' ? (
|
|
149
|
-
<View
|
|
150
|
-
style={[
|
|
151
|
-
styles.iconBackground,
|
|
152
|
-
{ backgroundColor: getIconBackgroundColor(type, disabled) },
|
|
153
|
-
]}
|
|
154
|
-
>
|
|
155
|
-
{adaptedPrefix}
|
|
156
|
-
</View>
|
|
157
|
-
) : (
|
|
158
|
-
adaptedPrefix
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
let adaptedSuffix =
|
|
162
|
-
suffix &&
|
|
163
|
-
React.cloneElement(suffix as ReactElement, {
|
|
164
|
-
size: 16,
|
|
165
|
-
color: getIconColor(type, disabled),
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
adaptedSuffix =
|
|
169
|
-
suffix && type === 'tertiary' ? (
|
|
170
|
-
<View
|
|
171
|
-
style={[
|
|
172
|
-
styles.iconBackground,
|
|
173
|
-
{ backgroundColor: getIconBackgroundColor(type, disabled) },
|
|
174
|
-
]}
|
|
175
|
-
>
|
|
176
|
-
{adaptedSuffix}
|
|
177
|
-
</View>
|
|
178
|
-
) : (
|
|
179
|
-
adaptedSuffix
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
return (
|
|
183
|
-
<TouchableOpacity
|
|
184
|
-
{...e2eID(testID)}
|
|
185
|
-
onPress={props.onPress}
|
|
186
|
-
focusable={true}
|
|
187
|
-
disabled={disabled}
|
|
188
|
-
{...a11y({
|
|
189
|
-
accessibilityRole: 'button',
|
|
190
|
-
accessible: true,
|
|
191
|
-
accessibilityState: {
|
|
192
|
-
disabled,
|
|
193
|
-
},
|
|
194
|
-
accessibilityLabel: accessibilityLabel || title,
|
|
195
|
-
accessibilityHint,
|
|
196
|
-
})}
|
|
197
|
-
style={wrapperStyle}
|
|
198
|
-
>
|
|
199
|
-
<View
|
|
200
|
-
style={[
|
|
201
|
-
styles.button,
|
|
202
|
-
{
|
|
203
|
-
backgroundColor: buttonColors.color,
|
|
204
|
-
borderColor: buttonColors.borderColor,
|
|
205
|
-
},
|
|
206
|
-
disabled && {
|
|
207
|
-
backgroundColor: buttonColors.disabledColor,
|
|
208
|
-
borderColor: buttonColors.disabledBorderColor,
|
|
209
|
-
},
|
|
210
|
-
isRoundedBottomCorner && {
|
|
211
|
-
borderBottomRightRadius: 22,
|
|
212
|
-
},
|
|
213
|
-
type === 'tertiary' && {
|
|
214
|
-
paddingVertical: 4,
|
|
215
|
-
paddingHorizontal: 0,
|
|
216
|
-
},
|
|
217
|
-
]}
|
|
218
|
-
>
|
|
219
|
-
{adaptedPrefix}
|
|
220
|
-
<Header
|
|
221
|
-
style={[
|
|
222
|
-
{
|
|
223
|
-
color: buttonColors.textColor,
|
|
224
|
-
},
|
|
225
|
-
disabled && {
|
|
226
|
-
color: buttonColors.disabledText,
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
lineHeight: 21,
|
|
230
|
-
},
|
|
231
|
-
titleStyle,
|
|
232
|
-
]}
|
|
233
|
-
>
|
|
234
|
-
{title}
|
|
235
|
-
</Header>
|
|
236
|
-
{adaptedSuffix}
|
|
237
|
-
</View>
|
|
238
|
-
</TouchableOpacity>
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const styles = StyleSheet.create({
|
|
243
|
-
button: {
|
|
244
|
-
alignItems: 'center',
|
|
245
|
-
flexDirection: 'row',
|
|
246
|
-
justifyContent: 'center',
|
|
247
|
-
borderRadius: 4,
|
|
248
|
-
paddingHorizontal: 24,
|
|
249
|
-
paddingVertical: 8,
|
|
250
|
-
gap: 4,
|
|
251
|
-
},
|
|
252
|
-
|
|
253
|
-
iconBackground: {
|
|
254
|
-
borderRadius: 16,
|
|
255
|
-
padding: 4,
|
|
256
|
-
marginHorizontal: 8,
|
|
257
|
-
},
|
|
258
|
-
});
|
package/tsconfig.json
DELETED
|
File without changes
|