feat: remove old PageTheme provider & add new implemented functionality to provide theme[using ThemeProvider]

This commit is contained in:
Marvin9
2020-10-04 17:58:09 +05:30
parent 5cf3f854d3
commit 26cfd3e2ca
3 changed files with 12 additions and 13 deletions
@@ -15,13 +15,13 @@
*/
import React, { useState } from 'react';
import { customPageTheme } from '@backstage/theme';
import {
Header,
Page,
HeaderLabel,
ContentHeader,
Content,
pageTheme,
InfoCard,
HeaderTabs,
} from '../';
@@ -196,7 +196,7 @@ export const PluginWithData = () => {
const [selectedTab, setSelectedTab] = useState<number>(2);
return (
<div style={{ border: '1px solid #ddd' }}>
<Page theme={pageTheme.tool}>
<Page pageTheme={customPageTheme.pageTheme.tool}>
<ExampleHeader />
<HeaderTabs
selectedIndex={selectedTab}
@@ -218,7 +218,7 @@ export const PluginWithData = () => {
export const PluginWithTable = () => {
return (
<div style={{ border: '1px solid #ddd' }}>
<Page theme={pageTheme.tool}>
<Page pageTheme={customPageTheme.pageTheme.tool}>
<ExampleHeader />
<Content>
<ExampleContentHeader />
+9 -8
View File
@@ -15,10 +15,8 @@
*/
import React, { FC } from 'react';
import { PageTheme, pageTheme } from './PageThemeProvider';
import { makeStyles } from '@material-ui/core';
export const PageThemeContext = React.createContext<PageTheme>(pageTheme.home);
import { customPageTheme, PageTheme } from '@backstage/theme';
import { makeStyles, ThemeProvider } from '@material-ui/core';
const useStyles = makeStyles(() => ({
root: {
@@ -32,14 +30,17 @@ const useStyles = makeStyles(() => ({
}));
type Props = {
theme?: PageTheme;
pageTheme?: PageTheme;
};
export const Page: FC<Props> = ({ theme = pageTheme.home, children }) => {
export const Page: FC<Props> = ({
pageTheme = customPageTheme.pageTheme.home,
children,
}) => {
const classes = useStyles();
return (
<PageThemeContext.Provider value={theme}>
<ThemeProvider theme={{ pageTheme, ...customPageTheme.baseTheme }}>
<div className={classes.root}>{children}</div>
</PageThemeContext.Provider>
</ThemeProvider>
);
};
-2
View File
@@ -15,5 +15,3 @@
*/
export { Page } from './Page';
export { pageTheme } from './PageThemeProvider';
export type { PageTheme } from './PageThemeProvider';