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

Controls not automatically generated for Single File Components #46

Closed
andrewcourtice opened this issue Jun 25, 2021 · 5 comments
Closed

Comments

@andrewcourtice
Copy link
Contributor

Hi

Thanks so much for writing this builder for Storybook! Being able to use Vite is so much better!

I am having an issue with getting controls to automatically generate for single file components though.

I have followed the setup guide for getting started using Storybook with Vue 3, Vite and TypeScript. Everything is running ok except I cannot get my story to automatically generate controls (or source) based on the components props.

I've had controls configured using the argTypes property but as far as I am aware Storybook should be able to generate these out of the box based on the components props?

I have been hunting through documentation and addons but can't find anything. Any help would be much appreciated.

Here is my current setup:

Storybook Packages:

  • "@babel/core": "^7.14.6"
  • "@storybook/addon-actions": "^6.3.0"
  • "@storybook/addon-essentials": "^6.3.0"
  • "@storybook/addon-links": "^6.3.0"
  • "@storybook/vue3": "^6.3.0"
  • "babel-loader": "^8.2.2"
  • "storybook-builder-vite": "^0.0.9"
  • "typescript": "^4.3.2"

main.js:

module.exports = {
    "stories": [
        "../src/**/*.stories.mdx",
        "../src/**/*.stories.@(js|jsx|ts|tsx)"
    ],
    "addons": [
        "@storybook/addon-links",
        "@storybook/addon-essentials"
    ],
    "core": {
        "builder": "storybook-builder-vite"
    }
};

preview.js:

export const parameters = {
    actions: {
        argTypesRegex: "^on[A-Z].*"
    },
    controls: {
        expanded: true,
        matchers: {
            color: /(background|color)$/i,
            date: /Date$/,
        },
    },
};

The source component props:

props: {

    /**
        * The unique id of this dropdown panel
    */
    id: {
        type: String,
        default: () => stringUniqueId(6),
    },

    /**
        * Where the dropdown panel originates from.
        * This could also be described as it's anchor point.
    */
    origin: {
        type: String as PropType<Origin>,
        default: 'bottom-centre',
    },

    /**
    * A boolean indicating whether this dropdown panel should be teleported
    */
    teleport: {
        type: Boolean,
        default: false,
    },

    /**
    * A boolean indicating whether the panel should automatically
    * close when an item within the panel is clicked.
    */
    autoClose: {
        type: Boolean,
        default: true,
    },

    /**
        * A value indicating how autofocus should behave within the panel
    */
    autoFocus: {
        type: [Boolean, String],
        default: 'input[type="text"]|[active]|:focusable',
    },

    /**
        * A value indicating whether the dropdown panel should automatically trap focus upon opening
    */
    focusTrap: {
        type: Boolean,
        default: true,
    },

},

The story for this component:

import DropdownPanel from '../../components/dropdown-panel/dropdown-panel.vue';

import template from './templates/default.html?raw';
import hero from '../_base/decorators/hero';

import {
    Meta,
    Story,
} from '@storybook/vue3';

export default {
    title: 'Dropdown Panel',
    component: DropdownPanel,
    decorators: [ hero ],
} as Meta;

const Component: Story = args => ({

    template,

    components: {
        DropdownPanel,
    },

    setup() {
        return {
            args,
        };
    },

});

export const Basic = Component.bind({});

Screenshot showing no controls:
storybook

Am I missing something completely obvious?

@shilman
Copy link
Member

shilman commented Jun 28, 2021

FYI, we are currently in the process of rearchitecting Storybook (as part of 6.4/7.0) to make the docgen generation decoupled from webpack. I don't have a timeline available yet, but should be able to share more about the project in the next couple weeks.

@andrewcourtice
Copy link
Contributor Author

@shilman - That's great news, thanks for letting me know 😄

Where would be the best place to get updates on the progress of the re-architecture? The GitHub repo, StoryBook blog?

@eirslett
Copy link
Collaborator

This should be fixed in #47 .

@jmorrice
Copy link

I'm having the same issue for React using Typescript. It looks like #47 adds a vue plugin, will there be something similar for React?

@IanVS
Copy link
Member

IanVS commented Jan 14, 2022

There is an experiment in #190, but it does not have all of the features that some might want.

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

Successfully merging a pull request may close this issue.

5 participants