Skip to content

Commit c4824f1

Browse files
Merge branch 'main' into feat/refactor-icon-button-component
Co-authored-by: Cursor <cursoragent@cursor.com>
2 parents 0a40a7d + 84fdd8e commit c4824f1

90 files changed

Lines changed: 21708 additions & 2218 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/6.x/docs/guides/fonts.md‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ Platform.select({
6767
}),
6868
```
6969
70+
Material Design 3 typescale uses two font families:
71+
72+
- **Brand**: Display, Headline and Title Large
73+
- **Plain**: Title Medium/Small, Label and Body
74+
75+
The default theme uses the platform default for both font families.
76+
7077
:::
7178
7279
- #### Display
@@ -291,14 +298,29 @@ Platform.select({
291298
"fontFamily": "Font",
292299
"fontSize": 16,
293300
"fontWeight": "400",
294-
"letterSpacing": 0.15,
301+
"letterSpacing": 0.5,
295302
"lineHeight": 24,
296303
}
297304
```
298305
299306
</div>
300307
</div>
301308
309+
- #### Emphasized
310+
311+
Each variant also has an `Emphasized` counterpart with a heavier font weight: `displayLargeEmphasized`,
312+
`bodyMediumEmphasized` etc.
313+
314+
```json
315+
"bodyMediumEmphasized": {
316+
"fontFamily": "Font",
317+
"fontSize": 14,
318+
"fontWeight": "500",
319+
"letterSpacing": 0.25,
320+
"lineHeight": 20,
321+
}
322+
```
323+
302324
:::info
303325
If any component uses Paper's `Text` component, without specified <b>variant</b>, then `default` variant is applied:
304326

‎docs/6.x/docs/guides/migration.md‎

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -71,61 +71,41 @@ You can use the component's color prop where available, or override the correspo
7171

7272
### Test IDs
7373

74-
Hardcoded default test IDs have been removed for the components listed below. Many of these components also derive test IDs for their internal parts by appending a suffix to the `testID` prop (e.g. `${testID}-container`). Since `testID` is no longer defaulted to a hardcoded value, none of these derived test IDs are set either unless you pass a `testID` explicitly — so all queries by the IDs below will stop matching:
74+
Hardcoded default test IDs have been removed for the components listed below:
7575

7676
- `Appbar.Content`: `appbar-content`
77-
- `appbar-content-title-text`
7877
- `Appbar.Header`: `appbar-header`
79-
- `appbar-header-root-layer`
8078
- `BottomNavigation`: `bottom-navigation`
81-
- `bottom-navigation-bar`
8279
- `BottomNavigation.Bar`: `bottom-navigation-bar`
83-
- `bottom-navigation-bar-content`
84-
- `bottom-navigation-bar-content-wrapper`
8580
- `Button`: `button`
86-
- `button-container`
87-
- `button-icon-container`
88-
- `button-text`
8981
- `Card`: `card`
90-
- `card-container`
91-
- `card-outline`
9282
- `Chip`: `chip`
93-
- `chip-container`
9483
- `Drawer.CollapsedItem`: `drawer-collapsed-item`
95-
- `drawer-collapsed-item-outline`
96-
- `drawer-collapsed-item-container`
9784
- `FAB`: `floating-action-button`
98-
- `floating-action-button-container`
99-
- `floating-action-button-text`
10085
- `FAB.Extended`: `extended-floating-action-button`
101-
- `extended-floating-action-button-container`
102-
- `extended-floating-action-button-text`
10386
- `FAB.Menu`: `floating-action-button-menu`
10487
- `IconButton`: `icon-button`
105-
- `icon-button-container`
106-
- `icon-button-icon` (and `icon-button-icon-previous` / `icon-button-icon-current` when `animated`)
10788
- `Menu`: `menu`
108-
- `menu-view`
109-
- `menu-surface`
11089
- `Menu.Item`: `menu-item`
111-
- `menu-item-title`
11290
- `Modal`: `modal`
113-
- `modal-backdrop`
114-
- `modal-wrapper`
115-
- `modal-surface`
11691
- `ProgressBar`: `progress-bar`
117-
- `progress-bar-fill`
11892
- `Searchbar`: `search-bar`
119-
- `search-bar-container`
120-
- `search-bar-icon`
121-
- `search-bar-icon-wrapper`
122-
- `search-bar-clear-icon`
123-
- `search-bar-trailering-icon`
124-
- `search-bar-divider`
12593
- `Surface`: `surface`
126-
- `surface-outer-layer`
12794

