Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show Code is not visible in adddon-docspage #9588

Closed
kvedantmahajan opened this issue Jan 21, 2020 · 3 comments
Closed

Show Code is not visible in adddon-docspage #9588

kvedantmahajan opened this issue Jan 21, 2020 · 3 comments

Comments

@kvedantmahajan
Copy link

kvedantmahajan commented Jan 21, 2020

Problem - No code available after setup in React Typescript setup
Screenshot below

Screenshot 2020-01-22 at 2 07 56 PM

Context - migrating from addon-info to addon-docs

I will quickly share my setup files

main.js

module.exports = {
  // other settings
  stories: ['../src/**/*.stories.(js|tsx|mdx)'],
  addons: [{
      name: '@storybook/addon-docs',
      options: {
        configureJSX: true,
        babelOptions: {},
        sourceLoaderOptions: null
      },
    }]
}

config.js

import { addDecorator } from '@storybook/react';
// import { withInfo } from '@storybook/addon-info';
import { addParameters, configure } from '@storybook/react';
// Can't use knobs in Typescript due to issue - https://github.com/storybookjs/storybook/issues/2964
// import { withKnobs } from "@storybook/addon-knobs";
import { withA11y } from '@storybook/addon-a11y';
import '@storybook/addon-console';
import { withConsole } from '@storybook/addon-console';
import requireContext from 'require-context.macro';
import StoryBookWrapper from "../src/storybook.setup";


// addDecorator(withInfo({
//   	inline: true,
//     styles: {
//       infoStory: {
//         padding: 40
//       }
//     }
// }));

addParameters({
  options: {
    name: "Mint UI",
    url: "https://mint-ui.netlify.com",
    showAddonPanel:false,
    panelPosition: "bottom",
  }
})

// addDecorator(withKnobs);
addDecorator(withA11y);
addDecorator((storyFn, context) => withConsole()(storyFn)(context));

// automatically import all files ending in *.stories.tsx
const req = requireContext('../src/', true, /\.stories\.tsx$/);

function loadStories() {
    req.keys().forEach(req);
}

configure(loadStories, module);

Now, I did try and remove sourceLoaderOptions: null but it didn't make any difference.

Looking into Typescript specific section at https://www.npmjs.com/package/@storybook/addon-docs, didn't offer any help to me either.

Almost missed adding story code

import * as React from "react";
import { storiesOf } from "@storybook/react";
import Avatar from "./index";
import Warning from "../icons/Warning";
import COLORS from "../__utils/colors";

const stories = storiesOf("Avatar", module);

stories.add(
	"size",
	() => (
		<>
			<Avatar size={128} icon="sort" />
			<Avatar size={64} icon="sort" />
			<Avatar size={40} icon="sort" />
			<Avatar size={24} icon="sort" />
		</>
	),
	{
		info: {
			propTables: [Avatar]
		}
	}
);

Please if the docs could be elaborated a bit further for typescript setups for all permutations. Let's say I use awesome-typescript-loader and the setup being in accordance with - https://storybook.js.org/docs/configurations/typescript-config/, will greatly help in reducing time to accomplish the setup. Meanwhile, if you could please suggest a solution.

@kvedantmahajan kvedantmahajan changed the title Show Code is not visible Show Code is not visible in adddon-docspage Jan 21, 2020
@shilman
Copy link
Member

shilman commented Feb 5, 2020

Try chaining your stories:

storiesOf("Avatar", module)
  .add('size', () => (...))
  .add(...)

@stale
Copy link

stale bot commented Feb 27, 2020

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!

@stale stale bot added the inactive label Feb 27, 2020
@kvedantmahajan
Copy link
Author

kvedantmahajan commented Feb 27, 2020

@shilman This works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants