Skip to content

Commit

Permalink
cgra-theming - Better practice
Browse files Browse the repository at this point in the history
  • Loading branch information
BugsBunny338 committed Sep 21, 2021
1 parent 7c3bf18 commit 473e0bb
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions cgra-theming/src/routes/Home.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
import React from "react";
import { InsightView } from "@gooddata/sdk-ui-ext";
import { ThemeProvider, useThemeIsLoading } from "@gooddata/sdk-ui-theme-provider";
import { ThemeProvider, useTheme, useThemeIsLoading } from "@gooddata/sdk-ui-theme-provider";

import Page from "../components/Page";
import customTheme from "../customTheme";

const ThemedHome = () => (
<ThemeProvider theme={customTheme}>
<Home />
</ThemeProvider>
);

const Home = () => {
const themeIsLoading = useThemeIsLoading();
const theme = useTheme();

if (themeIsLoading) {
return <p></p>;
return <p>Loading theme resources</p>;
}

return (
<ThemeProvider theme={customTheme}>
<div style={{ backgroundColor: "var(--gd-palette-complementary-0)" }}>
<Page>
<div style={{ height: 580 }}>
{/* line below renders a column chart create in analytical designer */}
<InsightView insight="aby6oS6DbpFX" />
</div>
</Page>
</div>
</ThemeProvider>
<div style={{ backgroundColor: theme.palette.complementary.c0 }}>
<Page>
<div style={{ height: 580 }}>
{/* line below renders a column chart create in analytical designer */}
<InsightView insight="aby6oS6DbpFX" />
</div>
</Page>
</div>
);
};

export default Home;
export default ThemedHome;

0 comments on commit 473e0bb

Please sign in to comment.