Skip to content

Commit

Permalink
feat: ThemeProvider revisited!
Browse files Browse the repository at this point in the history
and removed completely!
We don't need it anymore!
  • Loading branch information
ggdaltoso committed Mar 3, 2024
1 parent eb6a76f commit 233e3aa
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 80 deletions.
4 changes: 2 additions & 2 deletions packages/core/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Frame from './decorators/Frame';
import { withThemes } from './src/theme-changer/withThemes';

import './preview.css';
import { withModal } from './src/theme-changer/decorators';

export const globalTypes = {
selectedTheme: {
Expand All @@ -11,4 +11,4 @@ export const globalTypes = {
},
};

export const decorators = [Frame, withThemes];
export const decorators = [Frame, withModal];
5 changes: 2 additions & 3 deletions packages/core/.storybook/src/clippy-addon/register.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { createGlobalStyle } from 'styled-components';

import { Modal } from '../../../components/Modal';
import List from '../../../components/List';
import ThemeProvider from '../../../components/ThemeProvider';
import TextArea from '../../../components/TextArea';

const ClippyStyle = createGlobalStyle`
Expand Down Expand Up @@ -209,7 +208,7 @@ class Clippy extends React.Component {
].join('\n');

return (
<ThemeProvider>
<>
<ClippyStyle />
{showModal && (
<Modal
Expand Down Expand Up @@ -267,7 +266,7 @@ class Clippy extends React.Component {
/>
</Modal>
)}
</ThemeProvider>
</>
);
}
}
Expand Down
8 changes: 8 additions & 0 deletions packages/core/.storybook/src/theme-changer/decorators.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as React from 'react';
import { ModalProvider } from '../../../components/Modal';

export const withModal = (Story, context) => (
<ModalProvider>
<Story {...context} />
</ModalProvider>
);
40 changes: 0 additions & 40 deletions packages/core/.storybook/src/theme-changer/src/extractThemes.js

This file was deleted.

8 changes: 0 additions & 8 deletions packages/core/.storybook/src/theme-changer/withThemes.jsx

This file was deleted.

9 changes: 0 additions & 9 deletions packages/core/components/ThemeProvider/ThemeProvider.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions packages/core/components/ThemeProvider/index.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/core/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import TextArea from './TextArea';
import Tree from './Tree';
import Tooltip from './Tooltip';
import TitleBar from './TitleBar';
import ThemeProvider from './ThemeProvider';
import Video from './Video';

export {
Expand All @@ -46,6 +45,5 @@ export {
Tree,
Tooltip,
TitleBar,
ThemeProvider,
Video,
};
15 changes: 2 additions & 13 deletions packages/core/components/shared/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,14 @@ import {
RenderOptions,
RenderResult,
act,
cleanup,
render,
} from '@testing-library/react';
import ThemeProvider from '../../ThemeProvider';

const customRender = (
ui: React.ReactElement,
options?: Omit<RenderOptions, 'queries'>,
) => {
cleanup();

return render(ui, { wrapper: ThemeProvider, ...options });
};

const waitRender = async (
ui: React.ReactElement,
options?: Omit<RenderOptions, 'queries'>,
): Promise<RenderResult> => {
const { container, ...rest } = customRender(ui, options);
const { container, ...rest } = render(ui, options);

await act(async () => {
await Promise.resolve(container);
Expand All @@ -31,4 +20,4 @@ const waitRender = async (

export * from '@testing-library/react';

export { customRender as render, waitRender };
export { render, waitRender };

0 comments on commit 233e3aa

Please sign in to comment.