question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Storybook withClassPropertiesKnobs only exports the first element in the template

See original GitHub issue

Using the withClassPropertiesKnobs function only returns the first element in the template. This prevents developers from passing a custom-element with a HTML element to interact with the custom-element.

The first element is selected here and eventually returned here. Shouldn’t the whole wrapper be returned with only the custom-element in it replaced with applied knobs?

Example on what I was trying to do:

import {storiesOf, html, withKnobs, withClassPropertiesKnobs, select} from '@open-wc/demoing-storybook';
import {DraggableDrawer} from "./draggable-drawer";

storiesOf('Core UI', module)
  .addDecorator(withKnobs)
  .add(
    'Dragable Drawer Top',
    () => withClassPropertiesKnobs(DraggableDrawer, {
      overrides: el => [
        {
          key: 'align',
          fn: () => select('align', ['left', 'right','top','bottom'], el.align, 'Inherited'),
        }
      ],
      template: html`
        <draggable-drawer align="${'top'}">
          <h1>Drawer</h1>
          <ul>
            <li>List 1</li>
            <li>List 2</li>
            <li>List 3</li>
          </ul>
        </draggable-drawer>
        <button onclick="document.querySelector('draggable-drawer').open()">Open Drawer</button>        
        `
    }),
    { notes: 'Test' , options: { selectedPanel: 'storybooks/knobs/panel' }}
  );

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bennypowerscommented, Oct 27, 2019

See also #833

0reactions
daKmoRcommented, Nov 21, 2019

this helper function got replace with a storybook decorator… for a migration please see https://open-wc.org/demoing/MIGRATION.html#replaced-withclasspropertiesknobs-with-a-decorator-withwebcomponentsknobs

Read more comments on GitHub >

github_iconTop Results From Across the Web

Component Story Format (CSF) - Storybook
Every component story file consists of a required default export and one or more named exports. CSF is supported in all frameworks except...
Read more >
Storybook default export (non-named) in combination with ...
However, that default export example makes use of "component" and it does not seem to have a "template" option. Is there some way...
Read more >
Running JavaScript with Templates in Storybook for HTML
When working with Storybook for HTML, it can be difficult to pair a template with a JavaScript file. Learn an effective solution.
Read more >
Export to Word, PDF, or another file format in Pages on iPad
Export to Word, PDF, or another file format in Pages on iPad. To save a copy of a Pages document in another format,...
Read more >
Saving and exporting - Adobe Support
To save a copy of a document as a template, choose File > Save ... A document preview includes a JPEG image of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found