IssueRaiser

(addon-controls) Support destructering object properties into individual controls

**Is your feature request related to a problem? Please describe.** Im often passing objects to my (Vue) components which by default will be added as JSON.stringified text control by `@storybook/addon-controls`. As I feel this is confusing/limited functionality (also because the JSON object isnt pretty printed (ie `JSON.stringify(obj, null, 2)`) I'd like to destructure my object properties into separate controls for each individual object property. I have currently implemented this as follows in this stripped-down User example below <details><summary>User.vue</summary> ```js // User.vue <template> <p>The name of the user is: {{ user.name }}</p> </template> <script> export default { props: { user: { type: Object, required: true } } } </script> ``` </details> <details><summary>User.story.js</summary> ```js import User from '../User.vue' export default { title: 'User', component: User, argTypes: { user_name: { control: 'text', defaultValue: 'pimlie', table: { category: 'user', type: { summary: 'text', } } } } } const Template = (args, { argTypes }) => { console.log(argTypes) return { components: { User }, props: Object.keys(argTypes), watch: { user_name: { immediate: true, handler(value) { // use $set to ensure reactivity in case name // prop doesnt exist on this.user yet this.$set(this.user, 'nam

Posted by pimlie on Aug 17, 2020, 11:38 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments

reliability (Other)

(addon-controls) Support destructering object properties into individual controls

pimlieAug 17, 2020, 11:38 AM

**Is your feature request related to a problem? Please describe.** Im often passing objects to my (Vue) components which by default will be added as JSON.stringified text control by `@storybook/addon-controls`. As I feel this is confusing/limited functionality (also because the JSON object isnt pretty printed (ie `JSON.stringify(obj, null, 2)`) I'd like to destructure my object properties into separate controls for each individual object property. I have currently implemented this as follows in this stripped-down User example below <details><summary>User.vue</summary> ```js // User.vue <template> <p>The name of the user is: {{ user.name }}</p> </template> <script> export default { props: { user: { type: Object, required: true } } } </script> ``` </details> <details><summary>User.story.js</summary> ```js import User from '../User.vue' export default { title: 'User', component: User, argTypes: { user_name: { control: 'text', defaultValue: 'pimlie', table: { category: 'user', type: { summary: 'text', } } } } } const Template = (args, { argTypes }) => { console.log(argTypes) return { components: { User }, props: Object.keys(argTypes), watch: { user_name: { immediate: true, handler(value) { // use $set to ensure reactivity in case name // prop doesnt exist on this.user yet this.$set(this.user, 'nam

Comments (0)

No comments yet. Start the discussion.

Comment on this issue