Skip to content

Commit

Permalink
Remove storybook-addon-styled-component-theme (#10574)
Browse files Browse the repository at this point in the history
  • Loading branch information
timroes authored Feb 23, 2022
1 parent 10f17ef commit 62cbdfb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 366 deletions.
1 change: 0 additions & 1 deletion airbyte-webapp/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = {
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/preset-create-react-app",
"storybook-addon-styled-component-theme/dist",
],
webpackFinal: (config) => {
config.resolve.modules.push(process.cwd() + "/node_modules");
Expand Down
6 changes: 2 additions & 4 deletions airbyte-webapp/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { addDecorator } from "@storybook/react";
import { withThemesProvider } from "storybook-addon-styled-component-theme";

import WithProviders from "./withProvider";
import { theme } from "../src/theme";
import { withProviders } from "./withProvider";

addDecorator(withThemesProvider([theme], WithProviders));
addDecorator(withProviders);

export const parameters = {};
58 changes: 20 additions & 38 deletions airbyte-webapp/.storybook/withProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,32 @@
import { MemoryRouter } from "react-router-dom";
import * as React from "react";
import { IntlProvider } from "react-intl";
// import { createMemoryHistory } from "history";
import { ThemeProvider } from "styled-components";

// TODO: theme was not working correctly so imported directly
import { theme, Theme } from "../src/theme";
import { theme } from "../src/theme";
import GlobalStyle from "../src/global-styles";
import messages from "../src/locales/en.json";
import { FeatureService } from "../src/hooks/services/Feature";
import { ConfigServiceProvider, defaultConfig } from "../src/config";
import { ServicesProvider } from "../src/core/servicesProvider";

interface Props {
theme?: Theme;
}

interface Props {
children?: React.ReactNode;
theme?: Theme;
}

class WithProviders extends React.Component<Props> {
render() {
const { children } = this.props;

return (
<ServicesProvider>
<MemoryRouter>
<IntlProvider messages={messages} locale={"en"}>
<ThemeProvider theme={theme}>
<ConfigServiceProvider
defaultConfig={defaultConfig}
providers={[]}
>
<FeatureService>
<GlobalStyle />
{children}
</FeatureService>
</ConfigServiceProvider>
</ThemeProvider>
</IntlProvider>
</MemoryRouter>
</ServicesProvider>
);
}
}

export default WithProviders;
export const withProviders = (getStory) => (
<ServicesProvider>
<MemoryRouter>
<IntlProvider messages={messages} locale={"en"}>
<ThemeProvider theme={theme}>
<ConfigServiceProvider
defaultConfig={defaultConfig}
providers={[]}
>
<FeatureService>
<GlobalStyle />
{getStory()}
</FeatureService>
</ConfigServiceProvider>
</ThemeProvider>
</IntlProvider>
</MemoryRouter>
</ServicesProvider>
);
Loading

0 comments on commit 62cbdfb

Please sign in to comment.