@hero-design/rn 8.80.1 → 8.81.1
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.
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +12 -0
- package/es/index.js +71 -24
- package/lib/index.js +71 -24
- package/package.json +3 -2
- package/src/components/Button/Button.tsx +13 -5
- package/src/components/Button/StyledButton.tsx +60 -39
- package/src/components/Button/__tests__/Button.spec.tsx +21 -16
- package/src/components/Button/__tests__/StyledButton.spec.tsx +19 -12
- package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +670 -0
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +153 -0
- package/src/components/Chip/StyledChip.tsx +6 -1
- package/src/components/Chip/__tests__/__snapshots__/index.spec.tsx.snap +117 -60
- package/src/components/Chip/__tests__/index.spec.tsx +13 -0
- package/src/components/Chip/index.tsx +20 -12
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +1 -0
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +5 -0
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +1 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +8 -0
- package/src/theme/components/button.ts +5 -0
- package/src/theme/components/chip.ts +5 -0
- package/stats/8.81.0/rn-stats.html +4842 -0
- package/stats/8.81.1/rn-stats.html +4842 -0
- package/types/components/Button/Button.d.ts +1 -1
- package/types/components/Button/StyledButton.d.ts +3 -0
- package/types/components/Chip/StyledChip.d.ts +5 -1
- package/types/components/Chip/index.d.ts +2 -2
- package/types/theme/components/button.d.ts +5 -0
- package/types/theme/components/chip.d.ts +3 -0
|
@@ -82,7 +82,8 @@ const genOutlineContainerStyles = (
|
|
|
82
82
|
const genTextStyles = (
|
|
83
83
|
theme: Theme,
|
|
84
84
|
intent: Intent,
|
|
85
|
-
disabled?: boolean
|
|
85
|
+
disabled?: boolean,
|
|
86
|
+
isPressed?: boolean
|
|
86
87
|
): ReactNativeStyle => {
|
|
87
88
|
if (disabled) {
|
|
88
89
|
return {
|
|
@@ -90,6 +91,12 @@ const genTextStyles = (
|
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
if (isPressed) {
|
|
95
|
+
return {
|
|
96
|
+
color: theme.__hd__.button.colors.pressedText[intent],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
93
100
|
return { color: theme.__hd__.button.colors[intent] };
|
|
94
101
|
};
|
|
95
102
|
|
|
@@ -97,37 +104,49 @@ const StyledButtonContainer = styled(TouchableHighlight)<{
|
|
|
97
104
|
disabled?: boolean;
|
|
98
105
|
themeButtonVariant: ThemeVariant;
|
|
99
106
|
loading?: boolean;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
?
|
|
127
|
-
:
|
|
128
|
-
|
|
107
|
+
themeInlineText?: boolean;
|
|
108
|
+
}>(
|
|
109
|
+
({
|
|
110
|
+
disabled = false,
|
|
111
|
+
loading = false,
|
|
112
|
+
themeButtonVariant,
|
|
113
|
+
themeInlineText,
|
|
114
|
+
theme,
|
|
115
|
+
}) => {
|
|
116
|
+
switch (themeButtonVariant) {
|
|
117
|
+
case 'filled-primary':
|
|
118
|
+
return genFilledContainerStyles(theme, 'primary', disabled, loading);
|
|
119
|
+
case 'filled-secondary':
|
|
120
|
+
return genFilledContainerStyles(theme, 'secondary', disabled, loading);
|
|
121
|
+
case 'filled-danger':
|
|
122
|
+
return genFilledContainerStyles(theme, 'danger', disabled, loading);
|
|
123
|
+
case 'outlined-primary':
|
|
124
|
+
return genOutlineContainerStyles(theme, 'primary', disabled, loading);
|
|
125
|
+
case 'outlined-secondary':
|
|
126
|
+
return genOutlineContainerStyles(theme, 'secondary', disabled, loading);
|
|
127
|
+
case 'outlined-danger':
|
|
128
|
+
return genOutlineContainerStyles(theme, 'danger', disabled, loading);
|
|
129
|
+
case 'text-primary':
|
|
130
|
+
case 'text-secondary':
|
|
131
|
+
case 'text-danger':
|
|
132
|
+
return {
|
|
133
|
+
height: themeInlineText ? undefined : scale(60),
|
|
134
|
+
borderRadius: theme.__hd__.button.radii.text,
|
|
135
|
+
flexDirection: 'row',
|
|
136
|
+
justifyContent: 'center',
|
|
137
|
+
alignItems: 'center',
|
|
138
|
+
padding: themeInlineText
|
|
139
|
+
? 0
|
|
140
|
+
: theme.__hd__.button.space.textButtonPadding,
|
|
141
|
+
borderWidth: 0,
|
|
142
|
+
backgroundColor:
|
|
143
|
+
loading && !themeInlineText
|
|
144
|
+
? theme.__hd__.button.colors.textLoadingBackground
|
|
145
|
+
: 'transparent',
|
|
146
|
+
};
|
|
147
|
+
}
|
|
129
148
|
}
|
|
130
|
-
|
|
149
|
+
);
|
|
131
150
|
|
|
132
151
|
const StyledButtonText = styled(Typography.Title)<{
|
|
133
152
|
disabled?: boolean;
|
|
@@ -165,15 +184,16 @@ const StyledButtonText = styled(Typography.Title)<{
|
|
|
165
184
|
const StyledButtonTitleOfVariantText = styled(Typography.Body)<{
|
|
166
185
|
disabled?: boolean;
|
|
167
186
|
themeButtonVariant: 'text-primary' | 'text-secondary' | 'text-danger';
|
|
168
|
-
|
|
187
|
+
themeIsPressed?: boolean;
|
|
188
|
+
}>(({ disabled, themeButtonVariant, themeIsPressed, theme }) => {
|
|
169
189
|
const themeStyling = () => {
|
|
170
190
|
switch (themeButtonVariant) {
|
|
171
191
|
case 'text-primary':
|
|
172
|
-
return genTextStyles(theme, 'primary', disabled);
|
|
192
|
+
return genTextStyles(theme, 'primary', disabled, themeIsPressed);
|
|
173
193
|
case 'text-secondary':
|
|
174
|
-
return genTextStyles(theme, 'secondary', disabled);
|
|
194
|
+
return genTextStyles(theme, 'secondary', disabled, themeIsPressed);
|
|
175
195
|
case 'text-danger':
|
|
176
|
-
return genTextStyles(theme, 'danger', disabled);
|
|
196
|
+
return genTextStyles(theme, 'danger', disabled, themeIsPressed);
|
|
177
197
|
}
|
|
178
198
|
};
|
|
179
199
|
return {
|
|
@@ -198,7 +218,8 @@ const StyledButtonIconWrapper = styled(View)<{
|
|
|
198
218
|
const StyledButtonIcon = styled(Icon)<{
|
|
199
219
|
disabled?: boolean;
|
|
200
220
|
themeButtonVariant: ThemeVariant;
|
|
201
|
-
|
|
221
|
+
themeIsPressed?: boolean;
|
|
222
|
+
}>(({ disabled, themeButtonVariant, themeIsPressed, theme }) => {
|
|
202
223
|
const themeStyling = () => {
|
|
203
224
|
switch (themeButtonVariant) {
|
|
204
225
|
case 'filled-primary':
|
|
@@ -212,11 +233,11 @@ const StyledButtonIcon = styled(Icon)<{
|
|
|
212
233
|
case 'outlined-danger':
|
|
213
234
|
return genTextStyles(theme, 'danger', disabled);
|
|
214
235
|
case 'text-primary':
|
|
215
|
-
return genTextStyles(theme, 'primary', disabled);
|
|
236
|
+
return genTextStyles(theme, 'primary', disabled, themeIsPressed);
|
|
216
237
|
case 'text-secondary':
|
|
217
|
-
return genTextStyles(theme, 'secondary', disabled);
|
|
238
|
+
return genTextStyles(theme, 'secondary', disabled, themeIsPressed);
|
|
218
239
|
case 'text-danger':
|
|
219
|
-
return genTextStyles(theme, 'danger', disabled);
|
|
240
|
+
return genTextStyles(theme, 'danger', disabled, themeIsPressed);
|
|
220
241
|
}
|
|
221
242
|
};
|
|
222
243
|
|
|
@@ -108,22 +108,27 @@ describe('Button', () => {
|
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
it.each`
|
|
111
|
-
variant
|
|
112
|
-
${'filled'}
|
|
113
|
-
${'filled'}
|
|
114
|
-
${'filled'}
|
|
115
|
-
${'outlined'}
|
|
116
|
-
${'outlined'}
|
|
117
|
-
${'outlined'}
|
|
118
|
-
${'text'}
|
|
119
|
-
${'text'}
|
|
120
|
-
${'text'}
|
|
121
|
-
${'text'}
|
|
122
|
-
${'text'}
|
|
123
|
-
${'text'}
|
|
124
|
-
${'text'}
|
|
125
|
-
${'text'}
|
|
126
|
-
${'text'}
|
|
111
|
+
variant | intent | loading | disabled
|
|
112
|
+
${'filled'} | ${'primary'} | ${false} | ${false}
|
|
113
|
+
${'filled'} | ${'primary'} | ${true} | ${false}
|
|
114
|
+
${'filled'} | ${'primary'} | ${false} | ${true}
|
|
115
|
+
${'outlined'} | ${'primary'} | ${false} | ${false}
|
|
116
|
+
${'outlined'} | ${'primary'} | ${true} | ${false}
|
|
117
|
+
${'outlined'} | ${'primary'} | ${false} | ${true}
|
|
118
|
+
${'text'} | ${'primary'} | ${false} | ${false}
|
|
119
|
+
${'text'} | ${'primary'} | ${true} | ${false}
|
|
120
|
+
${'text'} | ${'primary'} | ${false} | ${true}
|
|
121
|
+
${'text'} | ${'secondary'} | ${false} | ${false}
|
|
122
|
+
${'text'} | ${'secondary'} | ${true} | ${false}
|
|
123
|
+
${'text'} | ${'secondary'} | ${false} | ${true}
|
|
124
|
+
${'text'} | ${'danger'} | ${false} | ${false}
|
|
125
|
+
${'text'} | ${'danger'} | ${true} | ${false}
|
|
126
|
+
${'text'} | ${'danger'} | ${false} | ${true}
|
|
127
|
+
${'inline-text'} | ${'primary'} | ${false} | ${false}
|
|
128
|
+
${'inline-text'} | ${'secondary'} | ${true} | ${false}
|
|
129
|
+
${'inline-text'} | ${'danger'} | ${false} | ${false}
|
|
130
|
+
${'inline-text'} | ${'primary'} | ${true} | ${false}
|
|
131
|
+
${'inline-text'} | ${'primary'} | ${false} | ${true}
|
|
127
132
|
`('renders correctly', ({ variant, intent, loading, disabled }) => {
|
|
128
133
|
const { toJSON } = renderWithTheme(
|
|
129
134
|
<Button
|
|
@@ -92,19 +92,26 @@ describe('StyledButtonIconWrapper', () => {
|
|
|
92
92
|
|
|
93
93
|
describe('StyledButtonIcon', () => {
|
|
94
94
|
it.each`
|
|
95
|
-
themeVariant
|
|
96
|
-
${'filled-primary'}
|
|
97
|
-
${'filled-secondary'}
|
|
98
|
-
${'filled-danger'}
|
|
99
|
-
${'outlined-primary'}
|
|
100
|
-
${'outlined-secondary'}
|
|
101
|
-
${'outlined-danger'}
|
|
102
|
-
${'text-primary'}
|
|
103
|
-
${'text-secondary'}
|
|
104
|
-
${'text-danger'}
|
|
105
|
-
|
|
95
|
+
themeVariant | themeIsPressed
|
|
96
|
+
${'filled-primary'} | ${undefined}
|
|
97
|
+
${'filled-secondary'} | ${undefined}
|
|
98
|
+
${'filled-danger'} | ${undefined}
|
|
99
|
+
${'outlined-primary'} | ${undefined}
|
|
100
|
+
${'outlined-secondary'} | ${undefined}
|
|
101
|
+
${'outlined-danger'} | ${undefined}
|
|
102
|
+
${'text-primary'} | ${false}
|
|
103
|
+
${'text-secondary'} | ${false}
|
|
104
|
+
${'text-danger'} | ${false}
|
|
105
|
+
${'text-primary'} | ${true}
|
|
106
|
+
${'text-secondary'} | ${true}
|
|
107
|
+
${'text-danger'} | ${true}
|
|
108
|
+
`('has $themeVariant style', ({ themeVariant, themeIsPressed }) => {
|
|
106
109
|
const { toJSON } = renderWithTheme(
|
|
107
|
-
<StyledButtonIcon
|
|
110
|
+
<StyledButtonIcon
|
|
111
|
+
icon="bell"
|
|
112
|
+
themeButtonVariant={themeVariant}
|
|
113
|
+
themeIsPressed={themeIsPressed}
|
|
114
|
+
/>
|
|
108
115
|
);
|
|
109
116
|
|
|
110
117
|
expect(toJSON()).toMatchSnapshot();
|