osuresearch / ui

Ohio State Research UI
https://osuresearch.github.io/ui/main
MIT License
6 stars 3 forks source link

Upgrade to Storybook 7 #86

Closed McManning closed 1 year ago

McManning commented 1 year ago

CSF 3 doesn't seem to like my abstraction for RUIComponentMeta.

export const Overview = RUIComponentStory<ButtonProps>((args) => <Button {...args}>Button</Button>);

Nor

const meta = RUIComponentMeta<AdmonitionProps>('Components', Admonition);
export default meta;

Nor

const meta = RUIComponentMeta<AdmonitionProps>('Components', Admonition);
export default { ...meta, title: meta.title };

But this one is fine:

const meta = RUIComponentMeta<AdmonitionProps>('Components', Admonition);
export default { ...meta, title: 'Components / Admonition' };

Looks like there's a relevant SO thread about it as well: https://stackoverflow.com/a/76109337

McManning commented 1 year ago

Looks like it was intentional for performance reasons - see their issue 21703. tl;dr is that it now does static analysis of story files, so dynamic meta's are no longer possible. Really throws a wrench in my configurable meta object that can add the style system props. I'll have to rethink how to enhance this.

McManning commented 1 year ago

To ease migration pain, syntactically I'll do something like:

export default {
  title: 'Components / Admonition',
  ...RUIComponentMeta('Components', Admonition)
};

Global fix is more or less something like:

-export default RUIComponentMeta<\w+>\('(\w+)', (\w+)\).withStyleSystemProps\(\);

+export default {
+  title: '$1 / $2',
+  ...RUIComponentMeta($2).withStyleSystemProps()
+};
McManning commented 1 year ago

MDX tables aren't loaded. Will need the GFM plugin since I believe that was dropped by default when doing the upgrade