@proximus/lavender-button-native 0.1.0-alpha.0

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 ADDED
@@ -0,0 +1,19 @@
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.0 (2025-08-12)
7
+
8
+ ### Features
9
+
10
+ - **BCRI-000000:** lerna setup ([1d24b00](https://github.com/Pxs-Corporate/react-native-lavender/commit/1d24b00a9ca917d873e9c497bfebf6a0cc570d13))
11
+ - **BCRI-000000:** lerna setup ([f7fa837](https://github.com/Pxs-Corporate/react-native-lavender/commit/f7fa837fb15e0fd1ee838f99f421ff23a52c0403))
12
+ - **BCRI-000000:** remove default E2E on DEV env build for all components ([a5d27bf](https://github.com/Pxs-Corporate/react-native-lavender/commit/a5d27bfaaebf5b75f3160f31c64b590b7bd00b93))
13
+ - **BCRI-3619796:** top navigation bar ([0b2bcae](https://github.com/Pxs-Corporate/react-native-lavender/commit/0b2bcaee7243b9f00f88e2b2fb97d86cf0cf5b77))
14
+ - **BCRI-3651606:** mono repo creation ([d19f852](https://github.com/Pxs-Corporate/react-native-lavender/commit/d19f852a710963ff85b1a9d31d18188217aa23ab))
15
+ - **BCRI-3689585:** icon module ([f13230d](https://github.com/Pxs-Corporate/react-native-lavender/commit/f13230d9c7643680089a0db2c69b96cd73ff246e))
16
+ - **BCRI-3702949:** tertiary button ([4999cea](https://github.com/Pxs-Corporate/react-native-lavender/commit/4999cea4d7866084d0f8c1cba37070c6cdaa7601))
17
+ - **BCRI-3702949:** tertiary button ([db24455](https://github.com/Pxs-Corporate/react-native-lavender/commit/db24455bd9687d80920be3e42c9e1fc14703a571))
18
+ - **BCRI-3749589:** button icon component ([62cfd94](https://github.com/Pxs-Corporate/react-native-lavender/commit/62cfd945420c26cf6da6dfb802cc998c613e9687))
19
+ - **BCRI-3810979:** tile components ([46fc5c7](https://github.com/Pxs-Corporate/react-native-lavender/commit/46fc5c7a0ddff6c2db43fba0de9929626092f265))
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@proximus/lavender-button-native",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "Button component",
5
+ "license": "MIT",
6
+ "main": "src/index.ts",
7
+ "scripts": {
8
+ "build": "echo \"we publish TS so no build\" && exit 0"
9
+ },
10
+ "peerDependencies": {
11
+ "@proximus/lavender-common-native": "workspace:*",
12
+ "@proximus/lavender-icon-native": "workspace:*",
13
+ "@proximus/lavender-styling-native": "workspace:*",
14
+ "@proximus/lavender-texts-native": "workspace:*"
15
+ },
16
+ "devDependencies": {
17
+ "@proximus/lavender-common-native": "workspace:*",
18
+ "@proximus/lavender-icon-native": "workspace:*",
19
+ "@proximus/lavender-styling-native": "workspace:*",
20
+ "@proximus/lavender-texts-native": "workspace:*"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "lerna": {
26
+ "command": {
27
+ "publish": {
28
+ "assets": [
29
+ "src/**/*.ts",
30
+ "package.json"
31
+ ]
32
+ }
33
+ }
34
+ },
35
+ "gitHead": "a4355bc543076d5914b48d76005a8686de1a5184"
36
+ }
@@ -0,0 +1,258 @@
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/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './PxButton';
package/tsconfig.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../../tsconfig.json"
3
+ }