Skip to content
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

bugfix: add OverlayProvider just once with the MarigoldProvider #1231

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ffa77ec
chore(jest): Update jest to version 27
sebald Jul 2, 2021
7f85798
Merge branch 'jest-major-update-to-27' into main
ti10le Jul 5, 2021
0ed336b
Merge branch 'main' of https://github.com/marigold-ui/marigold into main
ti10le Jul 5, 2021
3a04338
Merge branch 'main' of https://github.com/marigold-ui/marigold into main
ti10le Jul 5, 2021
a643b95
Merge branch 'main' of https://github.com/marigold-ui/marigold into main
ti10le Jul 8, 2021
6fb96ef
Merge branch 'main' of https://github.com/marigold-ui/marigold into main
ti10le Jul 14, 2021
9170315
Merge branch 'main' of https://github.com/marigold-ui/marigold into main
ti10le Jul 15, 2021
d2d4e30
Merge branch 'main' of https://github.com/marigold-ui/marigold into main
ti10le Jul 19, 2021
27c0cad
Merge branch 'main' of https://github.com/marigold-ui/marigold into main
ti10le Jul 21, 2021
9998892
Merge branch 'main' of https://github.com/marigold-ui/marigold into main
ti10le Jul 26, 2021
80f93ab
Merge branch 'main' of https://github.com/marigold-ui/marigold into main
ti10le Jul 28, 2021
8650ef6
Merge branch 'main' of https://github.com/marigold-ui/marigold into main
ti10le Aug 16, 2021
7b8b6ca
Merge branch 'main' of https://github.com/marigold-ui/marigold into main
ti10le Aug 16, 2021
f5262f0
Merge branch 'main' of https://github.com/marigold-ui/marigold into main
ti10le Aug 16, 2021
7c6e234
Merge branch 'main' of https://github.com/marigold-ui/marigold into main
ti10le Aug 19, 2021
e8ad85e
Merge branch 'main' of https://github.com/marigold-ui/marigold into main
ti10le Aug 20, 2021
5adf829
check if OverlayProvider is set
ti10le Aug 24, 2021
db550ef
Create neat-penguins-tap.md
ti10le Aug 24, 2021
3f678aa
Merge branch 'main' of https://github.com/marigold-ui/marigold into f…
ti10le Sep 9, 2021
e62a722
Merge branch 'fix-overlay-provider' of https://github.com/marigold-ui…
ti10le Sep 9, 2021
26f289c
use proper theme and context values
viktoria-schwarz Sep 9, 2021
9ea44e1
merge
viktoria-schwarz Sep 9, 2021
cfc8288
OverlayProvider and GlobalStyles once
viktoria-schwarz Sep 9, 2021
99cf053
Merge branch 'main' into fix-overlay-provider
viktoria-schwarz Sep 9, 2021
a886565
Merge branch 'fix-overlay-provider' of https://github.com/marigold-ui…
ti10le Sep 9, 2021
64d88a0
Merge branch 'main' of https://github.com/marigold-ui/marigold into f…
ti10le Sep 9, 2021
4179314
fix Provider problem
ti10le Sep 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-penguins-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@marigold/components": patch
---

bugfix: add OverlayProvider just once with the MarigoldProvider
34 changes: 29 additions & 5 deletions packages/components/src/Provider/MarigoldProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
import React from 'react';
import { OverlayProvider } from '@react-aria/overlays';
import { ThemeProvider, ThemeProviderProps, useTheme } from '@marigold/system';
import {
Theme,
ThemeProvider,
ThemeProviderProps,
useTheme,
} from '@marigold/system';
import { Global } from '@emotion/react';


interface ThemeContextValue {
theme: Theme;
}

const defaultThemeValue: ThemeContextValue = {
theme: {},
};

/**
* @internal
*/
const __MarigoldContext = React.createContext(
defaultThemeValue
)

const useMarigoldTheme = () => React.useContext(__MarigoldContext)

const GlobalStyles = () => {
const { css } = useTheme();
const styles = css({
Expand All @@ -17,12 +40,13 @@ export const MarigoldProvider: React.FC<ThemeProviderProps> = ({
theme,
children,
}) => {
const outerTheme = useMarigoldTheme();
const isTopLevel = outerTheme === defaultThemeValue

return (
<ThemeProvider theme={theme}>
<OverlayProvider>
<GlobalStyles />
{children}
</OverlayProvider>
{isTopLevel && <GlobalStyles />}
<OverlayProvider>{children}</OverlayProvider>
viktoria-schwarz marked this conversation as resolved.
Show resolved Hide resolved
</ThemeProvider>
);
};