@hero-design/rn 8.12.1 → 8.12.2

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.
Files changed (30) hide show
  1. package/.turbo/turbo-build.log +9 -9
  2. package/es/index.js +79 -25
  3. package/lib/index.js +78 -24
  4. package/package.json +5 -5
  5. package/src/components/Button/Button.tsx +42 -2
  6. package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +1 -1
  7. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +1 -1
  8. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +3 -3
  9. package/src/components/Button/StyledButton.tsx +21 -14
  10. package/src/components/Button/__tests__/Button.spec.tsx +46 -1
  11. package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +1564 -0
  12. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +126 -110
  13. package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +24 -22
  14. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +12 -9
  15. package/src/components/FAB/ActionGroup/ActionItem.tsx +17 -6
  16. package/src/components/FAB/ActionGroup/StyledActionItem.tsx +15 -17
  17. package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +170 -160
  18. package/src/components/FAB/FAB.tsx +3 -1
  19. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +36 -27
  20. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +12 -9
  21. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +17 -0
  22. package/src/theme/components/button.ts +16 -2
  23. package/src/theme/components/fab.ts +2 -0
  24. package/src/theme/global/borders.ts +2 -0
  25. package/types/components/Button/Button.d.ts +1 -1
  26. package/types/components/Button/StyledButton.d.ts +4 -3
  27. package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +3 -3
  28. package/types/theme/components/button.d.ts +14 -0
  29. package/types/theme/components/fab.d.ts +2 -0
  30. package/types/theme/global/borders.d.ts +1 -0
@@ -1,4 +1,4 @@
1
- import { TouchableOpacity, View } from 'react-native';
1
+ import { TouchableHighlight, View } from 'react-native';
2
2
  import styled from '@emotion/native';
3
3
  import type { ReactNativeStyle } from '@emotion/native';
4
4
  import type { Theme } from '@emotion/react';
