@proximus/lavender-button-native 0.1.0-alpha.15 → 0.1.0-alpha.17

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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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}`),
@@ -37,9 +65,9 @@ function getButtonColors(props, theme) {
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
102
  size: 'Xs',
72
- color: getIconColor({ type, disabled, inverted }, theme),
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@proximus/lavender-button-native",
3
- "version": "0.1.0-alpha.15",
3
+ "version": "0.1.0-alpha.17",
4
4
  "description": "Button component",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",