Repository navigation
fix(menu, banner)!: use surfaceContainer roles for background #5121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b630681
a58698d
9607a6a
a61aeb7
28410ed
ff1480f
d4d99d0
1b35f1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,9 +123,11 @@ Components no longer read values from the `style` prop to derive other styles, s | |
|
|
||
| - `Appbar` and `Appbar.Header`: `backgroundColor` and the border radius props (`borderRadius`, `borderTopLeftRadius` etc.) replace `style.backgroundColor` and the border radius in `style` | ||
| - `Avatar.Icon`, `Avatar.Image` and `Avatar.Text`: `backgroundColor` replaces `style.backgroundColor` | ||
| - `Banner`: `backgroundColor` replaces `style.backgroundColor` | ||
| - `Button`: `iconSize` replaces `labelStyle.fontSize` for the size of the icon and the loading indicator | ||
| - `Button`: `textColor` replaces `labelStyle.color` for the color of the icon and the loading indicator | ||
| - `Card`: `borderColor` replaces `style.borderColor` for the outline color | ||
| - `Menu`: `backgroundColor` replaces `contentStyle.backgroundColor` | ||
|
|
||
| `Tooltip` no longer reads positioning styles from the wrapped element. Apply them to a parent `View` wrapping the `Tooltip`, see [Tooltip](#tooltip). | ||
|
|
||
|
|
@@ -637,6 +639,24 @@ e.g.: | |
| + </View> | ||
| ``` | ||
|
|
||
| ### Banner | ||
|
|
||
| The banner background is now `theme.colors.surfaceContainerLow` by default and no longer depends on the `elevation` prop, which only controls the shadow. If you customized `theme.colors.elevation.level1` to change the banner background, customize `theme.colors.surfaceContainerLow` instead. With `LightTheme` and `DarkTheme`, the rendered color at the default `elevation` of `1` is unchanged. A banner with `elevation={0}` is no longer transparent. With `DynamicLightTheme` and `DynamicDarkTheme` on Android 12 and newer, the banner now uses the system surface color. To change the background of a single banner, use the new `backgroundColor` prop. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From reading |
||
|
|
||
| ```diff | ||
| const theme = { | ||
| ...LightTheme, | ||
| colors: { | ||
| ...LightTheme.colors, | ||
| - elevation: { | ||
| - ...LightTheme.colors.elevation, | ||
| - level1: '#ffd8e4', | ||
| - }, | ||
| + surfaceContainerLow: '#ffd8e4', | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| ### Surface | ||
|
|
||
| - The `elevation` prop no longer accepts a React Native `Animated.Value`. Any `elevation` changes are animated automatically. | ||
|
|
@@ -972,6 +992,22 @@ If your 5.x style set its own `gap`, drop `columnGap` from the copied style or s | |
|
|
||
| ### Menu | ||
|
|
||
| The menu background is now `theme.colors.surfaceContainer` by default, following the Material Design 3 spec, and no longer depends on the `elevation` prop, which only controls the shadow. If you customized `theme.colors.elevation.level2` to change the menu background, customize `theme.colors.surfaceContainer` instead. With `LightTheme` and `DarkTheme`, the rendered color at the default `elevation` of `2` is unchanged. A menu with `elevation={0}` is no longer transparent. With `DynamicLightTheme` and `DynamicDarkTheme` on Android 12 and newer, the menu now uses the system surface color. To change the background of a single menu, use the new `backgroundColor` prop. | ||
|
|
||
| ```diff | ||
| const theme = { | ||
| ...LightTheme, | ||
| colors: { | ||
| ...LightTheme.colors, | ||
| - elevation: { | ||
| - ...LightTheme.colors.elevation, | ||
| - level2: '#ffd8e4', | ||
| - }, | ||
| + surfaceContainer: '#ffd8e4', | ||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| The `overlayAccessibilityLabel` prop was renamed to `dismissAccessibilityLabel`: | ||
|
|
||
| ```diff | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,8 +13,9 @@ import { act } from '@testing-library/react-native'; | |
| import * as Reanimated from 'react-native-reanimated'; | ||
|
|
||
| import PaperProvider from '../../core/PaperProvider'; | ||
| import { render } from '../../test-utils'; | ||
| import { render, screen } from '../../test-utils'; | ||
| import { LightTheme } from '../../theme/schemes'; | ||
| import { Palette } from '../../theme/tokens'; | ||
| import type { Theme } from '../../theme/types'; | ||
| import Banner from '../Banner'; | ||
|
|
||
|
|
@@ -121,6 +122,30 @@ it('renders visible banner, with action buttons and with image', async () => { | |
| expect(tree).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('renders banner on the theme surface container background', async () => { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test passes on main too - default |
||
| await render( | ||
| <Banner visible testID="banner"> | ||
| Text | ||
| </Banner> | ||
| ); | ||
|
|
||
| expect(screen.getByTestId('banner')).toHaveStyle({ | ||
| backgroundColor: LightTheme.colors.surfaceContainerLow, | ||
| }); | ||
| }); | ||
|
|
||
| it('renders banner with a custom background color', async () => { | ||
| await render( | ||
| <Banner visible testID="banner" backgroundColor={Palette.error60}> | ||
| Text | ||
| </Banner> | ||
| ); | ||
|
|
||
| expect(screen.getByTestId('banner')).toHaveStyle({ | ||
| backgroundColor: Palette.error60, | ||
| }); | ||
| }); | ||
|
|
||
| it('render visible banner, with custom theme', async () => { | ||
| const tree = ( | ||
| await render( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noticed that after the merge with main we'll have two Banner sections - this one and the one at line 612 from #5016. Could we move it under the existing one?