Storybook: [docs] PropTypes are not expanded in props table

Created on 17 Mar 2020  路  3Comments  路  Source: storybookjs/storybook

Describe the bug
When I import props enumeration from external file, those values are not expanded in prop types table. Custom defined prop types are not expanded no matter if it's imported from external file or defined in components file.

To Reproduce

Custom PropTypes
*prop-types.js*

import PropTypes from 'prop-types';

export const ButtonVariants = PropTypes.oneOf([
  'primary',
  'secondary',
  'tertiary',
]);

export const ButtonSizes = PropTypes.oneOf([
  'extrasmall',
  'small',
  'medium',
  'large',
]);

Button.jsx

import { ButtonVariants, ButtonSizes } from './prop-types';

...

Button.propTypes = {
  children: PropTypes.node.isRequired,
  variant: ButtonVariants,
  size: ButtonSizes,
  iconClass: PropTypes.string,
  onClick: PropTypes.func,
};

Button.defaultProps = {
  variant: 'primary',
  size: 'medium',
  iconClass: '',
};

Imported props values
*enums.js*

export const VARIANTS = {
  PRIMARY: 'primary',
  SECONDARY: 'secondary',
  TERTIARY: 'tertiary',
};

export const SIZES = {
  EXTRASMALL: 'extrasmall',
  SMALL: 'small',
  MEDIUM: 'medium',
  LARGE: 'large',
};

Button.jsx

import { VARIANTS, SIZES } from './enums';

...

Button.propTypes = {
  children: PropTypes.node.isRequired,
  variant: PropTypes.oneOf(Object.values(VARIANTS)),
  size: PropTypes.oneOf(Object.values(SIZES)),
  iconClass: PropTypes.string,
  onClick: PropTypes.func,
};

Button.defaultProps = {
  variant: VARIANTS.PRIMARY,
  size: SIZES.MEDIUM,
  iconClass: '',
};

Expected behavior
Props table should contain expanded props values
internal-definition

Screenshots
Custom PropTypes
custom-prop-types

Imported props values
enumerations

System:

  System:
    OS: macOS 10.15.3
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
    Yarn: 1.22.0 - /usr/local/bin/yarn
    npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
  Browsers:
    Chrome: 80.0.3987.132
    Safari: 13.0.5
  npmPackages:
    @storybook/addon-actions: ^5.3.17 => 5.3.17
    @storybook/addon-docs: ^5.3.17 => 5.3.17
    @storybook/addon-knobs: ^5.3.17 => 5.3.17
    @storybook/addon-storyshots: ^5.3.17 => 5.3.17
    @storybook/addon-storyshots-puppeteer: ^5.3.17 => 5.3.17
    @storybook/addons: ^5.3.17 => 5.3.17
    @storybook/react: ^5.3.17 => 5.3.17
    @storybook/theming: ^5.3.17 => 5.3.17
docs props bug inactive

All 3 comments

I think this is due to https://github.com/reactjs/react-docgen/pull/352

Please upvote the PR and issue!

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

Was this page helpful?
0 / 5 - 0 ratings