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

Remove storybook-addon-styled-component-theme #10574

Merged
merged 1 commit into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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