128-
You can specify a `testID` explicitly to restore both the component's own test ID and all of its derived test IDs above, using the same suffixes.
95+
You can specify a `testID` explicitly to restore each component's own test ID.
96+
97+
These components used to also derive test IDs for internal, implementation-only elements by appending a suffix to the `testID` prop (e.g. `${testID}-container`, `${testID}-icon`, `${testID}-outline`). They have been removed entirely.
98+
99+
If you were relying on internal test IDs, update your tests not to rely on internal implementation details and only interact with elements or assert content your users can reach, e.g.: query by role, label, text etc., or `testID` props accepted by the component.
100+
101+
Some components now accept explicit `testID` props for their interactable elements:
102+
103+
- `BottomNavigation`: `barTestID` for the internal `BottomNavigation.Bar`, replacing the previous `${testID}-bar` derivation.
104+
- `Chip`: `closeIconTestID` for the close icon button.
105+
- `Dialog` and `Modal`: `overlayTestID` for the overlay displayed behind the content.
106+
- `Menu`: `overlayTestID` for the overlay displayed behind the menu.
107+
- `Searchbar`: `searchTestID`, `clearTestID`, and `trailingTestID` for the search, clear, and trailing icon buttons.
108+
- `Snackbar`: `iconTestID` for the icon button.
129109

