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

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,7 +8,9 @@ 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;
12
14
  isRoundedBottomCorner?: boolean;
13
15
  theme?: ITheme;
14
16
  disabled?: boolean;
@@ -17,5 +19,5 @@ export interface IProps extends AccessibilityProps {
17
19
  suffix?: ReactNode;
18
20
  inverted?: boolean;
19
21
  }
20
- export declare function PxButton({ title, wrapperStyle, titleStyle, isRoundedBottomCorner, testID, disabled, prefix, suffix, onPress, type, accessibilityLabel, accessibilityHint, inverted, }: IProps): React.JSX.Element;
22
+ export declare function PxButton(props: IProps): React.JSX.Element;
21
23
  //# 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,OAA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IAClB,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;AAgGD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,qBA0HrC"}
package/dist/PxButton.js CHANGED
@@ -3,10 +3,24 @@ 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
+ * @param props
9
+ */
10
+ function useVariant(props) {
11
+ const { variant, type } = props;
12
+ if (type && !variant) {
13
+ return type;
14
+ }
15
+ else if (!variant) {
16
+ return 'primary';
17
+ }
18
+ return variant;
19
+ }
6
20
  function getButtonColors(props, theme) {
7
- const { type, inverted = false } = props;
21
+ const { variant, inverted = false } = props;
8
22
  const invertedSuffix = inverted ? 'Inverted' : 'Default';
9
- switch (type) {
23
+ switch (variant) {
10
24
  case 'secondary': {
11
25
  return {
12
26
  backgroundColor: theme.t(`ColorBackgroundContainerSecondary${invertedSuffix}`),
@@ -37,9 +51,9 @@ function getButtonColors(props, theme) {
37
51
  }
38
52
  }
39
53
  function getIconColor(props, theme) {
40
- const { type, disabled, inverted } = props;
54
+ const { variant, disabled, inverted } = props;
41
55
  const invertedSuffix = inverted ? 'Inverted' : 'Default';
42
- switch (type) {
56
+ switch (variant) {
43
57
  case 'primary':
44
58
  return disabled
45
59
  ? theme.t(`ColorIconStateDisabled${invertedSuffix}`)
@@ -53,9 +67,9 @@ function getIconColor(props, theme) {
53
67
  }
54
68
  }
55
69
  function getIconBackgroundColor(props, theme) {
56
- const { type, disabled, inverted } = props;
70
+ const { variant, disabled, inverted } = props;
57
71
  const invertedSuffix = inverted ? 'Inverted' : 'Default';
58
- switch (type) {
72
+ switch (variant) {
59
73
  case 'tertiary':
60
74
  return disabled
61
75
  ? theme.t(`ColorBackgroundStateDisabled${invertedSuffix}`)
@@ -64,25 +78,27 @@ function getIconBackgroundColor(props, theme) {
64
78
  return undefined;
65
79
  }
66
80
  }
67
- export function PxButton({ title, wrapperStyle, titleStyle, isRoundedBottomCorner = true, testID, disabled = false, prefix, suffix, onPress, type = 'primary', accessibilityLabel, accessibilityHint, inverted, }) {
81
+ export function PxButton(props) {
82
+ const { title, wrapperStyle, titleStyle, isRoundedBottomCorner = true, testID, disabled = false, prefix, suffix, onPress, accessibilityLabel, accessibilityHint, inverted, } = props;
68
83
  const { theme } = useTheme();
69
- const buttonColors = getButtonColors({ type, inverted }, theme);
84
+ const variant = useVariant(props);
85
+ const buttonColors = getButtonColors({ variant, inverted }, theme);
70
86
  const iconStyles = {
71
87
  size: 'Xs',
72
- color: getIconColor({ type, disabled, inverted }, theme),
88
+ deprecatedColor: getIconColor({ variant, disabled, inverted }, theme),
73
89
  padding: theme.t('Padding2xsMobile').number,
74
90
  };
75
91
  const iconBackgroundStyles = {
76
- backgroundColor: getIconBackgroundColor({ type, disabled, inverted }, theme),
92
+ backgroundColor: getIconBackgroundColor({ variant, disabled, inverted }, theme),
77
93
  borderRadius: theme.t('RadiusPill').number,
78
94
  marginHorizontal: theme.t('SpacingXsMobile').number,
79
95
  };
80
96
  let adaptedPrefix = prefix && React.cloneElement(prefix, iconStyles);
81
97
  adaptedPrefix =
82
- prefix && type === 'tertiary' ? (React.createElement(View, { style: iconBackgroundStyles }, adaptedPrefix)) : (adaptedPrefix);
98
+ prefix && variant === 'tertiary' ? (React.createElement(View, { style: iconBackgroundStyles }, adaptedPrefix)) : (adaptedPrefix);
83
99
  let adaptedSuffix = suffix && React.cloneElement(suffix, iconStyles);
84
100
  adaptedSuffix =
85
- suffix && type === 'tertiary' ? (React.createElement(View, { style: iconBackgroundStyles }, adaptedSuffix)) : (adaptedSuffix);
101
+ suffix && variant === 'tertiary' ? (React.createElement(View, { style: iconBackgroundStyles }, adaptedSuffix)) : (adaptedSuffix);
86
102
  return (React.createElement(TouchableOpacity, { ...e2eID(testID), onPress: onPress, focusable: true, disabled: disabled, ...a11y({
87
103
  accessibilityRole: 'button',
88
104
  accessible: true,
@@ -101,19 +117,19 @@ export function PxButton({ title, wrapperStyle, titleStyle, isRoundedBottomCorne
101
117
  ...(isRoundedBottomCorner && {
102
118
  borderBottomEndRadius: theme.t('RadiusButtonBig').number,
103
119
  }),
104
- paddingHorizontal: type === 'tertiary' ? 0 : theme.t('PaddingMMobile').number,
105
- paddingVertical: type === 'tertiary'
120
+ paddingHorizontal: variant === 'tertiary' ? 0 : theme.t('PaddingMMobile').number,
121
+ paddingVertical: variant === 'tertiary'
106
122
  ? theme.t('Padding2xsMobile').number
107
123
  : theme.t('PaddingXsMobile').number,
108
124
  gap: theme.t('Spacing2xsMobile').number,
109
- ...(type !== 'tertiary' && {
125
+ ...(variant !== 'tertiary' && {
110
126
  minHeight: theme.t('SpacingLMobile').number,
111
127
  }),
112
128
  },
113
129
  disabled && {
114
130
  backgroundColor: buttonColors.disabledBackgroundColor,
115
131
  },
116
- type === 'tertiary' && {
132
+ variant === 'tertiary' && {
117
133
  paddingVertical: 4,
118
134
  paddingHorizontal: 0,
119
135
  },
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.16",
4
4
  "description": "Button component",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",