@hero-design/rn 8.104.1-alpha.2 → 8.105.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 +3 -3
- package/CHANGELOG.md +6 -10
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +683 -402
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +683 -401
- package/package.json +1 -1
- package/src/components/Calendar/CalendarRange.tsx +35 -117
- package/src/components/Calendar/__tests__/helper.spec.ts +197 -0
- package/src/components/Calendar/constants.ts +9 -0
- package/src/components/Calendar/helpers.ts +112 -0
- package/src/components/Calendar/index.tsx +34 -159
- package/src/components/Calendar/shared/hooks/useCalendarLayout.ts +37 -0
- package/src/components/Calendar/types.ts +62 -0
- package/src/components/DatePicker/DatePickerCalendar.tsx +2 -1
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/IconList.ts +2 -0
- package/src/components/SegmentedControl/SegmentedItem.tsx +192 -0
- package/src/components/SegmentedControl/StyledSegmentedControl.tsx +62 -0
- package/src/components/SegmentedControl/__tests__/SegmentedItem.spec.tsx +162 -0
- package/src/components/SegmentedControl/__tests__/__snapshots__/SegmentedItem.spec.tsx.snap +131 -0
- package/src/components/SegmentedControl/__tests__/__snapshots__/index.spec.tsx.snap +359 -0
- package/src/components/SegmentedControl/__tests__/index.spec.tsx +247 -0
- package/src/components/SegmentedControl/index.tsx +61 -0
- package/src/components/SegmentedControl/types.ts +46 -0
- package/src/components/Typography/Body/StyledBody.tsx +2 -2
- package/src/components/Typography/Body/__tests__/__snapshots__/index.spec.tsx.snap +51 -0
- package/src/components/Typography/Body/__tests__/index.spec.tsx +1 -0
- package/src/components/Typography/Body/index.tsx +2 -13
- package/src/components/Typography/Caption/StyledCaption.tsx +2 -2
- package/src/components/Typography/Caption/__tests__/__snapshots__/index.spec.tsx.snap +50 -0
- package/src/components/Typography/Caption/__tests__/index.spec.tsx +1 -0
- package/src/components/Typography/Caption/index.tsx +2 -13
- package/src/components/Typography/Label/StyledLabel.tsx +2 -2
- package/src/components/Typography/Label/__tests__/__snapshots__/index.spec.tsx.snap +48 -0
- package/src/components/Typography/Label/__tests__/index.spec.tsx +1 -0
- package/src/components/Typography/Label/index.tsx +2 -13
- package/src/components/Typography/Title/StyledTitle.tsx +2 -2
- package/src/components/Typography/Title/__tests__/__snapshots__/index.spec.tsx.snap +51 -0
- package/src/components/Typography/Title/__tests__/index.spec.tsx +1 -0
- package/src/components/Typography/Title/index.tsx +2 -13
- package/src/components/Typography/types.ts +3 -2
- package/src/index.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +54 -0
- package/src/theme/components/segmentedControl.ts +60 -0
- package/src/theme/components/typography.ts +1 -0
- package/src/theme/getTheme.ts +3 -0
- package/src/types.ts +2 -0
- package/stats/8.104.0/rn-stats.html +3 -1
- package/stats/8.105.0/rn-stats.html +4844 -0
- package/types/components/Calendar/CalendarRange.d.ts +4 -16
- package/types/components/Calendar/constants.d.ts +4 -0
- package/types/components/Calendar/helpers.d.ts +14 -0
- package/types/components/Calendar/index.d.ts +5 -56
- package/types/components/Calendar/shared/hooks/useCalendarLayout.d.ts +8 -0
- package/types/components/Calendar/types.d.ts +58 -0
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/SegmentedControl/SegmentedItem.d.ts +18 -0
- package/types/components/SegmentedControl/StyledSegmentedControl.d.ts +26 -0
- package/types/components/SegmentedControl/index.d.ts +31 -0
- package/types/components/SegmentedControl/types.d.ts +43 -0
- package/types/components/TextInput/index.d.ts +1 -1
- package/types/components/Typography/Body/StyledBody.d.ts +2 -2
- package/types/components/Typography/Body/index.d.ts +2 -1
- package/types/components/Typography/Caption/StyledCaption.d.ts +2 -2
- package/types/components/Typography/Caption/index.d.ts +2 -1
- package/types/components/Typography/Label/StyledLabel.d.ts +2 -2
- package/types/components/Typography/Label/index.d.ts +2 -1
- package/types/components/Typography/Title/StyledTitle.d.ts +2 -2
- package/types/components/Typography/Title/index.d.ts +2 -1
- package/types/components/Typography/types.d.ts +1 -1
- package/types/index.d.ts +2 -1
- package/types/theme/components/segmentedControl.d.ts +46 -0
- package/types/theme/components/typography.d.ts +1 -0
- package/types/theme/getTheme.d.ts +2 -0
- package/types/types.d.ts +2 -1
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fireEvent } from '@testing-library/react-native';
|
|
3
|
+
import SegmentedControl, { SegmentedControlProps } from '..';
|
|
4
|
+
import type { SegmentedControlItemConfig } from '../types';
|
|
5
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
6
|
+
import { scale } from '../../../utils/scale';
|
|
7
|
+
|
|
8
|
+
describe('SegmentedControl', () => {
|
|
9
|
+
const defaultItems: SegmentedControlItemConfig[] = [
|
|
10
|
+
{ value: 'option1', label: 'Option 1' },
|
|
11
|
+
{ value: 'option2', label: 'Option 2' },
|
|
12
|
+
{ value: 'option3', label: 'Option 3' },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const defaultProps: SegmentedControlProps = {
|
|
16
|
+
items: defaultItems,
|
|
17
|
+
value: 'option1',
|
|
18
|
+
onItemPress: jest.fn(),
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
jest.clearAllMocks();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should render correctly with default props', () => {
|
|
26
|
+
const { toJSON, getByText } = renderWithTheme(
|
|
27
|
+
<SegmentedControl {...defaultProps} />
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
expect(getByText('Option 1')).toBeVisible();
|
|
31
|
+
expect(getByText('Option 2')).toBeVisible();
|
|
32
|
+
expect(getByText('Option 3')).toBeVisible();
|
|
33
|
+
expect(toJSON()).toMatchSnapshot();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('sizing', () => {
|
|
37
|
+
it.each`
|
|
38
|
+
size | expectedHeight
|
|
39
|
+
${'medium'} | ${scale(36)}
|
|
40
|
+
${'large'} | ${scale(44)}
|
|
41
|
+
`(
|
|
42
|
+
'should have correct height of $expectedHeight for $size size',
|
|
43
|
+
({ size, expectedHeight }) => {
|
|
44
|
+
const { getByTestId } = renderWithTheme(
|
|
45
|
+
<SegmentedControl
|
|
46
|
+
{...defaultProps}
|
|
47
|
+
size={size}
|
|
48
|
+
testID="segmented-control"
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const wrapper = getByTestId('segmented-control');
|
|
53
|
+
expect(wrapper).toHaveStyle({ height: expectedHeight });
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should display icons when provided', () => {
|
|
59
|
+
const itemsWithIcons: SegmentedControlItemConfig[] = [
|
|
60
|
+
{
|
|
61
|
+
value: 'home',
|
|
62
|
+
label: 'Home',
|
|
63
|
+
prefix: 'home-outlined',
|
|
64
|
+
testID: 'home-item',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
value: 'settings',
|
|
68
|
+
label: 'Settings',
|
|
69
|
+
suffix: 'cog-outlined',
|
|
70
|
+
testID: 'settings-item',
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
const { getByText, getByTestId } = renderWithTheme(
|
|
75
|
+
<SegmentedControl {...defaultProps} items={itemsWithIcons} value="home" />
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
expect(getByTestId('home-item-prefix')).toBeVisible();
|
|
79
|
+
expect(getByTestId('settings-item-suffix')).toBeVisible();
|
|
80
|
+
expect(getByText('Home')).toBeVisible();
|
|
81
|
+
expect(getByText('Settings')).toBeVisible();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('should not call onItemPress when disabled item is clicked', () => {
|
|
85
|
+
const onItemPress = jest.fn();
|
|
86
|
+
const itemsWithDisabled: SegmentedControlItemConfig[] = [
|
|
87
|
+
{ value: 'option1', label: 'Option 1' },
|
|
88
|
+
{ value: 'option2', label: 'Option 2', disabled: true },
|
|
89
|
+
];
|
|
90
|
+
|
|
91
|
+
const { getByText } = renderWithTheme(
|
|
92
|
+
<SegmentedControl
|
|
93
|
+
{...defaultProps}
|
|
94
|
+
items={itemsWithDisabled}
|
|
95
|
+
onItemPress={onItemPress}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
fireEvent.press(getByText('Option 2'));
|
|
100
|
+
expect(onItemPress).not.toHaveBeenCalled();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it.each`
|
|
104
|
+
value | max | expectedText
|
|
105
|
+
${10} | ${10} | ${'10'}
|
|
106
|
+
${15} | ${10} | ${'10+'}
|
|
107
|
+
${99} | ${undefined} | ${'99'}
|
|
108
|
+
`(
|
|
109
|
+
'should display count badge $expectedText for $value and $max',
|
|
110
|
+
({ value, max, expectedText }) => {
|
|
111
|
+
const itemsWithBadges: SegmentedControlItemConfig[] = [
|
|
112
|
+
{
|
|
113
|
+
value: 'counter',
|
|
114
|
+
label: 'Counter',
|
|
115
|
+
badge: { type: 'counter', value, max },
|
|
116
|
+
},
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
const { getByText } = renderWithTheme(
|
|
120
|
+
<SegmentedControl
|
|
121
|
+
{...defaultProps}
|
|
122
|
+
items={itemsWithBadges}
|
|
123
|
+
value="counter"
|
|
124
|
+
/>
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
expect(getByText('Counter')).toBeVisible();
|
|
128
|
+
expect(getByText(expectedText)).toBeVisible();
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
it('should display status badge correctly', () => {
|
|
133
|
+
const itemsWithStatusBadge: SegmentedControlItemConfig[] = [
|
|
134
|
+
{
|
|
135
|
+
value: 'status',
|
|
136
|
+
label: 'Status',
|
|
137
|
+
badge: { type: 'status' },
|
|
138
|
+
testID: 'status-item',
|
|
139
|
+
},
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
const { getByText, getByTestId } = renderWithTheme(
|
|
143
|
+
<SegmentedControl
|
|
144
|
+
{...defaultProps}
|
|
145
|
+
items={itemsWithStatusBadge}
|
|
146
|
+
value="status"
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
expect(getByText('Status')).toBeVisible();
|
|
151
|
+
expect(getByTestId('status-item-badge')).toBeVisible();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('should display subtext when provided', () => {
|
|
155
|
+
const itemsWithSubtext: SegmentedControlItemConfig[] = [
|
|
156
|
+
{
|
|
157
|
+
value: 'item1',
|
|
158
|
+
label: 'Main Label',
|
|
159
|
+
subText: 'Secondary text',
|
|
160
|
+
},
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
const { getByText } = renderWithTheme(
|
|
164
|
+
<SegmentedControl
|
|
165
|
+
{...defaultProps}
|
|
166
|
+
items={itemsWithSubtext}
|
|
167
|
+
value="item1"
|
|
168
|
+
/>
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
expect(getByText('Main Label')).toBeVisible();
|
|
172
|
+
expect(getByText('Secondary text')).toBeVisible();
|
|
173
|
+
expect(getByText('·')).toBeVisible(); // bullet separator
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('should render complex control with all features correctly', () => {
|
|
177
|
+
const complexItems: SegmentedControlItemConfig[] = [
|
|
178
|
+
{
|
|
179
|
+
value: 'complex1',
|
|
180
|
+
label: 'Dashboard',
|
|
181
|
+
subText: 'Overview',
|
|
182
|
+
prefix: 'home-outlined',
|
|
183
|
+
suffix: 'cog-outlined',
|
|
184
|
+
badge: { type: 'counter', value: 5, max: 3 },
|
|
185
|
+
testID: 'complex1',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
value: 'complex2',
|
|
189
|
+
label: 'Profile',
|
|
190
|
+
badge: { type: 'status' },
|
|
191
|
+
disabled: true,
|
|
192
|
+
testID: 'complex2',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
value: 'complex3',
|
|
196
|
+
label: 'Settings',
|
|
197
|
+
prefix: 'pencil-outlined',
|
|
198
|
+
testID: 'complex3',
|
|
199
|
+
},
|
|
200
|
+
];
|
|
201
|
+
|
|
202
|
+
const { getByText, getByTestId } = renderWithTheme(
|
|
203
|
+
<SegmentedControl
|
|
204
|
+
{...defaultProps}
|
|
205
|
+
items={complexItems}
|
|
206
|
+
value="complex1"
|
|
207
|
+
size="large"
|
|
208
|
+
testID="complex-control"
|
|
209
|
+
/>
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
// Control container
|
|
213
|
+
expect(getByTestId('complex-control')).toBeVisible();
|
|
214
|
+
expect(getByTestId('complex-control')).toHaveStyle({ height: scale(44) }); // large size
|
|
215
|
+
|
|
216
|
+
// First item - all features
|
|
217
|
+
expect(getByText('Dashboard')).toBeVisible();
|
|
218
|
+
expect(getByText('Overview')).toBeVisible();
|
|
219
|
+
expect(getByText('·')).toBeVisible(); // bullet separator
|
|
220
|
+
expect(getByText('3+')).toBeVisible(); // over max badge
|
|
221
|
+
expect(getByTestId('complex1-prefix')).toBeVisible();
|
|
222
|
+
expect(getByTestId('complex1-suffix')).toBeVisible();
|
|
223
|
+
|
|
224
|
+
// Second item - disabled with status badge
|
|
225
|
+
expect(getByText('Profile')).toBeVisible();
|
|
226
|
+
expect(getByTestId('complex2-badge')).toBeVisible();
|
|
227
|
+
|
|
228
|
+
// Third item - simple with prefix
|
|
229
|
+
expect(getByText('Settings')).toBeVisible();
|
|
230
|
+
expect(getByTestId('complex3-prefix')).toBeVisible();
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it('should call onItemPress with correct item when pressed', () => {
|
|
234
|
+
const onItemPress = jest.fn();
|
|
235
|
+
const { getByText } = renderWithTheme(
|
|
236
|
+
<SegmentedControl {...defaultProps} onItemPress={onItemPress} />
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
fireEvent.press(getByText('Option 2'));
|
|
240
|
+
|
|
241
|
+
expect(onItemPress).toHaveBeenCalledTimes(1);
|
|
242
|
+
expect(onItemPress).toHaveBeenCalledWith({
|
|
243
|
+
value: 'option2',
|
|
244
|
+
label: 'Option 2',
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewProps, ViewStyle } from 'react-native';
|
|
3
|
+
import SegmentedItem from './SegmentedItem';
|
|
4
|
+
import { StyledSegmentedControlWrapper } from './StyledSegmentedControl';
|
|
5
|
+
import type { SegmentedControlItemConfig } from './types';
|
|
6
|
+
|
|
7
|
+
export interface SegmentedControlProps extends ViewProps {
|
|
8
|
+
/**
|
|
9
|
+
* The size of the segmented control.
|
|
10
|
+
*/
|
|
11
|
+
size?: 'medium' | 'large';
|
|
12
|
+
/**
|
|
13
|
+
* The items to display in the segmented control.
|
|
14
|
+
*/
|
|
15
|
+
items: SegmentedControlItemConfig[];
|
|
16
|
+
/**
|
|
17
|
+
* The value of the selected item.
|
|
18
|
+
*/
|
|
19
|
+
value: string;
|
|
20
|
+
/**
|
|
21
|
+
* Test ID for testing purposes.
|
|
22
|
+
*/
|
|
23
|
+
testID?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The style of the segmented control.
|
|
26
|
+
*/
|
|
27
|
+
style?: StyleProp<ViewStyle>;
|
|
28
|
+
/**
|
|
29
|
+
* The callback function to be called when the selected item changes.
|
|
30
|
+
*/
|
|
31
|
+
onItemPress: (item: SegmentedControlItemConfig) => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const SegmentedControl = ({
|
|
35
|
+
size = 'medium',
|
|
36
|
+
items,
|
|
37
|
+
value,
|
|
38
|
+
testID,
|
|
39
|
+
style,
|
|
40
|
+
onItemPress,
|
|
41
|
+
}: SegmentedControlProps) => {
|
|
42
|
+
return (
|
|
43
|
+
<StyledSegmentedControlWrapper
|
|
44
|
+
themeSize={size}
|
|
45
|
+
testID={testID}
|
|
46
|
+
style={style}
|
|
47
|
+
>
|
|
48
|
+
{items.map((item) => (
|
|
49
|
+
<SegmentedItem
|
|
50
|
+
{...item}
|
|
51
|
+
key={item.value}
|
|
52
|
+
selected={item.value === value}
|
|
53
|
+
onPress={() => onItemPress(item)}
|
|
54
|
+
size={size}
|
|
55
|
+
/>
|
|
56
|
+
))}
|
|
57
|
+
</StyledSegmentedControlWrapper>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default SegmentedControl;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { IconName } from '../Icon';
|
|
2
|
+
|
|
3
|
+
export type StatusBadgeType = {
|
|
4
|
+
type: 'status';
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type CounterBadgeType = {
|
|
8
|
+
type: 'counter';
|
|
9
|
+
value: number;
|
|
10
|
+
max?: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export interface SegmentedControlItemConfig {
|
|
14
|
+
/**
|
|
15
|
+
* The value of the segment option.
|
|
16
|
+
*/
|
|
17
|
+
value: string;
|
|
18
|
+
/**
|
|
19
|
+
* The label of the segment option.
|
|
20
|
+
*/
|
|
21
|
+
label?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The subtext of the segment option.
|
|
24
|
+
*/
|
|
25
|
+
subText?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The prefix of the segment option.
|
|
28
|
+
*/
|
|
29
|
+
prefix?: IconName;
|
|
30
|
+
/**
|
|
31
|
+
* The suffix of the segment option.
|
|
32
|
+
*/
|
|
33
|
+
suffix?: IconName;
|
|
34
|
+
/**
|
|
35
|
+
* Test ID for testing purposes.
|
|
36
|
+
*/
|
|
37
|
+
testID?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the segment option is disabled.
|
|
40
|
+
*/
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The badge configuration of the segment option.
|
|
44
|
+
*/
|
|
45
|
+
badge?: StatusBadgeType | CounterBadgeType;
|
|
46
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import styled from '@emotion/native';
|
|
2
2
|
import { Text } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import type { TypographyIntent } from '../types';
|
|
4
4
|
|
|
5
5
|
type ThemeVariant = 'small' | 'small-bold' | 'regular' | 'regular-bold';
|
|
6
6
|
type FontWeights = 'regular' | 'semiBold';
|
|
@@ -20,7 +20,7 @@ const FONTSIZE_MAP: Record<ThemeVariant, FontSizes> = {
|
|
|
20
20
|
'small-bold': 'small',
|
|
21
21
|
} as const;
|
|
22
22
|
const StyledBody = styled(Text)<{
|
|
23
|
-
themeIntent:
|
|
23
|
+
themeIntent: TypographyIntent;
|
|
24
24
|
themeTypeface: 'neutral' | 'playful';
|
|
25
25
|
themeVariant: ThemeVariant;
|
|
26
26
|
}>(({ themeIntent, theme, themeTypeface, themeVariant }) => ({
|
|
@@ -204,6 +204,57 @@ exports[`Body has disabled intent style 1`] = `
|
|
|
204
204
|
</View>
|
|
205
205
|
`;
|
|
206
206
|
|
|
207
|
+
exports[`Body has inactive intent style 1`] = `
|
|
208
|
+
<View
|
|
209
|
+
style={
|
|
210
|
+
{
|
|
211
|
+
"flex": 1,
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
>
|
|
215
|
+
<Text
|
|
216
|
+
allowFontScaling={false}
|
|
217
|
+
style={
|
|
218
|
+
[
|
|
219
|
+
{
|
|
220
|
+
"color": "#808f91",
|
|
221
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
222
|
+
"fontSize": 16,
|
|
223
|
+
"letterSpacing": 0.48,
|
|
224
|
+
"lineHeight": 24,
|
|
225
|
+
},
|
|
226
|
+
undefined,
|
|
227
|
+
]
|
|
228
|
+
}
|
|
229
|
+
themeIntent="inactive"
|
|
230
|
+
themeTypeface="neutral"
|
|
231
|
+
themeVariant="regular"
|
|
232
|
+
>
|
|
233
|
+
This is a test
|
|
234
|
+
</Text>
|
|
235
|
+
<View
|
|
236
|
+
pointerEvents="box-none"
|
|
237
|
+
position="bottom"
|
|
238
|
+
style={
|
|
239
|
+
[
|
|
240
|
+
{
|
|
241
|
+
"bottom": 0,
|
|
242
|
+
"elevation": 9999,
|
|
243
|
+
"flexDirection": "column-reverse",
|
|
244
|
+
"left": 0,
|
|
245
|
+
"paddingHorizontal": 24,
|
|
246
|
+
"paddingVertical": 16,
|
|
247
|
+
"position": "absolute",
|
|
248
|
+
"right": 0,
|
|
249
|
+
"top": 0,
|
|
250
|
+
},
|
|
251
|
+
undefined,
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
/>
|
|
255
|
+
</View>
|
|
256
|
+
`;
|
|
257
|
+
|
|
207
258
|
exports[`Body has info intent style 1`] = `
|
|
208
259
|
<View
|
|
209
260
|
style={
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
TextStyle,
|
|
7
7
|
} from 'react-native';
|
|
8
8
|
import { StyledBody } from './StyledBody';
|
|
9
|
+
import type { TypographyIntent } from '../types';
|
|
9
10
|
|
|
10
11
|
export interface BodyProps extends NativeTextProps {
|
|
11
12
|
/**
|
|
@@ -15,19 +16,7 @@ export interface BodyProps extends NativeTextProps {
|
|
|
15
16
|
/**
|
|
16
17
|
* Visual intent color to apply to the text.
|
|
17
18
|
*/
|
|
18
|
-
intent?:
|
|
19
|
-
| 'body'
|
|
20
|
-
| 'subdued'
|
|
21
|
-
| 'primary'
|
|
22
|
-
| 'secondary'
|
|
23
|
-
| 'success'
|
|
24
|
-
| 'info'
|
|
25
|
-
| 'warning'
|
|
26
|
-
| 'danger'
|
|
27
|
-
| 'inverted'
|
|
28
|
-
| 'archived'
|
|
29
|
-
| 'disabled'
|
|
30
|
-
| 'muted';
|
|
19
|
+
intent?: TypographyIntent;
|
|
31
20
|
/**
|
|
32
21
|
* Additional style.
|
|
33
22
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Text } from 'react-native';
|
|
2
2
|
import styled from '@emotion/native';
|
|
3
|
-
import { FONTWEIGHT_MAP,
|
|
3
|
+
import { FONTWEIGHT_MAP, TypographyIntent } from '../types';
|
|
4
4
|
|
|
5
5
|
const StyledCaption = styled(Text)<{
|
|
6
6
|
themeFontWeight: 'regular' | 'semi-bold';
|
|
7
|
-
themeIntent:
|
|
7
|
+
themeIntent: TypographyIntent;
|
|
8
8
|
}>(({ themeFontWeight, themeIntent, theme }) => ({
|
|
9
9
|
fontSize: theme.__hd__.typography.fontSizes.caption,
|
|
10
10
|
lineHeight: theme.__hd__.typography.lineHeights.caption,
|
|
@@ -200,6 +200,56 @@ exports[`Caption has disabled intent style 1`] = `
|
|
|
200
200
|
</View>
|
|
201
201
|
`;
|
|
202
202
|
|
|
203
|
+
exports[`Caption has inactive intent style 1`] = `
|
|
204
|
+
<View
|
|
205
|
+
style={
|
|
206
|
+
{
|
|
207
|
+
"flex": 1,
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
>
|
|
211
|
+
<Text
|
|
212
|
+
allowFontScaling={false}
|
|
213
|
+
style={
|
|
214
|
+
[
|
|
215
|
+
{
|
|
216
|
+
"color": "#808f91",
|
|
217
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
218
|
+
"fontSize": 12,
|
|
219
|
+
"letterSpacing": 0.36,
|
|
220
|
+
"lineHeight": 16,
|
|
221
|
+
},
|
|
222
|
+
undefined,
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
themeFontWeight="regular"
|
|
226
|
+
themeIntent="inactive"
|
|
227
|
+
>
|
|
228
|
+
This is a test
|
|
229
|
+
</Text>
|
|
230
|
+
<View
|
|
231
|
+
pointerEvents="box-none"
|
|
232
|
+
position="bottom"
|
|
233
|
+
style={
|
|
234
|
+
[
|
|
235
|
+
{
|
|
236
|
+
"bottom": 0,
|
|
237
|
+
"elevation": 9999,
|
|
238
|
+
"flexDirection": "column-reverse",
|
|
239
|
+
"left": 0,
|
|
240
|
+
"paddingHorizontal": 24,
|
|
241
|
+
"paddingVertical": 16,
|
|
242
|
+
"position": "absolute",
|
|
243
|
+
"right": 0,
|
|
244
|
+
"top": 0,
|
|
245
|
+
},
|
|
246
|
+
undefined,
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
/>
|
|
250
|
+
</View>
|
|
251
|
+
`;
|
|
252
|
+
|
|
203
253
|
exports[`Caption has info intent style 1`] = `
|
|
204
254
|
<View
|
|
205
255
|
style={
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
TextStyle,
|
|
7
7
|
} from 'react-native';
|
|
8
8
|
import { StyledCaption } from './StyledCaption';
|
|
9
|
+
import type { TypographyIntent } from '../types';
|
|
9
10
|
|
|
10
11
|
export interface CaptionProps extends NativeTextProps {
|
|
11
12
|
/**
|
|
@@ -19,19 +20,7 @@ export interface CaptionProps extends NativeTextProps {
|
|
|
19
20
|
/**
|
|
20
21
|
* Visual intent color to apply to the text.
|
|
21
22
|
*/
|
|
22
|
-
intent?:
|
|
23
|
-
| 'body'
|
|
24
|
-
| 'subdued'
|
|
25
|
-
| 'primary'
|
|
26
|
-
| 'secondary'
|
|
27
|
-
| 'success'
|
|
28
|
-
| 'info'
|
|
29
|
-
| 'warning'
|
|
30
|
-
| 'danger'
|
|
31
|
-
| 'inverted'
|
|
32
|
-
| 'archived'
|
|
33
|
-
| 'disabled'
|
|
34
|
-
| 'muted';
|
|
23
|
+
intent?: TypographyIntent;
|
|
35
24
|
/**
|
|
36
25
|
* Additional style.
|
|
37
26
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import styled from '@emotion/native';
|
|
2
2
|
import { Text } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import type { TypographyIntent } from '../types';
|
|
4
4
|
|
|
5
5
|
const StyledLabel = styled(Text)<{
|
|
6
|
-
themeIntent:
|
|
6
|
+
themeIntent: TypographyIntent;
|
|
7
7
|
}>(({ themeIntent, theme }) => ({
|
|
8
8
|
fontSize: theme.__hd__.typography.fontSizes.label,
|
|
9
9
|
lineHeight: theme.__hd__.typography.lineHeights.label,
|
|
@@ -192,6 +192,54 @@ exports[`Label has disabled intent style 1`] = `
|
|
|
192
192
|
</View>
|
|
193
193
|
`;
|
|
194
194
|
|
|
195
|
+
exports[`Label has inactive intent style 1`] = `
|
|
196
|
+
<View
|
|
197
|
+
style={
|
|
198
|
+
{
|
|
199
|
+
"flex": 1,
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
>
|
|
203
|
+
<Text
|
|
204
|
+
allowFontScaling={false}
|
|
205
|
+
style={
|
|
206
|
+
[
|
|
207
|
+
{
|
|
208
|
+
"color": "#808f91",
|
|
209
|
+
"fontSize": 10,
|
|
210
|
+
"letterSpacing": 0,
|
|
211
|
+
"lineHeight": 14,
|
|
212
|
+
},
|
|
213
|
+
undefined,
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
themeIntent="inactive"
|
|
217
|
+
>
|
|
218
|
+
This is a test
|
|
219
|
+
</Text>
|
|
220
|
+
<View
|
|
221
|
+
pointerEvents="box-none"
|
|
222
|
+
position="bottom"
|
|
223
|
+
style={
|
|
224
|
+
[
|
|
225
|
+
{
|
|
226
|
+
"bottom": 0,
|
|
227
|
+
"elevation": 9999,
|
|
228
|
+
"flexDirection": "column-reverse",
|
|
229
|
+
"left": 0,
|
|
230
|
+
"paddingHorizontal": 24,
|
|
231
|
+
"paddingVertical": 16,
|
|
232
|
+
"position": "absolute",
|
|
233
|
+
"right": 0,
|
|
234
|
+
"top": 0,
|
|
235
|
+
},
|
|
236
|
+
undefined,
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
/>
|
|
240
|
+
</View>
|
|
241
|
+
`;
|
|
242
|
+
|
|
195
243
|
exports[`Label has info intent style 1`] = `
|
|
196
244
|
<View
|
|
197
245
|
style={
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
TextStyle,
|
|
7
7
|
} from 'react-native';
|
|
8
8
|
import { StyledLabel } from './StyledLabel';
|
|
9
|
+
import type { TypographyIntent } from '../types';
|
|
9
10
|
|
|
10
11
|
export interface LabelProps extends NativeTextProps {
|
|
11
12
|
/**
|
|
@@ -15,19 +16,7 @@ export interface LabelProps extends NativeTextProps {
|
|
|
15
16
|
/**
|
|
16
17
|
* Visual intent color to apply to the text.
|
|
17
18
|
*/
|
|
18
|
-
intent?:
|
|
19
|
-
| 'body'
|
|
20
|
-
| 'subdued'
|
|
21
|
-
| 'primary'
|
|
22
|
-
| 'secondary'
|
|
23
|
-
| 'success'
|
|
24
|
-
| 'info'
|
|
25
|
-
| 'warning'
|
|
26
|
-
| 'danger'
|
|
27
|
-
| 'inverted'
|
|
28
|
-
| 'archived'
|
|
29
|
-
| 'disabled'
|
|
30
|
-
| 'muted';
|
|
19
|
+
intent?: TypographyIntent;
|
|
31
20
|
/**
|
|
32
21
|
* Additional style.
|
|
33
22
|
*/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import styled from '@emotion/native';
|
|
2
2
|
import { Text } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import type { TypographyIntent } from '../types';
|
|
4
4
|
|
|
5
5
|
type ThemeLevel = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
6
6
|
|
|
7
7
|
const StyledTitle = styled(Text)<{
|
|
8
|
-
themeIntent:
|
|
8
|
+
themeIntent: TypographyIntent;
|
|
9
9
|
themeLevel: ThemeLevel;
|
|
10
10
|
themeTypeface: 'neutral' | 'playful';
|
|
11
11
|
}>(({ themeIntent, themeLevel, theme, themeTypeface: typeface }) => ({
|