Skip to content

Commit 01cffd2

Browse files
geotrevze-flo
andcommitted
chore: use parent theme callback
Co-authored-by: Florent <ze-flo@users.noreply.github.com>
1 parent eeedb01 commit 01cffd2

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

packages/notifications/src/elements/global-alert/GlobalAlert.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
* found at http://www.apache.org/licenses/LICENSE-2.0.
66
*/
77

8-
import React, { forwardRef, useContext, useMemo } from 'react';
8+
import React, { forwardRef, useMemo } from 'react';
99
import PropTypes from 'prop-types';
10+
import { ThemeProvider } from 'styled-components';
1011
import InfoIcon from '@zendeskgarden/svg-icons/src/16/info-stroke.svg';
1112
import ErrorIcon from '@zendeskgarden/svg-icons/src/16/alert-error-stroke.svg';
1213
import WarningIcon from '@zendeskgarden/svg-icons/src/16/alert-warning-stroke.svg';
@@ -19,8 +20,6 @@ import { GlobalAlertButton } from './GlobalAlertButton';
1920
import { GlobalAlertClose } from './GlobalAlertClose';
2021
import { GlobalAlertContent } from './GlobalAlertContent';
2122
import { GlobalAlertTitle } from './GlobalAlertTitle';
22-
import { DefaultTheme, ThemeContext, ThemeProvider } from 'styled-components';
23-
import { DEFAULT_THEME } from '@zendeskgarden/react-theming';
2423

2524
/**
2625
* 1. Global Alert always renders with light theme colors
@@ -36,15 +35,9 @@ const GlobalAlertComponent = forwardRef<HTMLDivElement, IGlobalAlertProps>(
3635
warning: <WarningIcon />,
3736
info: <InfoIcon />
3837
}[type];
39-
const theme = useContext(ThemeContext) || DEFAULT_THEME;
40-
/* [1] */
41-
const lightTheme: DefaultTheme = useMemo(
42-
() => ({ ...theme, colors: { ...theme.colors, base: 'light' } }),
43-
[theme]
44-
);
4538

4639
return (
47-
<ThemeProvider theme={lightTheme}>
40+
<ThemeProvider theme={theme => ({ ...theme, colors: { ...theme.colors, base: 'light' } })}>
4841
<GlobalAlertContext.Provider value={useMemo(() => ({ type }), [type])}>
4942
{/* [2] */}
5043
{/* eslint-disable-next-line jsx-a11y/prefer-tag-over-role */}

0 commit comments

Comments
 (0)