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

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.
@@ -0,0 +1,21 @@
1
+ import type { ReactNode } from 'react';
2
+ import React from 'react';
3
+ import type { AccessibilityProps, StyleProp, TextStyle, ViewStyle } from 'react-native';
4
+ import type { ITheme } from '@proximus/lavender-styling-native';
5
+ export type Variant = 'primary' | 'secondary' | 'tertiary';
6
+ export interface IProps extends AccessibilityProps {
7
+ title: string;
8
+ titleStyle?: StyleProp<TextStyle>;
9
+ wrapperStyle?: StyleProp<ViewStyle>;
10
+ onPress?: () => void;
11
+ type?: Variant;
12
+ isRoundedBottomCorner?: boolean;
13
+ theme?: ITheme;
14
+ disabled?: boolean;
15
+ testID?: string;
16
+ prefix?: ReactNode;
17
+ suffix?: ReactNode;
18
+ inverted?: boolean;
19
+ }
20
+ export declare function PxButton({ title, wrapperStyle, titleStyle, isRoundedBottomCorner, testID, disabled, prefix, suffix, onPress, type, accessibilityLabel, accessibilityHint, inverted, }: IProps): React.JSX.Element;
21
+ //# sourceMappingURL=PxButton.d.ts.map
@@ -0,0 +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,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"}
@@ -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,2 @@
1
+ export * from './PxButton';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,36 +1,19 @@
1
1
  {
2
2
  "name": "@proximus/lavender-button-native",
3
- "version": "0.1.0-alpha.0",
3
+ "version": "0.1.0-alpha.12",
4
4
  "description": "Button component",
5
5
  "license": "MIT",
6
- "main": "src/index.ts",
7
- "scripts": {
8
- "build": "echo \"we publish TS so no build\" && exit 0"
9
- },
6
+ "main": "dist/index.js",
7
+ "files": [
8
+ "dist"
9
+ ],
10
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:*"
11
+ "@proximus/lavender-common-native": "*",
12
+ "@proximus/lavender-icon-native": "*",
13
+ "@proximus/lavender-styling-native": "*",
14
+ "@proximus/lavender-texts-native": "*"
21
15
  },
22
16
  "publishConfig": {
23
17
  "access": "public"
24
- },
25
- "lerna": {
26
- "command": {
27
- "publish": {
28
- "assets": [
29
- "src/**/*.ts",
30
- "package.json"
31
- ]
32
- }
33
- }
34
- },
35
- "gitHead": "a4355bc543076d5914b48d76005a8686de1a5184"
18
+ }
36
19
  }
package/CHANGELOG.md DELETED
@@ -1,19 +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.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/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
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.json"
3
- }
File without changes