@proximus/lavender-button-native 0.1.0-alpha.7 → 0.1.0-beta.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.
@@ -8,8 +8,12 @@ export interface IProps extends AccessibilityProps {
8
8
  titleStyle?: StyleProp<TextStyle>;
9
9
  wrapperStyle?: StyleProp<ViewStyle>;
10
10
  onPress?: () => void;
11
+ /** @deprecated Use `variant` instead. */
11
12
  type?: Variant;
13
+ variant?: Variant;
14
+ /** @deprecated Use `shape` instead. */
12
15
  isRoundedBottomCorner?: boolean;
16
+ shape?: 'default' | 'alternative';
13
17
  theme?: ITheme;
14
18
  disabled?: boolean;
15
19
  testID?: string;
@@ -17,5 +21,5 @@ export interface IProps extends AccessibilityProps {
17
21
  suffix?: ReactNode;
18
22
  inverted?: boolean;
19
23
  }
20
- export declare function PxButton({ title, wrapperStyle, titleStyle, isRoundedBottomCorner, testID, disabled, prefix, suffix, onPress, type, accessibilityLabel, accessibilityHint, inverted, }: IProps): React.JSX.Element;
24
+ export declare function PxButton(props: IProps): React.JSX.Element;
21
25
  //# sourceMappingURL=PxButton.d.ts.map
@@ -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,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"}
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,yCAAyC;IACzC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uCAAuC;IACvC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,KAAK,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;IAClC,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;AA8GD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,qBA0HrC"}
package/dist/PxButton.js CHANGED
@@ -3,10 +3,38 @@ import { StyleSheet, TouchableOpacity, View } from 'react-native';
3
3
  import { a11y, e2eID } from '@proximus/lavender-common-native';
4
4
  import { useTheme } from '@proximus/lavender-styling-native';
5
5
  import { Header } from '@proximus/lavender-texts-native';
6
+ /**
7
+ * Keeps backward compatibility for `type` prop.
8
+ */
9
+ function useVariant(props) {
10
+ const { variant, type } = props;
11
+ if (type && !variant) {
12
+ return type;
13
+ }
14
+ else if (!variant) {
15
+ return 'primary';
16
+ }
17
+ return variant;
18
+ }
19
+ /**
20
+ * Keeps backward compatibility for `isRoundedBottomCorner` prop.
21
+ */
22
+ function useShape(props) {
23
+ const { shape, isRoundedBottomCorner } = props;
24
+ if (shape) {
25
+ return shape;
26
+ }
27
+ else {
28
+ if (isRoundedBottomCorner === undefined || isRoundedBottomCorner) {
29
+ return 'default';
30
+ }
31
+ return 'alternative';
32
+ }
33
+ }
6
34
  function getButtonColors(props, theme) {
7
- const { type, inverted = false } = props;
35
+ const { variant, inverted = false } = props;
8
36
  const invertedSuffix = inverted ? 'Inverted' : 'Default';
9
- switch (type) {
37
+ switch (variant) {
10
38
  case 'secondary': {
11
39
  return {
12
40
  backgroundColor: theme.t(`ColorBackgroundContainerSecondary${invertedSuffix}`),
@@ -31,15 +59,15 @@ function getButtonColors(props, theme) {
31
59
  : theme.t('ColorTextBrandInverted'),
32
60
  disabledBackgroundColor: theme.t(`ColorBackgroundStateDisabled${invertedSuffix}`),
33
61
  disabledText: theme.t(`ColorTextStateDisabled${invertedSuffix}`),
34
- borderColor: theme.t('ColorBorderNone'),
62
+ borderColor: theme.t('ColorBorderNoneDefault'),
35
63
  };
36
64
  }
37
65
  }
38
66
  }
39
67
  function getIconColor(props, theme) {
40
- const { type, disabled, inverted } = props;
68
+ const { variant, disabled, inverted } = props;
41
69
  const invertedSuffix = inverted ? 'Inverted' : 'Default';
42
- switch (type) {
70
+ switch (variant) {
43
71
  case 'primary':
44
72
  return disabled
45
73
  ? theme.t(`ColorIconStateDisabled${invertedSuffix}`)
@@ -53,9 +81,9 @@ function getIconColor(props, theme) {
53
81
  }
54
82
  }
55
83
  function getIconBackgroundColor(props, theme) {
56
- const { type, disabled, inverted } = props;
84
+ const { variant, disabled, inverted } = props;
57
85
  const invertedSuffix = inverted ? 'Inverted' : 'Default';
58
- switch (type) {
86
+ switch (variant) {
59
87
  case 'tertiary':
60
88
  return disabled
61
89
  ? theme.t(`ColorBackgroundStateDisabled${invertedSuffix}`)
@@ -64,25 +92,28 @@ function getIconBackgroundColor(props, theme) {
64
92
  return undefined;
65
93
  }
66
94
  }
67
- export function PxButton({ title, wrapperStyle, titleStyle, isRoundedBottomCorner = true, testID, disabled = false, prefix, suffix, onPress, type = 'primary', accessibilityLabel, accessibilityHint, inverted, }) {
95
+ export function PxButton(props) {
96
+ const { title, wrapperStyle, titleStyle, testID, disabled = false, prefix, suffix, onPress, accessibilityLabel, accessibilityHint, inverted, } = props;
68
97
  const { theme } = useTheme();
69
- const buttonColors = getButtonColors({ type, inverted }, theme);
98
+ const variant = useVariant(props);
99
+ const shape = useShape(props);
100
+ const buttonColors = getButtonColors({ variant, inverted }, theme);
70
101
  const iconStyles = {
71
- size: theme.t('SizeIconXs').number,
72
- color: getIconColor({ type, disabled, inverted }, theme),
102
+ size: 'Xs',
103
+ deprecatedColor: getIconColor({ variant, disabled, inverted }, theme),
73
104
  padding: theme.t('Padding2xsMobile').number,
74
105
  };
75
106
  const iconBackgroundStyles = {
76
- backgroundColor: getIconBackgroundColor({ type, disabled, inverted }, theme),
107
+ backgroundColor: getIconBackgroundColor({ variant, disabled, inverted }, theme),
77
108
  borderRadius: theme.t('RadiusPill').number,
78
109
  marginHorizontal: theme.t('SpacingXsMobile').number,
79
110
  };
80
111
  let adaptedPrefix = prefix && React.cloneElement(prefix, iconStyles);
81
112
  adaptedPrefix =
82
- prefix && type === 'tertiary' ? (React.createElement(View, { style: iconBackgroundStyles }, adaptedPrefix)) : (adaptedPrefix);
113
+ prefix && variant === 'tertiary' ? (React.createElement(View, { style: iconBackgroundStyles }, adaptedPrefix)) : (adaptedPrefix);
83
114
  let adaptedSuffix = suffix && React.cloneElement(suffix, iconStyles);
84
115
  adaptedSuffix =
85
- suffix && type === 'tertiary' ? (React.createElement(View, { style: iconBackgroundStyles }, adaptedSuffix)) : (adaptedSuffix);
116
+ suffix && variant === 'tertiary' ? (React.createElement(View, { style: iconBackgroundStyles }, adaptedSuffix)) : (adaptedSuffix);
86
117
  return (React.createElement(TouchableOpacity, { ...e2eID(testID), onPress: onPress, focusable: true, disabled: disabled, ...a11y({
87
118
  accessibilityRole: 'button',
88
119
  accessible: true,
@@ -98,22 +129,22 @@ export function PxButton({ title, wrapperStyle, titleStyle, isRoundedBottomCorne
98
129
  backgroundColor: buttonColors.backgroundColor,
99
130
  borderColor: buttonColors.borderColor,
100
131
  borderRadius: theme.t('RadiusButtonSmall').number,
101
- ...(isRoundedBottomCorner && {
132
+ ...(shape === 'default' && {
102
133
  borderBottomEndRadius: theme.t('RadiusButtonBig').number,
103
134
  }),
104
- paddingHorizontal: type === 'tertiary' ? 0 : theme.t('PaddingMMobile').number,
105
- paddingVertical: type === 'tertiary'
135
+ paddingHorizontal: variant === 'tertiary' ? 0 : theme.t('PaddingMMobile').number,
136
+ paddingVertical: variant === 'tertiary'
106
137
  ? theme.t('Padding2xsMobile').number
107
138
  : theme.t('PaddingXsMobile').number,
108
139
  gap: theme.t('Spacing2xsMobile').number,
109
- ...(type !== 'tertiary' && {
140
+ ...(variant !== 'tertiary' && {
110
141
  minHeight: theme.t('SpacingLMobile').number,
111
142
  }),
112
143
  },
113
144
  disabled && {
114
145
  backgroundColor: buttonColors.disabledBackgroundColor,
115
146
  },
116
- type === 'tertiary' && {
147
+ variant === 'tertiary' && {
117
148
  paddingVertical: 4,
118
149
  paddingHorizontal: 0,
119
150
  },
package/package.json CHANGED
@@ -1,46 +1,19 @@
1
1
  {
2
2
  "name": "@proximus/lavender-button-native",
3
- "version": "0.1.0-alpha.7",
3
+ "version": "0.1.0-beta.0",
4
4
  "description": "Button component",
5
5
  "license": "MIT",
6
- "main": "src/index.ts",
7
- "scripts": {
8
- "clean": "rm -rf dist",
9
- "transform-package-json": "node ../../../scripts/tranformPackageJson.js package.json dist/far/away",
10
- "prepublish": "yarn clean && yarn transform-package-json && 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": "workspace:*",
15
- "@proximus/lavender-icon-native": "workspace:*",
16
- "@proximus/lavender-styling-native": "workspace:*",
17
- "@proximus/lavender-texts-native": "workspace:*"
18
- },
19
- "devDependencies": {
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"
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
- {
33
- "from": "dist/far/away/package.json",
34
- "to": "."
35
- },
36
- "dist/*.js",
37
- "dist/*.d.ts",
38
- "dist/*.d.ts.map",
39
- "src",
40
- "package.json"
41
- ]
42
- }
43
- }
44
- },
45
- "gitHead": "e50a17526561b3eafb159e36c737173956093e0d"
18
+ }
46
19
  }
package/CHANGELOG.md DELETED
@@ -1,57 +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.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
-
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)
23
-
24
- **Note:** Version bump only for package @proximus/lavender-button-native
25
-
26
- # [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)
27
-
28
- ### Features
29
-
30
- - **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))
31
-
32
- # [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)
33
-
34
- ### Bug Fixes
35
-
36
- - **BCRI-4210372:** fix types field in modules ([68ac126](https://github.com/Pxs-Corporate/react-native-lavender/commit/68ac12657112473ae9e0e683076b1d9172be9ce6))
37
-
38
- # [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)
39
-
40
- ### Features
41
-
42
- - **BCRI-4210372:** automatic versionning ([9c1f0a0](https://github.com/Pxs-Corporate/react-native-lavender/commit/9c1f0a00e19a9d1a277044ea627632032a674102))
43
-
44
- # 0.1.0-alpha.0 (2025-08-12)
45
-
46
- ### Features
47
-
48
- - **BCRI-000000:** lerna setup ([1d24b00](https://github.com/Pxs-Corporate/react-native-lavender/commit/1d24b00a9ca917d873e9c497bfebf6a0cc570d13))
49
- - **BCRI-000000:** lerna setup ([f7fa837](https://github.com/Pxs-Corporate/react-native-lavender/commit/f7fa837fb15e0fd1ee838f99f421ff23a52c0403))
50
- - **BCRI-000000:** remove default E2E on DEV env build for all components ([a5d27bf](https://github.com/Pxs-Corporate/react-native-lavender/commit/a5d27bfaaebf5b75f3160f31c64b590b7bd00b93))
51
- - **BCRI-3619796:** top navigation bar ([0b2bcae](https://github.com/Pxs-Corporate/react-native-lavender/commit/0b2bcaee7243b9f00f88e2b2fb97d86cf0cf5b77))
52
- - **BCRI-3651606:** mono repo creation ([d19f852](https://github.com/Pxs-Corporate/react-native-lavender/commit/d19f852a710963ff85b1a9d31d18188217aa23ab))
53
- - **BCRI-3689585:** icon module ([f13230d](https://github.com/Pxs-Corporate/react-native-lavender/commit/f13230d9c7643680089a0db2c69b96cd73ff246e))
54
- - **BCRI-3702949:** tertiary button ([4999cea](https://github.com/Pxs-Corporate/react-native-lavender/commit/4999cea4d7866084d0f8c1cba37070c6cdaa7601))
55
- - **BCRI-3702949:** tertiary button ([db24455](https://github.com/Pxs-Corporate/react-native-lavender/commit/db24455bd9687d80920be3e42c9e1fc14703a571))
56
- - **BCRI-3749589:** button icon component ([62cfd94](https://github.com/Pxs-Corporate/react-native-lavender/commit/62cfd945420c26cf6da6dfb802cc998c613e9687))
57
- - **BCRI-3810979:** tile components ([46fc5c7](https://github.com/Pxs-Corporate/react-native-lavender/commit/46fc5c7a0ddff6c2db43fba0de9929626092f265))
@@ -1,34 +0,0 @@
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/src/PxButton.tsx DELETED
@@ -1,241 +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 { useTheme } from '@proximus/lavender-styling-native';
13
- import { Header } from '@proximus/lavender-texts-native';
14
-
15
- export type Variant = 'primary' | 'secondary' | 'tertiary';
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
- inverted?: boolean;
30
- }
31
-
32
- function getButtonColors(props: Partial<IProps>, theme: ITheme) {
33
- const { type, inverted = false } = props;
34
-
35
- const invertedSuffix = inverted ? 'Inverted' : 'Default';
36
-
37
- switch (type) {
38
- case 'secondary': {
39
- return {
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}`),
48
- };
49
- }
50
-
51
- case 'tertiary': {
52
- return {
53
- backgroundColor: 'transparent',
54
- disabledBackgroundColor: 'transparent',
55
- textColor: theme.t(`ColorTextBrand${invertedSuffix}`),
56
- disabledText: theme.t(`ColorTextStateDisabled${invertedSuffix}`),
57
- };
58
- }
59
-
60
- default: {
61
- return {
62
- backgroundColor: theme.t(
63
- `ColorBackgroundContainerPrimary${invertedSuffix}`
64
- ),
65
- textColor: inverted
66
- ? theme.t('ColorTextBrandDefault')
67
- : theme.t('ColorTextBrandInverted'),
68
- disabledBackgroundColor: theme.t(
69
- `ColorBackgroundStateDisabled${invertedSuffix}`
70
- ),
71
- disabledText: theme.t(`ColorTextStateDisabled${invertedSuffix}`),
72
- borderColor: theme.t('ColorBorderNone'),
73
- };
74
- }
75
- }
76
- }
77
-
78
- function getIconColor(props: Partial<IProps>, theme: ITheme) {
79
- const { type, disabled, inverted } = props;
80
-
81
- const invertedSuffix = inverted ? 'Inverted' : 'Default';
82
-
83
- switch (type) {
84
- case 'primary':
85
- return disabled
86
- ? theme.t(`ColorIconStateDisabled${invertedSuffix}`)
87
- : inverted
88
- ? theme.t('ColorIconBrandDefault')
89
- : theme.t('ColorIconBrandInverted');
90
- default:
91
- return disabled
92
- ? theme.t(`ColorIconStateDisabled${invertedSuffix}`)
93
- : theme.t(`ColorIconBrand${invertedSuffix}`);
94
- }
95
- }
96
-
97
- function getIconBackgroundColor(props: Partial<IProps>, theme: ITheme) {
98
- const { type, disabled, inverted } = props;
99
-
100
- const invertedSuffix = inverted ? 'Inverted' : 'Default';
101
-
102
- switch (type) {
103
- case 'tertiary':
104
- return disabled
105
- ? theme.t(`ColorBackgroundStateDisabled${invertedSuffix}`)
106
- : theme.t(`ColorBackgroundContainerSecondary${invertedSuffix}`);
107
- default:
108
- return undefined;
109
- }
110
- }
111
-
112
- export function PxButton({
113
- title,
114
- wrapperStyle,
115
- titleStyle,
116
- isRoundedBottomCorner = true,
117
- testID,
118
- disabled = false,
119
- prefix,
120
- suffix,
121
- onPress,
122
- type = 'primary',
123
- accessibilityLabel,
124
- accessibilityHint,
125
- inverted,
126
- }: IProps) {
127
- const { theme } = useTheme();
128
- const buttonColors = getButtonColors({ type, inverted }, theme);
129
-
130
- const iconStyles = {
131
- size: theme.t('SizeIconXs').number,
132
- color: getIconColor({ type, disabled, inverted }, theme),
133
- padding: theme.t('Padding2xsMobile').number,
134
- };
135
-
136
- const iconBackgroundStyles = {
137
- backgroundColor: getIconBackgroundColor(
138
- { type, disabled, inverted },
139
- theme
140
- ),
141
- borderRadius: theme.t('RadiusPill').number,
142
- marginHorizontal: theme.t('SpacingXsMobile').number,
143
- };
144
-
145
- let adaptedPrefix =
146
- prefix && React.cloneElement(prefix as ReactElement, iconStyles);
147
-
148
- adaptedPrefix =
149
- prefix && type === 'tertiary' ? (
150
- <View style={iconBackgroundStyles}>{adaptedPrefix}</View>
151
- ) : (
152
- adaptedPrefix
153
- );
154
-
155
- let adaptedSuffix =
156
- suffix && React.cloneElement(suffix as ReactElement, iconStyles);
157
-
158
- adaptedSuffix =
159
- suffix && type === 'tertiary' ? (
160
- <View style={iconBackgroundStyles}>{adaptedSuffix}</View>
161
- ) : (
162
- adaptedSuffix
163
- );
164
-
165
- return (
166
- <TouchableOpacity
167
- {...e2eID(testID)}
168
- onPress={onPress}
169
- focusable={true}
170
- disabled={disabled}
171
- {...a11y({
172
- accessibilityRole: 'button',
173
- accessible: true,
174
- accessibilityState: {
175
- disabled,
176
- },
177
- accessibilityLabel: accessibilityLabel || title,
178
- accessibilityHint,
179
- })}
180
- style={wrapperStyle}
181
- >
182
- <View
183
- style={[
184
- styles.button,
185
- {
186
- backgroundColor: buttonColors.backgroundColor,
187
- borderColor: buttonColors.borderColor,
188
- borderRadius: theme.t('RadiusButtonSmall').number,
189
- ...(isRoundedBottomCorner && {
190
- borderBottomEndRadius: theme.t('RadiusButtonBig').number,
191
- }),
192
- paddingHorizontal:
193
- type === 'tertiary' ? 0 : theme.t('PaddingMMobile').number,
194
- paddingVertical:
195
- type === 'tertiary'
196
- ? theme.t('Padding2xsMobile').number
197
- : theme.t('PaddingXsMobile').number,
198
- gap: theme.t('Spacing2xsMobile').number,
199
- ...(type !== 'tertiary' && {
200
- minHeight: theme.t('SpacingLMobile').number,
201
- }),
202
- },
203
- disabled && {
204
- backgroundColor: buttonColors.disabledBackgroundColor,
205
- },
206
- type === 'tertiary' && {
207
- paddingVertical: 4,
208
- paddingHorizontal: 0,
209
- },
210
- ]}
211
- >
212
- {adaptedPrefix}
213
- <Header
214
- style={[
215
- {
216
- color: buttonColors.textColor,
217
- },
218
- disabled && {
219
- color: buttonColors.disabledText,
220
- },
221
- {
222
- lineHeight: 21,
223
- },
224
- titleStyle,
225
- ]}
226
- >
227
- {title}
228
- </Header>
229
- {adaptedSuffix}
230
- </View>
231
- </TouchableOpacity>
232
- );
233
- }
234
-
235
- const styles = StyleSheet.create({
236
- button: {
237
- alignItems: 'center',
238
- flexDirection: 'row',
239
- justifyContent: 'center',
240
- },
241
- });
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './PxButton';
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.npm.json",
3
- "compilerOptions": {
4
- "outDir": "dist"
5
- },
6
- "include": ["src","../../../lib.d.ts"],
7
- "exclude": ["dist", "node_modules", "src/**/*.spec.tsx", "src/**/*.spec.ts"]
8
- }