@@ -21,10 +21,11 @@ type ThemeVariant =
21
21
  const genFilledContainerStyles = (
22
22
  theme: Theme,
23
23
  intent: Intent,
24
- disabled: boolean
24
+ disabled: boolean,
25
+ loading: boolean
25
26
  ): ReactNativeStyle => {
26
27
  const backgroundColorStyling = () => {
27
- if (disabled) {
28
+ if (!loading && disabled) {
28
29
  return {
29
30
  backgroundColor: theme.__hd__.button.colors.disabledBorder,
30
31
  };
@@ -47,10 +48,11 @@ const genFilledContainerStyles = (
47
48
  const genOutlineContainerStyles = (
48
49
  theme: Theme,
49
50
  intent: Intent,
50
- disabled: boolean
51
+ disabled: boolean,
52
+ loading: boolean
51
53
  ): ReactNativeStyle => {
52
54
  const borderColorStyling = () => {
53
- if (disabled) {
55
+ if (!loading && disabled) {
54
56
  return {
55
57
  borderColor: theme.__hd__.button.colors.disabledBorder,
56
58
  };
@@ -118,32 +120,37 @@ const genTextVariantTextStyles = (
118
120
  };
119
121
  };
120
122
 
121
- const StyledButtonContainer = styled(TouchableOpacity)<{
123
+ const StyledButtonContainer = styled(TouchableHighlight)<{
122
124
  disabled?: boolean;
123
125
  themeVariant: ThemeVariant;
124
- }>(({ disabled = false, themeVariant, theme }) => {
126
+ loading?: boolean;
127
+ }>(({ disabled = false, loading = false, themeVariant, theme }) => {
125
128
  switch (themeVariant) {
126
129
  case 'filled-primary':
127
- return genFilledContainerStyles(theme, 'primary', disabled);
130
+ return genFilledContainerStyles(theme, 'primary', disabled, loading);
128
131
  case 'filled-secondary':
129
- return genFilledContainerStyles(theme, 'secondary', disabled);
132
+ return genFilledContainerStyles(theme, 'secondary', disabled, loading);
130
133
  case 'filled-danger':
131
- return genFilledContainerStyles(theme, 'danger', disabled);
134
+ return genFilledContainerStyles(theme, 'danger', disabled, loading);
132
135
  case 'outlined-primary':
133
- return genOutlineContainerStyles(theme, 'primary', disabled);
136
+ return genOutlineContainerStyles(theme, 'primary', disabled, loading);
134
137
  case 'outlined-secondary':
135
- return genOutlineContainerStyles(theme, 'secondary', disabled);
138
+ return genOutlineContainerStyles(theme, 'secondary', disabled, loading);
136
139
  case 'outlined-danger':
137
- return genOutlineContainerStyles(theme, 'danger', disabled);
140
+ return genOutlineContainerStyles(theme, 'danger', disabled, loading);
138
141
  case 'text-primary':
139
142
  case 'text-secondary':
140
143
  case 'text-danger':
141
144
  return {
145
+ borderRadius: theme.__hd__.button.radii.text,
142
146
  flexDirection: 'row',
143
147
  justifyContent: 'center',
144
148
  alignItems: 'center',
145
- padding: theme.__hd__.button.space.buttonPadding,
149
+ padding: theme.__hd__.button.space.textButtonPadding,
146
150
  borderWidth: 0,
151
+ backgroundColor: loading
152
+ ? theme.__hd__.button.colors.textLoadingBackground
153
+ : 'transparent',
147
154
  };
148
155
  }
149
156
  });
@@ -46,9 +46,11 @@ describe('Button', () => {
46
46
  });
47
47
 
48
48
  it('renders loading icon', () => {
49
- const { getByTestId } = renderWithTheme(
49
+ const { getByTestId, toJSON } = renderWithTheme(
50
50
  <Button text="A button" testID="button" onPress={jest.fn()} loading />
51
51
  );
52
+
53
+ expect(toJSON()).toMatchSnapshot();
52
54
  expect(getByTestId('button-loading-indicator')).toBeDefined();
53
55
  });
54
56
 
@@ -64,6 +66,17 @@ describe('Button', () => {
64
66
  });
65
67
  });
66
68
 
69
+ describe('button is loading', () => {
70
+ it('NOT allows to click on', () => {
71
+ const onPress = jest.fn();
72
+ const { getByTestId } = renderWithTheme(
73
+ <Button text="A button" testID="button" loading onPress={onPress} />
74
+ );
75
+ fireEvent.press(getByTestId('button-loading-indicator'));
76
+ expect(onPress).not.toHaveBeenCalled();
77
+ });
78
+ });
79
+
67
80
  describe('button is enabled', () => {
68
81
  it('allows to click on', () => {
69
82
  const onPress = jest.fn();
@@ -75,6 +88,38 @@ describe('Button', () => {
75
88
  });
76
89
  });
77
90
  });
91
+
92
+ it.each`
93
+ variant | intent | loading | disabled
94
+ ${'filled'} | ${'primary'} | ${false} | ${false}
95
+ ${'filled'} | ${'primary'} | ${true} | ${false}
96
+ ${'filled'} | ${'primary'} | ${false} | ${true}
97
+ ${'outlined'} | ${'primary'} | ${false} | ${false}
98
+ ${'outlined'} | ${'primary'} | ${true} | ${false}
99
+ ${'outlined'} | ${'primary'} | ${false} | ${true}
100
+ ${'text'} | ${'primary'} | ${false} | ${false}
101
+ ${'text'} | ${'primary'} | ${true} | ${false}
102
+ ${'text'} | ${'primary'} | ${false} | ${true}
103
+ ${'text'} | ${'secondary'} | ${false} | ${false}
104
+ ${'text'} | ${'secondary'} | ${true} | ${false}
105
+ ${'text'} | ${'secondary'} | ${false} | ${true}
106
+ ${'text'} | ${'danger'} | ${false} | ${false}
107
+ ${'text'} | ${'danger'} | ${true} | ${false}
108
+ ${'text'} | ${'danger'} | ${false} | ${true}
109
+ `('renders correctly', ({ variant, intent, loading, disabled }) => {
110
+ const { toJSON } = renderWithTheme(
111
+ <Button
112
+ text="A button"
113
+ variant={variant}
114
+ intent={intent}
115
+ loading={loading}
116
+ disabled={disabled}
117
+ onPress={jest.fn()}
118
+ />
119
+ );
120
+
121
+ expect(toJSON()).toMatchSnapshot();
122
+ });
78
123
  });
79
124
 
80
125
  describe('getThemeVariant', () => {