@hero-design/rn 8.33.1 → 8.34.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.
- package/.turbo/turbo-build.log +1 -1
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +868 -655
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +871 -656
- package/package.json +8 -7
- package/rollup.config.js +1 -0
- package/src/components/Accordion/AccordionItem.tsx +1 -3
- package/src/components/Accordion/__tests__/AccordionItem.spec.tsx +5 -5
- package/src/components/Accordion/__tests__/__snapshots__/AccordionItem.spec.tsx.snap +26 -34
- package/src/components/Accordion/__tests__/__snapshots__/index.spec.tsx.snap +36 -48
- package/src/components/Accordion/__tests__/index.spec.tsx +2 -2
- package/src/components/Alert/__tests__/__snapshots__/index.spec.tsx.snap +26 -39
- package/src/components/Alert/__tests__/index.spec.tsx +8 -2
- package/src/components/Alert/index.tsx +2 -2
- package/src/components/Attachment/__tests__/__snapshots__/index.spec.tsx.snap +2 -3
- package/src/components/Attachment/index.tsx +3 -1
- package/src/components/Badge/StyledBadge.tsx +1 -4
- package/src/components/Badge/__tests__/Status.spec.tsx +1 -1
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +18 -48
- package/src/components/Badge/__tests__/__snapshots__/Status.spec.tsx.snap +2 -3
- package/src/components/BottomNavigation/StyledBottomNavigation.tsx +1 -1
- package/src/components/BottomNavigation/__tests__/__snapshots__/index.spec.tsx.snap +4 -12
- package/src/components/BottomNavigation/index.tsx +0 -1
- package/src/components/BottomSheet/Header.tsx +1 -3
- package/src/components/BottomSheet/__tests__/__snapshots__/index.spec.tsx.snap +2 -3
- package/src/components/Button/Button.tsx +34 -11
- package/src/components/Button/StyledButton.tsx +45 -38
- package/src/components/Button/UtilityButton/StyledUtilityButton.tsx +2 -4
- package/src/components/Button/UtilityButton/__tests__/__snapshots__/index.spec.tsx.snap +8 -14
- package/src/components/Button/__tests__/StyledButton.spec.tsx +12 -6
- package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +66 -90
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +56 -86
- package/src/components/Calendar/CalendarRowItem.tsx +5 -2
- package/src/components/Calendar/__tests__/__snapshots__/CalendarRowItem.spec.tsx.snap +10 -15
- package/src/components/Calendar/index.tsx +1 -1
- package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +12 -18
- package/src/components/Card/__tests__/index.spec.tsx +1 -1
- package/src/components/Carousel/CardCarousel.tsx +2 -0
- package/src/components/Carousel/CarouselItem.tsx +4 -4
- package/src/components/Carousel/StyledCarousel.tsx +1 -4
- package/src/components/Carousel/__tests__/CardCarousel.spec.tsx +18 -18
- package/src/components/Carousel/__tests__/__snapshots__/CardCarousel.spec.tsx.snap +24 -20
- package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +99 -165
- package/src/components/Checkbox/StyledCheckbox.tsx +1 -1
- package/src/components/Checkbox/__tests__/__snapshots__/index.spec.tsx.snap +8 -12
- package/src/components/Checkbox/index.tsx +1 -1
- package/src/components/ContentNavigator/StyledContentNavigator.tsx +1 -6
- package/src/components/ContentNavigator/__tests__/StyledContentNavigator.spec.tsx +1 -9
- package/src/components/ContentNavigator/__tests__/__snapshots__/StyledContentNavigator.spec.tsx.snap +0 -29
- package/src/components/ContentNavigator/__tests__/__snapshots__/index.spec.tsx.snap +124 -17
- package/src/components/ContentNavigator/__tests__/index.spec.tsx +16 -0
- package/src/components/ContentNavigator/index.tsx +30 -9
- package/src/components/DatePicker/__tests__/__snapshots__/DatePicker.spec.tsx.snap +12 -18
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerAndroid.spec.tsx.snap +4 -6
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerCalendar.spec.tsx.snap +4 -6
- package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +13 -18
- package/src/components/Empty/StyledEmpty.tsx +2 -6
- package/src/components/Empty/__tests__/__snapshots__/index.spec.tsx.snap +22 -36
- package/src/components/Empty/index.tsx +4 -2
- package/src/components/Error/StyledError.tsx +2 -8
- package/src/components/Error/__tests__/__snapshots__/index.spec.tsx.snap +44 -76
- package/src/components/Error/index.tsx +6 -2
- package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +1 -4
- package/src/components/FAB/ActionGroup/StyledActionItem.tsx +1 -5
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +54 -116
- package/src/components/FAB/ActionGroup/index.tsx +1 -1
- package/src/components/FAB/StyledFAB.tsx +1 -4
- package/src/components/FAB/__tests__/StyledFAB.spec.tsx +1 -1
- package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +2 -3
- package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +4 -8
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/IconList.ts +2 -0
- package/src/components/List/BasicListItem.tsx +2 -6
- package/src/components/List/ListItem.tsx +3 -5
- package/src/components/List/__tests__/ListItem.spec.tsx +4 -4
- package/src/components/List/__tests__/StyledBasicListItem.spec.tsx +3 -1
- package/src/components/List/__tests__/StyledListItem.spec.tsx +3 -1
- package/src/components/List/__tests__/__snapshots__/BasicListItem.spec.tsx.snap +4 -10
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +23 -37
- package/src/components/List/__tests__/__snapshots__/StyledBasicListItem.spec.tsx.snap +8 -12
- package/src/components/List/__tests__/__snapshots__/StyledListItem.spec.tsx.snap +8 -12
- package/src/components/Modal/ModalContentWrapper.tsx +112 -0
- package/src/components/Modal/ModalPresenter/ModalPresenter.tsx +135 -0
- package/src/components/Modal/ModalPresenter/index.tsx +9 -0
- package/src/components/Modal/ModalProvider.tsx +8 -0
- package/src/components/Modal/__tests__/ModalContentWrapper.spec.tsx +25 -0
- package/src/components/Modal/__tests__/ModalPresenter.spec.tsx +57 -0
- package/src/components/Modal/__tests__/__snapshots__/ModalContentWrapper.spec.tsx.snap +35 -0
- package/src/components/Modal/__tests__/__snapshots__/ModalPresenter.spec.tsx.snap +55 -0
- package/src/components/Modal/__tests__/index.spec.tsx +50 -0
- package/src/components/Modal/index.tsx +121 -0
- package/src/components/PageControl/index.tsx +0 -1
- package/src/components/PinInput/PinCell.tsx +3 -1
- package/src/components/PinInput/StyledPinInput.tsx +2 -7
- package/src/components/PinInput/__tests__/__snapshots__/PinCell.spec.tsx.snap +25 -45
- package/src/components/PinInput/__tests__/__snapshots__/index.spec.tsx.snap +18 -34
- package/src/components/PinInput/index.tsx +2 -0
- package/src/components/Progress/ProgressCircle.tsx +1 -3
- package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +3 -6
- package/src/components/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +2 -4
- package/src/components/Radio/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +3 -6
- package/src/components/RichTextEditor/RichTextEditor.tsx +7 -11
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +16 -24
- package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +2 -3
- package/src/components/SectionHeading/__tests__/index.spec.tsx +3 -1
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/Option.spec.tsx.snap +1 -2
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +12 -24
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +86 -130
- package/src/components/Select/MultiSelect/__tests__/index.spec.tsx +6 -10
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/Option.spec.tsx.snap +1 -2
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +12 -24
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +49 -79
- package/src/components/Select/SingleSelect/__tests__/index.spec.tsx +5 -9
- package/src/components/Success/StyledSuccess.tsx +2 -6
- package/src/components/Success/__tests__/__snapshots__/index.spec.tsx.snap +40 -64
- package/src/components/Success/index.tsx +3 -1
- package/src/components/Swipeable/__tests__/SwipeableAction.spec.tsx +2 -2
- package/src/components/Swipeable/__tests__/__snapshots__/SwipeableAction.spec.tsx.snap +6 -9
- package/src/components/Swipeable/__tests__/__snapshots__/index.spec.tsx.snap +2 -3
- package/src/components/Swipeable/__tests__/index.spec.tsx +6 -4
- package/src/components/Switch/SelectorSwitch/Option.tsx +1 -1
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/Option.spec.tsx.snap +1 -2
- package/src/components/Switch/SelectorSwitch/__tests__/__snapshots__/index.spec.tsx.snap +1 -2
- package/src/components/Tabs/ScrollableTabsHeader.tsx +3 -3
- package/src/components/Tabs/__tests__/SceneView.spec.tsx +4 -4
- package/src/components/Tabs/__tests__/__snapshots__/SceneView.spec.tsx.snap +6 -9
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +33 -60
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabsHeader.spec.tsx.snap +7 -13
- package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +3 -8
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +45 -81
- package/src/components/Tabs/index.tsx +3 -3
- package/src/components/Tag/StyledTag.tsx +1 -4
- package/src/components/Tag/__tests__/Tag.spec.tsx +5 -1
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +47 -93
- package/src/components/Tag/index.tsx +5 -1
- package/src/components/TextInput/StyledTextInput.tsx +8 -16
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +72 -134
- package/src/components/TextInput/__tests__/__snapshots__/index.spec.tsx.snap +145 -257
- package/src/components/TextInput/index.tsx +2 -3
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerAndroid.spec.tsx.snap +12 -23
- package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +21 -35
- package/src/components/Toast/Toast.tsx +6 -5
- package/src/components/Toast/ToastContainer.tsx +2 -0
- package/src/components/Toast/__tests__/Toast.spec.tsx +5 -1
- package/src/components/Toast/__tests__/__snapshots__/Toast.spec.tsx.snap +26 -39
- package/src/components/Toolbar/StyledToolbar.tsx +1 -1
- package/src/components/Toolbar/ToolbarItem.tsx +4 -6
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarGroup.spec.tsx.snap +12 -18
- package/src/components/Toolbar/__tests__/__snapshots__/ToolbarItem.spec.tsx.snap +14 -21
- package/src/index.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +4 -0
- package/src/theme/components/badge.ts +15 -0
- package/src/theme/components/button.ts +16 -0
- package/src/theme/components/carousel.ts +15 -0
- package/src/theme/components/empty.ts +12 -0
- package/src/theme/components/error.ts +16 -0
- package/src/theme/components/fab.ts +11 -0
- package/src/theme/components/pinInput.ts +15 -0
- package/src/theme/components/success.ts +12 -0
- package/src/theme/components/tag.ts +16 -0
- package/src/theme/components/textInput.ts +1 -0
- package/src/theme/getTheme.ts +18 -18
- package/testUtils/setup.tsx +24 -0
- package/types/components/Badge/StyledBadge.d.ts +1 -1
- package/types/components/BottomNavigation/StyledBottomNavigation.d.ts +1 -1
- package/types/components/Button/StyledButton.d.ts +12 -5
- package/types/components/Button/UtilityButton/StyledUtilityButton.d.ts +1 -1
- package/types/components/Carousel/StyledCarousel.d.ts +1 -1
- package/types/components/Checkbox/StyledCheckbox.d.ts +1 -1
- package/types/components/ContentNavigator/StyledContentNavigator.d.ts +1 -5
- package/types/components/Empty/StyledEmpty.d.ts +2 -2
- package/types/components/Error/StyledError.d.ts +2 -2
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +2 -2
- package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +1 -1
- package/types/components/FAB/StyledFAB.d.ts +1 -1
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/components/Modal/ModalContentWrapper.d.ts +16 -0
- package/types/components/Modal/ModalPresenter/ModalPresenter.d.ts +34 -0
- package/types/components/Modal/ModalPresenter/index.d.ts +3 -0
- package/types/components/Modal/ModalProvider.d.ts +5 -0
- package/types/components/Modal/index.d.ts +33 -0
- package/types/components/PinInput/StyledPinInput.d.ts +2 -2
- package/types/components/RichTextEditor/RichTextEditor.d.ts +2 -2
- package/types/components/Success/StyledSuccess.d.ts +2 -2
- package/types/components/Tag/StyledTag.d.ts +1 -1
- package/types/components/TextInput/StyledTextInput.d.ts +7 -10
- package/types/components/Toolbar/StyledToolbar.d.ts +1 -1
- package/types/index.d.ts +2 -1
- package/types/theme/components/badge.d.ts +15 -0
- package/types/theme/components/button.d.ts +14 -0
- package/types/theme/components/carousel.d.ts +15 -0
- package/types/theme/components/empty.d.ts +11 -0
- package/types/theme/components/error.d.ts +15 -0
- package/types/theme/components/fab.d.ts +11 -0
- package/types/theme/components/pinInput.d.ts +15 -0
- package/types/theme/components/success.d.ts +11 -0
- package/types/theme/components/tag.d.ts +15 -0
- package/types/theme/components/textInput.d.ts +1 -0
- package/types/theme/getTheme.d.ts +18 -18
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
StyledButtonIcon,
|
|
10
10
|
StyledButtonIconWrapper,
|
|
11
11
|
StyledButtonText,
|
|
12
|
+
StyledButtonTitleOfVariantText,
|
|
12
13
|
} from './StyledButton';
|
|
13
14
|
import { useDeprecation } from '../../utils/hooks';
|
|
14
15
|
|
|
@@ -123,6 +124,15 @@ const deprecatedVariants: ThemeVariant[] = [
|
|
|
123
124
|
'outlined-secondary',
|
|
124
125
|
'outlined-danger',
|
|
125
126
|
];
|
|
127
|
+
|
|
128
|
+
function isTextVariant(
|
|
129
|
+
themeVariant: ThemeVariant
|
|
130
|
+
): themeVariant is 'text-primary' | 'text-secondary' | 'text-danger' {
|
|
131
|
+
return ['text-primary', 'text-secondary', 'text-danger'].includes(
|
|
132
|
+
themeVariant
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
126
136
|
const Button = ({
|
|
127
137
|
accessibilityHint,
|
|
128
138
|
accessibilityLabel,
|
|
@@ -156,7 +166,7 @@ const Button = ({
|
|
|
156
166
|
loading={loading}
|
|
157
167
|
onPress={onPress}
|
|
158
168
|
testID={testID}
|
|
159
|
-
|
|
169
|
+
themeButtonVariant={themeVariant}
|
|
160
170
|
style={style}
|
|
161
171
|
underlayColor={underlayColor}
|
|
162
172
|
>
|
|
@@ -173,25 +183,38 @@ const Button = ({
|
|
|
173
183
|
disabled={disabled}
|
|
174
184
|
icon={icon}
|
|
175
185
|
testID={`${testID}-left-icon`}
|
|
176
|
-
|
|
186
|
+
themeButtonVariant={themeVariant}
|
|
177
187
|
/>
|
|
178
188
|
</StyledButtonIconWrapper>
|
|
179
189
|
)}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
190
|
+
{isTextVariant(themeVariant) ? (
|
|
191
|
+
<StyledButtonTitleOfVariantText
|
|
192
|
+
variant="regular-bold"
|
|
193
|
+
ellipsizeMode="tail"
|
|
194
|
+
numberOfLines={1}
|
|
195
|
+
disabled={disabled}
|
|
196
|
+
themeButtonVariant={themeVariant}
|
|
197
|
+
>
|
|
198
|
+
{text}
|
|
199
|
+
</StyledButtonTitleOfVariantText>
|
|
200
|
+
) : (
|
|
201
|
+
<StyledButtonText
|
|
202
|
+
level="h5"
|
|
203
|
+
ellipsizeMode="tail"
|
|
204
|
+
numberOfLines={1}
|
|
205
|
+
disabled={disabled}
|
|
206
|
+
themeButtonVariant={themeVariant}
|
|
207
|
+
>
|
|
208
|
+
{text}
|
|
209
|
+
</StyledButtonText>
|
|
210
|
+
)}
|
|
188
211
|
{rightIcon !== undefined && (
|
|
189
212
|
<StyledButtonIconWrapper themePosition="right">
|
|
190
213
|
<StyledButtonIcon
|
|
191
214
|
disabled={disabled}
|
|
192
215
|
icon={rightIcon}
|
|
193
216
|
testID={`${testID}-right-icon`}
|
|
194
|
-
|
|
217
|
+
themeButtonVariant={themeVariant}
|
|
195
218
|
/>
|
|
196
219
|
</StyledButtonIconWrapper>
|
|
197
220
|
)}
|
|
@@ -81,20 +81,13 @@ const genOutlineTextStyles = (
|
|
|
81
81
|
intent: Intent,
|
|
82
82
|
disabled?: boolean
|
|
83
83
|
): ReactNativeStyle => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return { color: theme.__hd__.button.colors[intent] };
|
|
92
|
-
};
|
|
84
|
+
if (disabled) {
|
|
85
|
+
return {
|
|
86
|
+
color: theme.__hd__.button.colors.disabledText,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
93
89
|
|
|
94
|
-
return {
|
|
95
|
-
fontSize: theme.__hd__.button.fontSize.default,
|
|
96
|
-
...textColorStyling(),
|
|
97
|
-
};
|
|
90
|
+
return { color: theme.__hd__.button.colors[intent] };
|
|
98
91
|
};
|
|
99
92
|
|
|
100
93
|
const genTextVariantTextStyles = (
|
|
@@ -102,28 +95,21 @@ const genTextVariantTextStyles = (
|
|
|
102
95
|
intent: Intent,
|
|
103
96
|
disabled?: boolean
|
|
104
97
|
): ReactNativeStyle => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return { color: theme.__hd__.button.colors[intent] };
|
|
113
|
-
};
|
|
98
|
+
if (disabled) {
|
|
99
|
+
return {
|
|
100
|
+
color: theme.__hd__.button.colors.disabledText,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
114
103
|
|
|
115
|
-
return {
|
|
116
|
-
fontSize: theme.__hd__.button.fontSize.textVariant,
|
|
117
|
-
...textColorStyling(),
|
|
118
|
-
};
|
|
104
|
+
return { color: theme.__hd__.button.colors[intent] };
|
|
119
105
|
};
|
|
120
106
|
|
|
121
107
|
const StyledButtonContainer = styled(TouchableHighlight)<{
|
|
122
108
|
disabled?: boolean;
|
|
123
|
-
|
|
109
|
+
themeButtonVariant: ThemeVariant;
|
|
124
110
|
loading?: boolean;
|
|
125
|
-
}>(({ disabled = false, loading = false,
|
|
126
|
-
switch (
|
|
111
|
+
}>(({ disabled = false, loading = false, themeButtonVariant, theme }) => {
|
|
112
|
+
switch (themeButtonVariant) {
|
|
127
113
|
case 'filled-primary':
|
|
128
114
|
return genFilledContainerStyles(theme, 'primary', disabled, loading);
|
|
129
115
|
case 'filled-secondary':
|
|
@@ -153,17 +139,16 @@ const StyledButtonContainer = styled(TouchableHighlight)<{
|
|
|
153
139
|
}
|
|
154
140
|
});
|
|
155
141
|
|
|
156
|
-
const StyledButtonText = styled(Typography.
|
|
142
|
+
const StyledButtonText = styled(Typography.Title)<{
|
|
157
143
|
disabled?: boolean;
|
|
158
|
-
|
|
159
|
-
}>(({ disabled,
|
|
144
|
+
themeButtonVariant: ThemeVariant;
|
|
145
|
+
}>(({ disabled, themeButtonVariant, theme }) => {
|
|
160
146
|
const themeStyling = () => {
|
|
161
|
-
switch (
|
|
147
|
+
switch (themeButtonVariant) {
|
|
162
148
|
case 'filled-primary':
|
|
163
149
|
case 'filled-secondary':
|
|
164
150
|
case 'filled-danger':
|
|
165
151
|
return {
|
|
166
|
-
fontSize: theme.__hd__.button.fontSize.default,
|
|
167
152
|
color: theme.__hd__.button.colors.invertedText,
|
|
168
153
|
};
|
|
169
154
|
case 'outlined-primary':
|
|
@@ -183,7 +168,28 @@ const StyledButtonText = styled(Typography.Text)<{
|
|
|
183
168
|
return {
|
|
184
169
|
flexShrink: 1,
|
|
185
170
|
textAlign: 'center',
|
|
186
|
-
|
|
171
|
+
...themeStyling(),
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const StyledButtonTitleOfVariantText = styled(Typography.Body)<{
|
|
176
|
+
disabled?: boolean;
|
|
177
|
+
themeButtonVariant: 'text-primary' | 'text-secondary' | 'text-danger';
|
|
178
|
+
}>(({ disabled, themeButtonVariant, theme }) => {
|
|
179
|
+
const themeStyling = () => {
|
|
180
|
+
switch (themeButtonVariant) {
|
|
181
|
+
case 'text-primary':
|
|
182
|
+
return genTextVariantTextStyles(theme, 'primary', disabled);
|
|
183
|
+
case 'text-secondary':
|
|
184
|
+
return genTextVariantTextStyles(theme, 'secondary', disabled);
|
|
185
|
+
case 'text-danger':
|
|
186
|
+
return genTextVariantTextStyles(theme, 'danger', disabled);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
return {
|
|
190
|
+
flexShrink: 1,
|
|
191
|
+
lineHeight: theme.__hd__.button.lineHeights.titleOfTextVariant, // align text on Android
|
|
192
|
+
textAlign: 'center',
|
|
187
193
|
...themeStyling(),
|
|
188
194
|
};
|
|
189
195
|
});
|
|
@@ -201,10 +207,10 @@ const StyledButtonIconWrapper = styled(View)<{
|
|
|
201
207
|
|
|
202
208
|
const StyledButtonIcon = styled(Icon)<{
|
|
203
209
|
disabled?: boolean;
|
|
204
|
-
|
|
205
|
-
}>(({ disabled,
|
|
210
|
+
themeButtonVariant: ThemeVariant;
|
|
211
|
+
}>(({ disabled, themeButtonVariant, theme }) => {
|
|
206
212
|
const themeStyling = () => {
|
|
207
|
-
switch (
|
|
213
|
+
switch (themeButtonVariant) {
|
|
208
214
|
case 'filled-primary':
|
|
209
215
|
case 'filled-secondary':
|
|
210
216
|
case 'filled-danger':
|
|
@@ -235,5 +241,6 @@ export {
|
|
|
235
241
|
StyledButtonText,
|
|
236
242
|
StyledButtonIconWrapper,
|
|
237
243
|
StyledButtonIcon,
|
|
244
|
+
StyledButtonTitleOfVariantText,
|
|
238
245
|
};
|
|
239
246
|
export type { Intent, ThemeVariant };
|
|
@@ -17,9 +17,7 @@ export const IconWrapper = styled(View)(({ theme }) => ({
|
|
|
17
17
|
paddingRight: theme.__hd__.button.space.iconPadding,
|
|
18
18
|
}));
|
|
19
19
|
|
|
20
|
-
export const ButtonText = styled(Typography.
|
|
20
|
+
export const ButtonText = styled(Typography.Body)({
|
|
21
21
|
flexShrink: 1,
|
|
22
22
|
textAlign: 'center',
|
|
23
|
-
|
|
24
|
-
fontFamily: theme.__hd__.button.fonts.utility,
|
|
25
|
-
}));
|
|
23
|
+
});
|
|
@@ -59,25 +59,22 @@ exports[`UtilityButton snapshot has intent primary style 1`] = `
|
|
|
59
59
|
Object {
|
|
60
60
|
"color": "#001f23",
|
|
61
61
|
"fontFamily": "BeVietnamPro-Regular",
|
|
62
|
-
"fontSize":
|
|
63
|
-
"letterSpacing": 0.
|
|
64
|
-
"lineHeight":
|
|
62
|
+
"fontSize": 16,
|
|
63
|
+
"letterSpacing": 0.48,
|
|
64
|
+
"lineHeight": 24,
|
|
65
65
|
},
|
|
66
66
|
Array [
|
|
67
67
|
Object {
|
|
68
68
|
"flexShrink": 1,
|
|
69
|
-
"fontFamily": "BeVietnamPro-Regular",
|
|
70
|
-
"fontSize": 16,
|
|
71
69
|
"textAlign": "center",
|
|
72
70
|
},
|
|
73
71
|
undefined,
|
|
74
72
|
],
|
|
75
73
|
]
|
|
76
74
|
}
|
|
77
|
-
themeFontSize="medium"
|
|
78
|
-
themeFontWeight="regular"
|
|
79
75
|
themeIntent="body"
|
|
80
76
|
themeTypeface="neutral"
|
|
77
|
+
themeVariant="regular"
|
|
81
78
|
>
|
|
82
79
|
Settings
|
|
83
80
|
</Text>
|
|
@@ -143,25 +140,22 @@ exports[`UtilityButton snapshot has intent text style 1`] = `
|
|
|
143
140
|
Object {
|
|
144
141
|
"color": "#001f23",
|
|
145
142
|
"fontFamily": "BeVietnamPro-Regular",
|
|
146
|
-
"fontSize":
|
|
147
|
-
"letterSpacing": 0.
|
|
148
|
-
"lineHeight":
|
|
143
|
+
"fontSize": 16,
|
|
144
|
+
"letterSpacing": 0.48,
|
|
145
|
+
"lineHeight": 24,
|
|
149
146
|
},
|
|
150
147
|
Array [
|
|
151
148
|
Object {
|
|
152
149
|
"flexShrink": 1,
|
|
153
|
-
"fontFamily": "BeVietnamPro-Regular",
|
|
154
|
-
"fontSize": 16,
|
|
155
150
|
"textAlign": "center",
|
|
156
151
|
},
|
|
157
152
|
undefined,
|
|
158
153
|
],
|
|
159
154
|
]
|
|
160
155
|
}
|
|
161
|
-
themeFontSize="medium"
|
|
162
|
-
themeFontWeight="regular"
|
|
163
156
|
themeIntent="body"
|
|
164
157
|
themeTypeface="neutral"
|
|
158
|
+
themeVariant="regular"
|
|
165
159
|
>
|
|
166
160
|
Settings
|
|
167
161
|
</Text>
|
|
@@ -24,7 +24,7 @@ describe('StyledButtonContainer', () => {
|
|
|
24
24
|
${'text-danger'}
|
|
25
25
|
`('has $themeVariant style', ({ themeVariant }): void => {
|
|
26
26
|
const { toJSON } = renderWithTheme(
|
|
27
|
-
<StyledButtonContainer
|
|
27
|
+
<StyledButtonContainer themeButtonVariant={themeVariant}>
|
|
28
28
|
<Text>Title</Text>
|
|
29
29
|
</StyledButtonContainer>
|
|
30
30
|
);
|
|
@@ -34,7 +34,7 @@ describe('StyledButtonContainer', () => {
|
|
|
34
34
|
|
|
35
35
|
it('renders disabled correctly', () => {
|
|
36
36
|
const { toJSON } = renderWithTheme(
|
|
37
|
-
<StyledButtonContainer
|
|
37
|
+
<StyledButtonContainer themeButtonVariant="filled-primary" disabled>
|
|
38
38
|
<Text>Title</Text>
|
|
39
39
|
</StyledButtonContainer>
|
|
40
40
|
);
|
|
@@ -57,7 +57,9 @@ describe('StyledButtonText', () => {
|
|
|
57
57
|
${'text-danger'}
|
|
58
58
|
`('has $themeVariant style', ({ themeVariant }) => {
|
|
59
59
|
const { toJSON } = renderWithTheme(
|
|
60
|
-
<StyledButtonText
|
|
60
|
+
<StyledButtonText themeButtonVariant={themeVariant}>
|
|
61
|
+
Example
|
|
62
|
+
</StyledButtonText>
|
|
61
63
|
);
|
|
62
64
|
|
|
63
65
|
expect(toJSON()).toMatchSnapshot();
|
|
@@ -65,7 +67,7 @@ describe('StyledButtonText', () => {
|
|
|
65
67
|
|
|
66
68
|
it('renders disabled correctly', () => {
|
|
67
69
|
const { toJSON } = renderWithTheme(
|
|
68
|
-
<StyledButtonText
|
|
70
|
+
<StyledButtonText themeButtonVariant="filled-primary" disabled>
|
|
69
71
|
Example
|
|
70
72
|
</StyledButtonText>
|
|
71
73
|
);
|
|
@@ -102,7 +104,7 @@ describe('StyledButtonIcon', () => {
|
|
|
102
104
|
${'text-danger'}
|
|
103
105
|
`('has $themeVariant style', ({ themeVariant }) => {
|
|
104
106
|
const { toJSON } = renderWithTheme(
|
|
105
|
-
<StyledButtonIcon icon="bell"
|
|
107
|
+
<StyledButtonIcon icon="bell" themeButtonVariant={themeVariant} />
|
|
106
108
|
);
|
|
107
109
|
|
|
108
110
|
expect(toJSON()).toMatchSnapshot();
|
|
@@ -110,7 +112,11 @@ describe('StyledButtonIcon', () => {
|
|
|
110
112
|
|
|
111
113
|
it('renders disabled correctly', () => {
|
|
112
114
|
const { toJSON } = renderWithTheme(
|
|
113
|
-
<StyledButtonIcon
|
|
115
|
+
<StyledButtonIcon
|
|
116
|
+
icon="bell"
|
|
117
|
+
themeButtonVariant="filled-primary"
|
|
118
|
+
disabled
|
|
119
|
+
/>
|
|
114
120
|
);
|
|
115
121
|
|
|
116
122
|
expect(toJSON()).toMatchSnapshot();
|