130110
## Components
131111

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"dependencies": {
5151
"@callstack/react-theme-provider": "^3.0.9",
5252
"color": "^3.1.2",
53+
"fast-deep-equal": "^3.1.3",
5354
"use-latest-callback": "^0.2.3"
5455
},
5556
"devDependencies": {

‎src/components/Appbar/AppbarContent.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ const AppbarContent = ({
135135
numberOfLines={1}
136136
accessible
137137
role={onPress ? 'none' : 'heading'}
138-
testID={testID ? `${testID}-title-text` : undefined}
139138
maxFontSizeMultiplier={titleMaxFontSizeMultiplier}
140139
>
141140
{title}

‎src/components/BottomNavigation/BottomNavigation.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ export type Props<Route extends BaseRoute> = {
252252
* TestID used for testing purposes
253253
*/
254254
testID?: string;
255+
/**
256+
* testID for the underlying `BottomNavigation.Bar`.
257+
*/
258+
barTestID?: string;
255259
};
256260

257261
const FAR_FAR_AWAY = Platform.OS === 'web' ? 0 : 9999;
@@ -336,6 +340,7 @@ const BottomNavigation = <Route extends BaseRoute>({
336340
labelMaxFontSizeMultiplier = 1,
337341
compact: compactProp,
338342
testID,
343+
barTestID,
339344
theme: themeOverrides,
340345
getLazy = ({ route }: { route: Route }) => route.lazy,
341346
}: Props<Route>) => {
@@ -579,7 +584,7 @@ const BottomNavigation = <Route extends BaseRoute>({
579584
safeAreaInsets={safeAreaInsets}
580585
labelMaxFontSizeMultiplier={labelMaxFontSizeMultiplier}
581586
compact={compact}
582-
testID={testID ? `${testID}-bar` : undefined}
587+
testID={barTestID}
583588
theme={theme}
584589
/>
585590
</View>

‎src/components/BottomNavigation/BottomNavigationBar.tsx‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,7 @@ const BottomNavigationBar = <Route extends BaseRoute>({
493493
]}
494494
onLayout={onLayout}
495495
>
496-
<Animated.View
497-
style={[styles.barContent, { backgroundColor }]}
498-
testID={testID ? `${testID}-content` : undefined}
499-
>
496+
<Animated.View style={[styles.barContent, { backgroundColor }]}>
500497
<View
501498
style={[
502499
styles.items,
@@ -509,7 +506,6 @@ const BottomNavigationBar = <Route extends BaseRoute>({
509506
},
510507
]}
511508
role={'tablist'}
512-
testID={testID ? `${testID}-content-wrapper` : undefined}
513509
>
514510
{routes.map((route, index) => {
515511
const focused = navigationState.index === index;

‎src/components/Button/Button.tsx‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ const Button = ({
292292
<Surface
293293
{...rest}
294294
ref={ref}
295-
testID={testID ? `${testID}-container` : undefined}
296295
backgroundColor={backgroundOpacity < 1 ? 'transparent' : backgroundColor}
297296
{...touchableStyle}
298297
style={[
@@ -342,10 +341,7 @@ const Button = ({
342341
>
343342
<View style={[styles.content, { opacity: textOpacity }, contentStyle]}>
344343
{icon && loading !== true ? (
345-
<View
346-
style={iconStyle}
347-
testID={testID ? `${testID}-icon-container` : undefined}
348-
>
344+
<View style={iconStyle}>
349345
<Icon
350346
source={icon}
351347
size={customLabelSize ?? iconSize}
@@ -372,7 +368,6 @@ const Button = ({
372368
variant="labelLarge"
373369
selectable={false}
374370
numberOfLines={1}
375-
testID={testID ? `${testID}-text` : undefined}
376371
style={[
377372
styles.label,
378373
isMode('text')

‎src/components/Card/Card.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ const Card = ({
204204
const borderRadius = theme.shapes.corner.medium;
205205

206206
const content = (
207-
<View style={[styles.innerContainer, contentStyle]} testID={testID}>
207+
<View style={[styles.innerContainer, contentStyle]}>
208208
{React.Children.map(children, (child, index) =>
209209
React.isValidElement(child)
210210
? React.cloneElement(child as React.ReactElement<any>, {
@@ -225,13 +225,12 @@ const Card = ({
225225
style={[{ borderColor }, style]}
226226
theme={theme}
227227
elevation={elevation}
228-
testID={testID ? `${testID}-container` : undefined}
228+
testID={hasPassedTouchHandler ? undefined : testID}
229229
{...rest}
230230
>
231231
{isMode('outlined') && (
232232
<View
233233
pointerEvents="none"
234-
testID={testID ? `${testID}-outline` : undefined}
235234
style={[
236235
{
237236
borderColor,
@@ -252,6 +251,7 @@ const Card = ({
252251
onPress={onPress}
253252
onPressIn={handlePressIn}
254253
onPressOut={handlePressOut}
254+
testID={testID}
255255
>
256256
{content}
257257
</Pressable>

‎src/components/Card/CardContent.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export type Props = ViewProps & {
4343
* ```
4444
*/
4545
const CardContent = ({ index, total, siblings, style, ...rest }: Props) => {
46-
const cover = 'withInternalTheme(CardCover)';
47-
const title = 'withInternalTheme(CardTitle)';
46+
const cover = 'Card.Cover';
47+
const title = 'Card.Title';
4848

4949
let contentStyle, prev, next;
5050

‎src/components/Card/CardTitle.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ export type Props = ViewProps & {
102102
* @optional
103103
*/
104104
theme?: ThemeProp;
105+
/**
106+
* testID to be used on tests.
107+
*/
108+
testID?: string;
105109
};
106110

107111
const LEFT_SIZE = 40;
@@ -143,14 +147,15 @@ const CardTitle = ({
143147
rightStyle,
144148
style,
145149
theme: themeOverrides,
150+
testID,
146151
}: Props) => {
147152
useInternalTheme(themeOverrides);
148153

149154
const minHeight = subtitle || left || right ? 72 : 50;
150155
const marginBottom = subtitle ? 0 : 2;
151156

152157
return (
153-
<View style={[styles.container, { minHeight }, style]}>
158+
<View style={[styles.container, { minHeight }, style]} testID={testID}>
154159
{left ? (
155160
<View style={[styles.left, leftStyle]}>
156161
{left({

0 commit comments

Comments
 (0)