@proximus/lavender-button-native 0.1.0-alpha.1 → 0.1.0-alpha.3
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 +12 -0
- package/dist/PxButton.d.ts +3 -2
- package/dist/PxButton.d.ts.map +1 -1
- package/package.json +6 -7
- package/src/PxButton.tsx +91 -121
- package/tsconfig.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.3](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-button-native@0.1.0-alpha.2...@proximus/lavender-button-native@0.1.0-alpha.3) (2025-09-05)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **BCRI-4279213:** update token architecture and component styles ([#18](https://github.com/Pxs-Corporate/react-native-lavender/issues/18)) ([2fabf41](https://github.com/Pxs-Corporate/react-native-lavender/commit/2fabf416ce069e9756daa868c3012181db87e7f5))
|
|
11
|
+
|
|
12
|
+
# [0.1.0-alpha.2](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-button-native@0.1.0-alpha.1...@proximus/lavender-button-native@0.1.0-alpha.2) (2025-08-13)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- **BCRI-4210372:** fix types field in modules ([68ac126](https://github.com/Pxs-Corporate/react-native-lavender/commit/68ac12657112473ae9e0e683076b1d9172be9ce6))
|
|
17
|
+
|
|
6
18
|
# [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
19
|
|
|
8
20
|
### Features
|
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
|
+
loading?: boolean;
|
|
18
19
|
}
|
|
19
|
-
export declare function PxButton(
|
|
20
|
+
export declare function PxButton({ title, wrapperStyle, titleStyle, isRoundedBottomCorner, testID, disabled, prefix, suffix, onPress, loading, type, accessibilityLabel, accessibilityHint, }: 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,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAwED,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,YAAY,EACZ,UAAU,EACV,qBAA4B,EAC5B,MAAM,EACN,QAAgB,EAChB,MAAM,EACN,MAAM,EACN,OAAO,EACP,OAAe,EACf,IAAgB,EAChB,kBAAkB,EAClB,iBAAiB,GAClB,EAAE,MAAM,qBAwGR"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proximus/lavender-button-native",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.3",
|
|
4
4
|
"description": "Button component",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
7
|
"scripts": {
|
|
9
8
|
"clean": "rm -rf dist",
|
|
10
9
|
"prepublish": "yarn clean && yarn build",
|
|
@@ -17,10 +16,10 @@
|
|
|
17
16
|
"@proximus/lavender-texts-native": "workspace:*"
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|
|
20
|
-
"@proximus/lavender-common-native": "0.1.0-alpha.
|
|
21
|
-
"@proximus/lavender-icon-native": "0.1.0-alpha.
|
|
22
|
-
"@proximus/lavender-styling-native": "0.1.0-alpha.
|
|
23
|
-
"@proximus/lavender-texts-native": "0.1.0-alpha.
|
|
19
|
+
"@proximus/lavender-common-native": "0.1.0-alpha.2",
|
|
20
|
+
"@proximus/lavender-icon-native": "0.1.0-alpha.2",
|
|
21
|
+
"@proximus/lavender-styling-native": "0.1.0-alpha.2",
|
|
22
|
+
"@proximus/lavender-texts-native": "0.1.0-alpha.2"
|
|
24
23
|
},
|
|
25
24
|
"publishConfig": {
|
|
26
25
|
"access": "public"
|
|
@@ -36,5 +35,5 @@
|
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
},
|
|
39
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "38a67765befa2567a3f5f57976b7933cf5b85a24"
|
|
40
39
|
}
|
package/src/PxButton.tsx
CHANGED
|
@@ -9,10 +9,10 @@ import type {
|
|
|
9
9
|
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
10
10
|
import { a11y, e2eID } from '@proximus/lavender-common-native';
|
|
11
11
|
import type { ITheme } from '@proximus/lavender-styling-native';
|
|
12
|
-
import {
|
|
12
|
+
import { useTheme } from '@proximus/lavender-styling-native';
|
|
13
13
|
import { Header } from '@proximus/lavender-texts-native';
|
|
14
14
|
|
|
15
|
-
export type Variant = 'primary' | 'secondary' | 'tertiary'
|
|
15
|
+
export type Variant = 'primary' | 'secondary' | 'tertiary';
|
|
16
16
|
|
|
17
17
|
export interface IProps extends AccessibilityProps {
|
|
18
18
|
title: string;
|
|
@@ -26,155 +26,125 @@ export interface IProps extends AccessibilityProps {
|
|
|
26
26
|
testID?: string;
|
|
27
27
|
prefix?: ReactNode;
|
|
28
28
|
suffix?: ReactNode;
|
|
29
|
+
loading?: boolean;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
function getButtonColors(props: IProps
|
|
32
|
-
|
|
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
|
-
}
|
|
32
|
+
function getButtonColors(props: Partial<IProps>, theme: ITheme) {
|
|
33
|
+
const { loading, type } = props;
|
|
50
34
|
|
|
35
|
+
switch (type) {
|
|
51
36
|
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
37
|
return {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
38
|
+
backgroundColor: loading
|
|
39
|
+
? theme.t('ColorBackgroundStateDisabledDefault')
|
|
40
|
+
: theme.t('ColorBackgroundContainerSecondaryDefault'),
|
|
41
|
+
textColor: loading
|
|
42
|
+
? theme.t('ColorTextBrandInverted')
|
|
43
|
+
: theme.t('ColorTextBrandDefault'),
|
|
44
|
+
disabledBackgroundColor: theme.t('ColorBackgroundStateDisabledDefault'),
|
|
45
|
+
disabledText: theme.t('ColorTextStateDisabledDefault'),
|
|
67
46
|
};
|
|
68
47
|
}
|
|
69
48
|
|
|
70
49
|
case 'tertiary': {
|
|
71
50
|
return {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
textColor:
|
|
75
|
-
disabledText:
|
|
51
|
+
backgroundColor: 'transparent',
|
|
52
|
+
disabledBackgroundColor: 'transparent',
|
|
53
|
+
textColor: theme.t('ColorTextBrandDefault'),
|
|
54
|
+
disabledText: theme.t('ColorTextStateDisabledDefault'),
|
|
76
55
|
};
|
|
77
56
|
}
|
|
57
|
+
|
|
78
58
|
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
59
|
return {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
60
|
+
backgroundColor: loading
|
|
61
|
+
? theme.t('ColorBackgroundStateDisabledDefault')
|
|
62
|
+
: theme.t('ColorBackgroundContainerPrimaryDefault'),
|
|
63
|
+
textColor: loading
|
|
64
|
+
? theme.t('ColorTextBrandDefault')
|
|
65
|
+
: theme.t('ColorTextBrandInverted'),
|
|
66
|
+
disabledBackgroundColor: theme.t('ColorBackgroundStateDisabledDefault'),
|
|
67
|
+
disabledText: theme.t('ColorTextStateDisabledDefault'),
|
|
68
|
+
borderColor: theme.t('ColorBorderNone'),
|
|
94
69
|
};
|
|
95
70
|
}
|
|
96
71
|
}
|
|
97
72
|
}
|
|
98
73
|
|
|
99
|
-
function getIconColor(
|
|
74
|
+
function getIconColor(props: Partial<IProps>, theme: ITheme) {
|
|
75
|
+
const { type, disabled } = props;
|
|
76
|
+
|
|
100
77
|
switch (type) {
|
|
101
78
|
case 'primary':
|
|
102
|
-
return disabled
|
|
79
|
+
return disabled
|
|
80
|
+
? theme.t('ColorIconStateDisabledDefault')
|
|
81
|
+
: theme.t('ColorIconBrandInverted');
|
|
103
82
|
default:
|
|
104
83
|
return disabled
|
|
105
|
-
?
|
|
106
|
-
:
|
|
84
|
+
? theme.t('ColorIconStateDisabledDefault')
|
|
85
|
+
: theme.t('ColorIconBrandDefault');
|
|
107
86
|
}
|
|
108
87
|
}
|
|
109
88
|
|
|
110
|
-
function getIconBackgroundColor(
|
|
89
|
+
function getIconBackgroundColor(props: Partial<IProps>, theme: ITheme) {
|
|
90
|
+
const { type, disabled } = props;
|
|
91
|
+
|
|
111
92
|
switch (type) {
|
|
112
93
|
case 'tertiary':
|
|
113
94
|
return disabled
|
|
114
|
-
?
|
|
115
|
-
:
|
|
95
|
+
? theme.t('ColorBackgroundStateDisabledDefault')
|
|
96
|
+
: theme.t('ColorBackgroundContainerSecondaryDefault');
|
|
116
97
|
default:
|
|
117
98
|
return undefined;
|
|
118
99
|
}
|
|
119
100
|
}
|
|
120
101
|
|
|
121
|
-
export function PxButton(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
|
|
102
|
+
export function PxButton({
|
|
103
|
+
title,
|
|
104
|
+
wrapperStyle,
|
|
105
|
+
titleStyle,
|
|
106
|
+
isRoundedBottomCorner = true,
|
|
107
|
+
testID,
|
|
108
|
+
disabled = false,
|
|
109
|
+
prefix,
|
|
110
|
+
suffix,
|
|
111
|
+
onPress,
|
|
112
|
+
loading = false,
|
|
113
|
+
type = 'primary',
|
|
114
|
+
accessibilityLabel,
|
|
115
|
+
accessibilityHint,
|
|
116
|
+
}: IProps) {
|
|
117
|
+
const { theme } = useTheme();
|
|
118
|
+
const buttonColors = getButtonColors({ loading, type }, theme);
|
|
119
|
+
|
|
120
|
+
const iconStyles = {
|
|
121
|
+
size: theme.t('SizeIconXs').number,
|
|
122
|
+
color: getIconColor({ type, disabled }, theme),
|
|
123
|
+
padding: theme.t('Padding2xsMobile').number,
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const iconBackgroundStyles = {
|
|
127
|
+
backgroundColor: getIconBackgroundColor({ type, disabled }, theme),
|
|
128
|
+
borderRadius: theme.t('RadiusPill').number,
|
|
129
|
+
marginHorizontal: theme.t('SpacingXsMobile').number,
|
|
130
|
+
};
|
|
139
131
|
|
|
140
132
|
let adaptedPrefix =
|
|
141
|
-
prefix &&
|
|
142
|
-
React.cloneElement(prefix as ReactElement, {
|
|
143
|
-
size: 16,
|
|
144
|
-
color: getIconColor(type, disabled),
|
|
145
|
-
});
|
|
133
|
+
prefix && React.cloneElement(prefix as ReactElement, iconStyles);
|
|
146
134
|
|
|
147
135
|
adaptedPrefix =
|
|
148
136
|
prefix && type === 'tertiary' ? (
|
|
149
|
-
<View
|
|
150
|
-
style={[
|
|
151
|
-
styles.iconBackground,
|
|
152
|
-
{ backgroundColor: getIconBackgroundColor(type, disabled) },
|
|
153
|
-
]}
|
|
154
|
-
>
|
|
155
|
-
{adaptedPrefix}
|
|
156
|
-
</View>
|
|
137
|
+
<View style={iconBackgroundStyles}>{adaptedPrefix}</View>
|
|
157
138
|
) : (
|
|
158
139
|
adaptedPrefix
|
|
159
140
|
);
|
|
160
141
|
|
|
161
142
|
let adaptedSuffix =
|
|
162
|
-
suffix &&
|
|
163
|
-
React.cloneElement(suffix as ReactElement, {
|
|
164
|
-
size: 16,
|
|
165
|
-
color: getIconColor(type, disabled),
|
|
166
|
-
});
|
|
143
|
+
suffix && React.cloneElement(suffix as ReactElement, iconStyles);
|
|
167
144
|
|
|
168
145
|
adaptedSuffix =
|
|
169
146
|
suffix && type === 'tertiary' ? (
|
|
170
|
-
<View
|
|
171
|
-
style={[
|
|
172
|
-
styles.iconBackground,
|
|
173
|
-
{ backgroundColor: getIconBackgroundColor(type, disabled) },
|
|
174
|
-
]}
|
|
175
|
-
>
|
|
176
|
-
{adaptedSuffix}
|
|
177
|
-
</View>
|
|
147
|
+
<View style={iconBackgroundStyles}>{adaptedSuffix}</View>
|
|
178
148
|
) : (
|
|
179
149
|
adaptedSuffix
|
|
180
150
|
);
|
|
@@ -182,7 +152,7 @@ export function PxButton(props: IProps) {
|
|
|
182
152
|
return (
|
|
183
153
|
<TouchableOpacity
|
|
184
154
|
{...e2eID(testID)}
|
|
185
|
-
onPress={
|
|
155
|
+
onPress={onPress}
|
|
186
156
|
focusable={true}
|
|
187
157
|
disabled={disabled}
|
|
188
158
|
{...a11y({
|
|
@@ -200,15 +170,25 @@ export function PxButton(props: IProps) {
|
|
|
200
170
|
style={[
|
|
201
171
|
styles.button,
|
|
202
172
|
{
|
|
203
|
-
backgroundColor: buttonColors.
|
|
173
|
+
backgroundColor: buttonColors.backgroundColor,
|
|
204
174
|
borderColor: buttonColors.borderColor,
|
|
175
|
+
borderRadius: theme.t('RadiusButtonSmall').number,
|
|
176
|
+
...(isRoundedBottomCorner && {
|
|
177
|
+
borderBottomEndRadius: theme.t('RadiusButtonBig').number,
|
|
178
|
+
}),
|
|
179
|
+
paddingHorizontal:
|
|
180
|
+
type === 'tertiary' ? 0 : theme.t('PaddingMMobile').number,
|
|
181
|
+
paddingVertical:
|
|
182
|
+
type === 'tertiary'
|
|
183
|
+
? theme.t('Padding2xsMobile').number
|
|
184
|
+
: theme.t('PaddingXsMobile').number,
|
|
185
|
+
gap: theme.t('Spacing2xsMobile').number,
|
|
186
|
+
...(type !== 'tertiary' && {
|
|
187
|
+
minHeight: theme.t('SpacingLMobile').number,
|
|
188
|
+
}),
|
|
205
189
|
},
|
|
206
190
|
disabled && {
|
|
207
|
-
backgroundColor: buttonColors.
|
|
208
|
-
borderColor: buttonColors.disabledBorderColor,
|
|
209
|
-
},
|
|
210
|
-
isRoundedBottomCorner && {
|
|
211
|
-
borderBottomRightRadius: 22,
|
|
191
|
+
backgroundColor: buttonColors.disabledBackgroundColor,
|
|
212
192
|
},
|
|
213
193
|
type === 'tertiary' && {
|
|
214
194
|
paddingVertical: 4,
|
|
@@ -244,15 +224,5 @@ const styles = StyleSheet.create({
|
|
|
244
224
|
alignItems: 'center',
|
|
245
225
|
flexDirection: 'row',
|
|
246
226
|
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
227
|
},
|
|
258
228
|
});
|