Skip to content

Commit

Permalink
feat: adding AntdThemeProvider to storybook config (#29795)
Browse files Browse the repository at this point in the history
  • Loading branch information
rusackas authored Jul 31, 2024
1 parent 0d62bb2 commit da46ad4
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 44 deletions.
5 changes: 3 additions & 2 deletions superset-frontend/.storybook/preview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
import { withJsx } from '@mihkeleidast/storybook-addon-source';
import { supersetTheme, ThemeProvider } from '@superset-ui/core';
import { AntdThemeProvider } from '../src/components/AntdThemeProvider';
import { combineReducers, createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import { Provider } from 'react-redux';
Expand All @@ -35,10 +36,10 @@ const store = createStore(

const themeDecorator = Story => (
<ThemeProvider theme={supersetTheme}>
<>
<AntdThemeProvider>
<GlobalStyles />
<Story />
</>
</AntdThemeProvider>
</ThemeProvider>
);

Expand Down
25 changes: 9 additions & 16 deletions superset-frontend/src/components/Badge/Badge.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
import { AntdThemeProvider } from 'src/components/AntdThemeProvider';
import Badge, { BadgeProps } from '.';

export default {
Expand Down Expand Up @@ -59,11 +58,7 @@ const SIZES = {
defaultValue: undefined,
};

export const InteractiveBadge = (args: BadgeProps) => (
<AntdThemeProvider>
<Badge {...args} />
</AntdThemeProvider>
);
export const InteractiveBadge = (args: BadgeProps) => <Badge {...args} />;

InteractiveBadge.args = {
count: undefined,
Expand Down Expand Up @@ -120,16 +115,14 @@ export const BadgeGallery = () => (
{SIZES.options.map(size => (
<div key={size} style={{ marginBottom: 40 }}>
<h4>{size}</h4>
<AntdThemeProvider>
{COLORS.options.map(color => (
<Badge
count={9}
size={size}
key={`${color}_${size}`}
style={{ marginRight: '15px' }}
/>
))}
</AntdThemeProvider>
{COLORS.options.map(color => (
<Badge
count={9}
size={size}
key={`${color}_${size}`}
style={{ marginRight: '15px' }}
/>
))}
</div>
))}
</>
Expand Down
7 changes: 1 addition & 6 deletions superset-frontend/src/components/Card/Card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
import { AntdThemeProvider } from 'src/components/AntdThemeProvider';
import Card, { CardProps } from '.';

export default {
title: 'Card',
component: Card,
};

export const InteractiveCard = (args: CardProps) => (
<AntdThemeProvider>
<Card {...args} />
</AntdThemeProvider>
);
export const InteractiveCard = (args: CardProps) => <Card {...args} />;

InteractiveCard.args = {
padded: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
import { AntdThemeProvider } from 'src/components/AntdThemeProvider';
import ProgressBar, { ProgressBarProps } from '.';

export default {
Expand All @@ -25,21 +24,15 @@ export default {
};

export const InteractiveProgressBar = (args: ProgressBarProps) => (
<AntdThemeProvider>
<ProgressBar {...args} type="line" />
</AntdThemeProvider>
<ProgressBar {...args} type="line" />
);

export const InteractiveProgressCircle = (args: ProgressBarProps) => (
<AntdThemeProvider>
<ProgressBar {...args} type="circle" />
</AntdThemeProvider>
<ProgressBar {...args} type="circle" />
);

export const InteractiveProgressDashboard = (args: ProgressBarProps) => (
<AntdThemeProvider>
<ProgressBar {...args} type="dashboard" />
</AntdThemeProvider>
<ProgressBar {...args} type="dashboard" />
);

const commonArgs = {
Expand Down
7 changes: 1 addition & 6 deletions superset-frontend/src/components/Tags/Tag.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
import { AntdThemeProvider } from 'src/components/AntdThemeProvider';
import TagType from 'src/types/TagType';
import { Tag } from '.';

export default {
title: 'Tags',
component: Tag,
};
export const InteractiveTag = (args: TagType) => (
<AntdThemeProvider>
<Tag {...args} />
</AntdThemeProvider>
);
export const InteractiveTag = (args: TagType) => <Tag {...args} />;

InteractiveTag.args = {
editable: false,
Expand Down
5 changes: 1 addition & 4 deletions superset-frontend/src/components/Tags/TagsList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/
import TagType from 'src/types/TagType';
import { AntdThemeProvider } from 'src/components/AntdThemeProvider';
import { TagsList } from '.';
import { TagsListProps } from './TagsList';

Expand All @@ -31,9 +30,7 @@ export const InteractiveTagsList = ({
editable,
maxTags,
}: TagsListProps) => (
<AntdThemeProvider>
<TagsList tags={tags} editable={editable} maxTags={maxTags} />
</AntdThemeProvider>
<TagsList tags={tags} editable={editable} maxTags={maxTags} />
);

const tags: TagType[] = [
Expand Down

0 comments on commit da46ad4

Please sign in to comment.