Skip to content

Commit

Permalink
chore(new-hope): resolved "No longer inferring default values of args"
Browse files Browse the repository at this point in the history
`argType.defaultValue` is deprecated and will be removed in Storybook 7.0.
  • Loading branch information
Yakutoc committed Nov 14, 2023
1 parent 57effef commit 9e4698e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/plasma-new-hope/src/examples/_helpers.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ArgTypes, StoryContext, Story as StoryType } from '@storybook/react';
import React from 'react';
import type { ArgTypes, StoryContext, Decorator } from '@storybook/react';

import { ComponentConfig } from '../engines';
import type { HTMLTagList, PropsType, Variants } from '../engines/types';

import { ThemeType, themes } from './themes';

export const WithTheme = (Story: StoryType, context: StoryContext) => {
export const WithTheme: Decorator = (Story, context: StoryContext) => {
const themeType = context.globals.theme as keyof ThemeType;
const themeName = context.title.split('/')[0];

Expand All @@ -32,21 +32,28 @@ export function argTypesFromConfig<
const filteredVariations = Object.entries(variations).filter(([key]) => !exclude.includes(key));

const argTypes: ArgTypes = {};

for (const [key, val] of filteredVariations) {
const control: ArgTypes[''] = {
control: {},
};

if (val.true) {
control.control.type = 'boolean';
control.defaultValue = false;
control.table = { defaultValue: { summary: false } };
} else {
control.control.type = 'select';
control.options = Object.keys(val).filter((name) => name !== 'css');
}

const defaultValue = defaults[key];

if (defaultValue) {
control.defaultValue = val.true ? Boolean(defaultValue) : defaultValue;
control.table = {
defaultValue: {
summary: val.true ? Boolean(defaultValue) : defaultValue,
},
};
}

argTypes[key] = control;
Expand Down

0 comments on commit 9e4698e

Please sign in to comment.