Skip to content

Commit e7108ca

Browse files
committed
feat(popover): propagate the theme props to its children
1 parent 7d85e7a commit e7108ca

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
- `ThemeProvider` & `useTheme`: add context util to facilitate propagation of theme.
12+
- `ThemeProvider` & `useTheme`: add context util to facilitate propagation of theme
13+
- `Popover`: dark theme prop applies to all children via the theme context
1314

1415
## [3.10.0][] - 2025-01-16
1516

packages/lumx-core/src/scss/components/popover/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363

6464
&--theme-dark {
6565
background: lumx-color-variant("dark", "N");
66+
color: lumx-color-variant("light", "N");
6667

6768
#{$self}__arrow {
6869
fill: lumx-color-variant("dark", "N");

packages/lumx-react/src/components/popover/Popover.test.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,13 @@ describe(`<${Popover.displayName}>`, () => {
5151
forwardClassName: 'element',
5252
forwardAttributes: 'element',
5353
applyTheme: {
54-
affects: [{ element: 'element' }, { not: { element: 'themeSentinel' } }],
54+
affects: [
55+
{ element: 'element' },
56+
// Theme automatically transferred to the children
57+
{ element: 'themeSentinel' },
58+
],
5559
viaProp: true,
60+
// Parent context does not affect the popover
5661
viaContext: false,
5762
},
5863
});

packages/lumx-react/src/components/popover/Popover.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ const _InnerPopover = forwardRef<PopoverProps, HTMLDivElement>((props, ref) => {
181181
</svg>
182182
</div>
183183
)}
184-
<ThemeProvider value={undefined}>{children}</ThemeProvider>
184+
<ThemeProvider value={theme}>{children}</ThemeProvider>
185185
</ClickAwayProvider>
186186
</Component>,
187187
usePortal,

packages/site-demo/content/product/foundations/light-dark-theme/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ Use the `ThemeProvider` component to apply the desired theme to all descendants
3838
</DemoBlock>
3939

4040
Please note **some exceptions** to the theme context propagation:
41-
- The `Popover` ignores the theme context for now because most children that we put inside do not support the `dark` theme (List & ListItem)
42-
- The components `Popover`, `Lightbox` and `Dialog` all stop the propagation of the theme context and reset the theme because their children won't appear on the same background from where they are called
41+
- The components `Popover`, `Lightbox` and `Dialog` all ignore the parent theme context and reset the theme because their children won't appear on the same background from where they are called
42+
- However, the `Popover` takes the given `theme` props and propagates to its items via the context
4343

4444
Use the `useTheme()` hook to get the theme from the current theme context when you need to adapt within your custom component.
4545

0 commit comments

Comments
 (0)