@proximus/lavender-button-native 0.1.0-alpha.4 → 0.1.0-alpha.7
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/CHANGELOG.md +16 -0
- package/dist/PxButton.d.ts +2 -2
- package/dist/PxButton.d.ts.map +1 -1
- package/dist/PxButton.js +142 -0
- package/dist/far/away/package.json +34 -0
- package/dist/index.js +1 -0
- package/package.json +15 -8
- package/src/PxButton.tsx +43 -30
- package/tsconfig.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.1.0-alpha.7](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-button-native@0.1.0-alpha.6...@proximus/lavender-button-native@0.1.0-alpha.7) (2025-09-26)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @proximus/lavender-button-native
|
|
9
|
+
|
|
10
|
+
# [0.1.0-alpha.6](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-button-native@0.1.0-alpha.5...@proximus/lavender-button-native@0.1.0-alpha.6) (2025-09-25)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **BCRI-000000:** no free space on gh runner during build ([#27](https://github.com/Pxs-Corporate/react-native-lavender/issues/27)) ([a7c8604](https://github.com/Pxs-Corporate/react-native-lavender/commit/a7c86043b5cefcb10fd768d449c5718fbabe87ec))
|
|
15
|
+
|
|
16
|
+
# [0.1.0-alpha.5](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-button-native@0.1.0-alpha.4...@proximus/lavender-button-native@0.1.0-alpha.5) (2025-09-19)
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
- **BCRI-4249550:** message card + tag components ([#22](https://github.com/Pxs-Corporate/react-native-lavender/issues/22)) ([39fb91c](https://github.com/Pxs-Corporate/react-native-lavender/commit/39fb91cc294a37d07e63fca2b4e993d90b867082))
|
|
21
|
+
|
|
6
22
|
# [0.1.0-alpha.4](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-button-native@0.1.0-alpha.3...@proximus/lavender-button-native@0.1.0-alpha.4) (2025-09-12)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @proximus/lavender-button-native
|
package/dist/PxButton.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface IProps extends AccessibilityProps {
|
|
|
15
15
|
testID?: string;
|
|
16
16
|
prefix?: ReactNode;
|
|
17
17
|
suffix?: ReactNode;
|
|
18
|
-
|
|
18
|
+
inverted?: boolean;
|
|
19
19
|
}
|
|
20
|
-
export declare function PxButton({ title, wrapperStyle, titleStyle, isRoundedBottomCorner, testID, disabled, prefix, suffix, onPress,
|
|
20
|
+
export declare function PxButton({ title, wrapperStyle, titleStyle, isRoundedBottomCorner, testID, disabled, prefix, suffix, onPress, type, accessibilityLabel, accessibilityHint, inverted, }: IProps): React.JSX.Element;
|
|
21
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,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,
|
|
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('ColorBorderNone'),
|
|
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
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proximus/lavender-button-native",
|
|
3
|
+
"version": "0.1.0-alpha.7",
|
|
4
|
+
"description": "Button component",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"peerDependencies": {
|
|
8
|
+
"@proximus/lavender-common-native": "*",
|
|
9
|
+
"@proximus/lavender-icon-native": "*",
|
|
10
|
+
"@proximus/lavender-styling-native": "*",
|
|
11
|
+
"@proximus/lavender-texts-native": "*"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"lerna": {
|
|
17
|
+
"command": {
|
|
18
|
+
"publish": {
|
|
19
|
+
"assets": [
|
|
20
|
+
{
|
|
21
|
+
"from": "dist/far/away/package.json",
|
|
22
|
+
"to": "."
|
|
23
|
+
},
|
|
24
|
+
"dist/*.js",
|
|
25
|
+
"dist/*.d.ts",
|
|
26
|
+
"dist/*.d.ts.map",
|
|
27
|
+
"src",
|
|
28
|
+
"package.json"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"gitHead": "e50a17526561b3eafb159e36c737173956093e0d"
|
|
34
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PxButton';
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proximus/lavender-button-native",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.7",
|
|
4
4
|
"description": "Button component",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"clean": "rm -rf dist",
|
|
9
|
-
"
|
|
9
|
+
"transform-package-json": "node ../../../scripts/tranformPackageJson.js package.json dist/far/away",
|
|
10
|
+
"prepublish": "yarn clean && yarn transform-package-json && yarn build",
|
|
10
11
|
"build": "npx tsc -p tsconfig.json"
|
|
11
12
|
},
|
|
12
13
|
"peerDependencies": {
|
|
@@ -16,10 +17,10 @@
|
|
|
16
17
|
"@proximus/lavender-texts-native": "workspace:*"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
|
-
"@proximus/lavender-common-native": "0.1.0-alpha.
|
|
20
|
-
"@proximus/lavender-icon-native": "0.1.0-alpha.
|
|
21
|
-
"@proximus/lavender-styling-native": "0.1.0-alpha.
|
|
22
|
-
"@proximus/lavender-texts-native": "0.1.0-alpha.
|
|
20
|
+
"@proximus/lavender-common-native": "0.1.0-alpha.6",
|
|
21
|
+
"@proximus/lavender-icon-native": "0.1.0-alpha.6",
|
|
22
|
+
"@proximus/lavender-styling-native": "0.1.0-alpha.5",
|
|
23
|
+
"@proximus/lavender-texts-native": "0.1.0-alpha.6"
|
|
23
24
|
},
|
|
24
25
|
"publishConfig": {
|
|
25
26
|
"access": "public"
|
|
@@ -28,12 +29,18 @@
|
|
|
28
29
|
"command": {
|
|
29
30
|
"publish": {
|
|
30
31
|
"assets": [
|
|
31
|
-
|
|
32
|
+
{
|
|
33
|
+
"from": "dist/far/away/package.json",
|
|
34
|
+
"to": "."
|
|
35
|
+
},
|
|
36
|
+
"dist/*.js",
|
|
37
|
+
"dist/*.d.ts",
|
|
38
|
+
"dist/*.d.ts.map",
|
|
32
39
|
"src",
|
|
33
40
|
"package.json"
|
|
34
41
|
]
|
|
35
42
|
}
|
|
36
43
|
}
|
|
37
44
|
},
|
|
38
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "e50a17526561b3eafb159e36c737173956093e0d"
|
|
39
46
|
}
|
package/src/PxButton.tsx
CHANGED
|
@@ -26,23 +26,25 @@ export interface IProps extends AccessibilityProps {
|
|
|
26
26
|
testID?: string;
|
|
27
27
|
prefix?: ReactNode;
|
|
28
28
|
suffix?: ReactNode;
|
|
29
|
-
|
|
29
|
+
inverted?: boolean;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
function getButtonColors(props: Partial<IProps>, theme: ITheme) {
|
|
33
|
-
const {
|
|
33
|
+
const { type, inverted = false } = props;
|
|
34
|
+
|
|
35
|
+
const invertedSuffix = inverted ? 'Inverted' : 'Default';
|
|
34
36
|
|
|
35
37
|
switch (type) {
|
|
36
38
|
case 'secondary': {
|
|
37
39
|
return {
|
|
38
|
-
backgroundColor:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
textColor:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
disabledText: theme.t(
|
|
40
|
+
backgroundColor: theme.t(
|
|
41
|
+
`ColorBackgroundContainerSecondary${invertedSuffix}`
|
|
42
|
+
),
|
|
43
|
+
textColor: theme.t(`ColorTextBrand${invertedSuffix}`),
|
|
44
|
+
disabledBackgroundColor: theme.t(
|
|
45
|
+
`ColorBackgroundStateDisabled${invertedSuffix}`
|
|
46
|
+
),
|
|
47
|
+
disabledText: theme.t(`ColorTextStateDisabled${invertedSuffix}`),
|
|
46
48
|
};
|
|
47
49
|
}
|
|
48
50
|
|
|
@@ -50,21 +52,23 @@ function getButtonColors(props: Partial<IProps>, theme: ITheme) {
|
|
|
50
52
|
return {
|
|
51
53
|
backgroundColor: 'transparent',
|
|
52
54
|
disabledBackgroundColor: 'transparent',
|
|
53
|
-
textColor: theme.t(
|
|
54
|
-
disabledText: theme.t(
|
|
55
|
+
textColor: theme.t(`ColorTextBrand${invertedSuffix}`),
|
|
56
|
+
disabledText: theme.t(`ColorTextStateDisabled${invertedSuffix}`),
|
|
55
57
|
};
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
default: {
|
|
59
61
|
return {
|
|
60
|
-
backgroundColor:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
textColor:
|
|
62
|
+
backgroundColor: theme.t(
|
|
63
|
+
`ColorBackgroundContainerPrimary${invertedSuffix}`
|
|
64
|
+
),
|
|
65
|
+
textColor: inverted
|
|
64
66
|
? theme.t('ColorTextBrandDefault')
|
|
65
67
|
: theme.t('ColorTextBrandInverted'),
|
|
66
|
-
disabledBackgroundColor: theme.t(
|
|
67
|
-
|
|
68
|
+
disabledBackgroundColor: theme.t(
|
|
69
|
+
`ColorBackgroundStateDisabled${invertedSuffix}`
|
|
70
|
+
),
|
|
71
|
+
disabledText: theme.t(`ColorTextStateDisabled${invertedSuffix}`),
|
|
68
72
|
borderColor: theme.t('ColorBorderNone'),
|
|
69
73
|
};
|
|
70
74
|
}
|
|
@@ -72,28 +76,34 @@ function getButtonColors(props: Partial<IProps>, theme: ITheme) {
|
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
function getIconColor(props: Partial<IProps>, theme: ITheme) {
|
|
75
|
-
const { type, disabled } = props;
|
|
79
|
+
const { type, disabled, inverted } = props;
|
|
80
|
+
|
|
81
|
+
const invertedSuffix = inverted ? 'Inverted' : 'Default';
|
|
76
82
|
|
|
77
83
|
switch (type) {
|
|
78
84
|
case 'primary':
|
|
79
85
|
return disabled
|
|
80
|
-
? theme.t(
|
|
81
|
-
:
|
|
86
|
+
? theme.t(`ColorIconStateDisabled${invertedSuffix}`)
|
|
87
|
+
: inverted
|
|
88
|
+
? theme.t('ColorIconBrandDefault')
|
|
89
|
+
: theme.t('ColorIconBrandInverted');
|
|
82
90
|
default:
|
|
83
91
|
return disabled
|
|
84
|
-
? theme.t(
|
|
85
|
-
: theme.t(
|
|
92
|
+
? theme.t(`ColorIconStateDisabled${invertedSuffix}`)
|
|
93
|
+
: theme.t(`ColorIconBrand${invertedSuffix}`);
|
|
86
94
|
}
|
|
87
95
|
}
|
|
88
96
|
|
|
89
97
|
function getIconBackgroundColor(props: Partial<IProps>, theme: ITheme) {
|
|
90
|
-
const { type, disabled } = props;
|
|
98
|
+
const { type, disabled, inverted } = props;
|
|
99
|
+
|
|
100
|
+
const invertedSuffix = inverted ? 'Inverted' : 'Default';
|
|
91
101
|
|
|
92
102
|
switch (type) {
|
|
93
103
|
case 'tertiary':
|
|
94
104
|
return disabled
|
|
95
|
-
? theme.t(
|
|
96
|
-
: theme.t(
|
|
105
|
+
? theme.t(`ColorBackgroundStateDisabled${invertedSuffix}`)
|
|
106
|
+
: theme.t(`ColorBackgroundContainerSecondary${invertedSuffix}`);
|
|
97
107
|
default:
|
|
98
108
|
return undefined;
|
|
99
109
|
}
|
|
@@ -109,22 +119,25 @@ export function PxButton({
|
|
|
109
119
|
prefix,
|
|
110
120
|
suffix,
|
|
111
121
|
onPress,
|
|
112
|
-
loading = false,
|
|
113
122
|
type = 'primary',
|
|
114
123
|
accessibilityLabel,
|
|
115
124
|
accessibilityHint,
|
|
125
|
+
inverted,
|
|
116
126
|
}: IProps) {
|
|
117
127
|
const { theme } = useTheme();
|
|
118
|
-
const buttonColors = getButtonColors({
|
|
128
|
+
const buttonColors = getButtonColors({ type, inverted }, theme);
|
|
119
129
|
|
|
120
130
|
const iconStyles = {
|
|
121
131
|
size: theme.t('SizeIconXs').number,
|
|
122
|
-
color: getIconColor({ type, disabled }, theme),
|
|
132
|
+
color: getIconColor({ type, disabled, inverted }, theme),
|
|
123
133
|
padding: theme.t('Padding2xsMobile').number,
|
|
124
134
|
};
|
|
125
135
|
|
|
126
136
|
const iconBackgroundStyles = {
|
|
127
|
-
backgroundColor: getIconBackgroundColor(
|
|
137
|
+
backgroundColor: getIconBackgroundColor(
|
|
138
|
+
{ type, disabled, inverted },
|
|
139
|
+
theme
|
|
140
|
+
),
|
|
128
141
|
borderRadius: theme.t('RadiusPill').number,
|
|
129
142
|
marginHorizontal: theme.t('SpacingXsMobile').number,
|
|
130
143
|
};
|
package/tsconfig.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "../../../tsconfig.npm.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"outDir": "dist"
|
|
4
|
+
"outDir": "dist"
|
|
5
5
|
},
|
|
6
6
|
"include": ["src","../../../lib.d.ts"],
|
|
7
|
-
"exclude": ["dist", "node_modules", "src/**/*.
|
|
7
|
+
"exclude": ["dist", "node_modules", "src/**/*.spec.tsx", "src/**/*.spec.ts"]
|
|
8
8
|
}
|