Giter Club home page Giter Club logo

storybook-addons's Introduction

storybook-addons's People

Contributors

coderkevin avatar dependabot[bot] avatar tyom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

storybook-addons's Issues

Support storybook 7

Hi, I see that these addons are relying on storybook packages with ^6.3.6. Maybe you could release a pre-release (alpha or beta) version that uses storybook 7?

storybook-react-context: Maximum call stack size exceeded

From https://tyom.github.io/storybook-addons/react/?path=/story/storybook-react-context--change-context-on-mount&fixtures=.0

RangeError: Maximum call stack size exceeded
    at sortObject (https://tyom.github.io/storybook-addons/react/vendors~main.17a6b5f5.iframe.bundle.js:2:417487)
    at https://tyom.github.io/storybook-addons/react/vendors~main.17a6b5f5.iframe.bundle.js:2:417758
    at Array.reduce (<anonymous>)
    at sortObject (https://tyom.github.io/storybook-addons/react/vendors~main.17a6b5f5.iframe.bundle.js:2:417665)
    at https://tyom.github.io/storybook-addons/react/vendors~main.17a6b5f5.iframe.bundle.js:2:417758
    at Array.reduce (<anonymous>)
    at sortObject (https://tyom.github.io/storybook-addons/react/vendors~main.17a6b5f5.iframe.bundle.js:2:417665)
    at https://tyom.github.io/storybook-addons/react/vendors~main.17a6b5f5.iframe.bundle.js:2:417758
    at Array.reduce (<anonymous>)
    at sortObject (https://tyom.github.io/storybook-addons/react/vendors~main.17a6b5f5.iframe.bundle.js:2:417665)

Screen Shot 2021-08-02 at 4 18 57 PM

Decorated component re-mounts on dispatch

Hello,

I'm trying to use the context addon for input-based components.
For example:

import { useEffect } from 'react';
import { withReactContext } from 'storybook-react-context';

const InputWrapper = ({ value, children }) => (
  <div>
    <p>{value}</p>
    {children}
  </div>
);

export default {
  component: InputWrapper,
  title: 'InputWrapper',
};

export const Input = (args, { context: [ state, dispatch ] }) => {
  const handleChange = (e) => {
    const { target: { value } } = e;

    dispatch({ value });
  };

  useEffect(() => {
    console.info('mount');

    return () => {
      console.info('unmount');
    }
  }, [])

  return (
    <InputWrapper value={state.value}>
      <input type="text" value={state.value} onChange={handleChange} />
    </InputWrapper>
  );
};
Input.decorators = [withReactContext({
  initialState: {
    value: 'Hello',
  },
})];
Input.args = {};

I'm noticing that on every dispatch (input value change) story is re-mounted.
Is there a way to avoid that, because on each keystroke input is re-mounted and focus is lost?

Thx

Fixtures conflicts with controls on Vue

Hi!

I can't get both controls and fixtures working at the same time on Vue. The example doesn't include that, so how could tht be done?
I've tried several ideas but none of them worked.

My code is something like:

const Template = (args, { argTypes, fixture }) => {
  return {
    component: Table,
    props: Object.keys(argTypes),
    template: '<Table v-bind="$props" />'
  }
}

export const SomeRows = Template.bind({})
SomeRows.args = {
  rows: [
    { text: 'Value 1' },
    { text: 'Value 2' }
  ]
}
SomeRows.parameters = {
  fixtures: {
    __singleTab: true,
    realExamples: {
      'Some real values': {
        rows: [
          { text: 'Real Value 1' },
          { text: 'Real Value 2' }
        ]
      },
      'Other real values': {
        rows: [
          { text: 'Other value 1' },
          { text: 'Other value 2' }
        ]
      }
    }
  }
}

Unsafe use of `window.parent`

This code:

const urlQuery = qs.parse(global.parent.location.search, {
ignoreQueryPrefix: true,
});

Access window.parent from the preview. This works in Storybook proper, but leads to errors in cases where the preview iframe is embedded in other places (such as Chromatic, or other 3rd party integrations).

In general any random URL parameters will be passed through to the preview iframe; additionally you can use the UPDATE_QUERY_PARAMS event to be informed of any changes.

storybook-react-context packs value incorrectly

The storybook-react-context addon repacks the initialState value into a new type that doesn't necessarily match the original context provider value. The addon unconditionally changes the provider value to a React.useReducer result. It looks like the implementation may overfit to a particular use case. I'm working with a provider where the value is just a plain object. What I pass as the initialState value should be what the component gets with a React.useContext call. In this particular case, it's a 3rd party context so I don't have the liberty of adjusting it to conform to this addon's expectations.

I'm happy to pull together a PR, but I'd like to get agreement on what, if anything, should change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.