Code Monkey home page Code Monkey logo

Comments (7)

Cherry avatar Cherry commented on May 22, 2024 1

@storybook/csf got a 0.1.5 release that fixes this: https://github.com/ComponentDriven/csf/releases/tag/v0.1.5

Once #26958 is merged and a storybook release is out, that should resolve this moving forward.

from storybook.

asso1985 avatar asso1985 commented on May 22, 2024

Having same issues but with latest SB version you no longer need to set options as before. You will get those automatically.
You can still change the control type indeed.

from storybook.

Cherry avatar Cherry commented on May 22, 2024

I think simply making options a readonly any[] instead of just any[] should work, as per https://www.typescriptlang.org/play?#code/C4TwDgpgBAhgdiAKgCwJZwOZQLxQE4QwAmA9nADYiwIDaAugNwBQTAxmQM7BQckC2EYGkw4oNAEQAzEiXEAaKOIBGMPOLqwOUdnC7MdXHv0HCMAUXIdouGgEYFAJgUBmRiwPdeAoegwBBBAAuaiRTUS8TX31OT2MfTAsrAJBg+FDfcLjTRIgGIA

I'd make a PR for this and test it, but I'm struggling to find where this is defined. I can see it published in @storybook/types but can't quite find it in this repo. https://npmdiff.dev/%40storybook%2Ftypes/8.0.8/8.0.9/

EDIT: I found it. It's https://github.com/ComponentDriven/csf. I think this was introduced in ComponentDriven/csf@ab72fee

from storybook.

Cherry avatar Cherry commented on May 22, 2024

I've opened ComponentDriven/csf#85 which from my testing resolves this.

from storybook.

MatthijsBon avatar MatthijsBon commented on May 22, 2024

I've opened ComponentDriven/csf#85 which from my testing resolves this.

Great! Do we also need a PR in storybook to address the dependency upgrade? I'm a bit of a OS / Storybook noob, so not completely sure what the best approach is.

from storybook.

alicegherbison avatar alicegherbison commented on May 22, 2024

Hello,

We are also experiencing this issue with 8.0.9 when using an enum as the value for the options property against an argType.

Previously ok and now throwing same error as above:

export enum EStatus {
  ACCENT = "accent",
  DANGER = "danger",
  LOADING = "loading",
  NEUTRAL = "neutral",
  SUCCESS = "success",
  WARNING = "warning",
}

argTypes: {
    status: {
      options: EStatus,
      control: { type: "radio" },
    },
  },

Removing the options property does not automatically give the correct enum as options even through it is specified in the prop types for the component. Control in Storybook gives "-".

Manually specifying individual enum items in an array in the options property does still work e.g.

argTypes: {
  status: {
      control: { type: "radio" },
      options: [EStatus.ACCENT, EStatus.DANGER, EStatus.NEUTRAL, EStatus.SUCCESS, EStatus.WARNING],
    },
}

Do we need to change our technique for the options property or is this a bug with the new version? Many thanks.

from storybook.

Cherry avatar Cherry commented on May 22, 2024

I've opened ComponentDriven/csf#85 which from my testing resolves this.

Great! Do we also need a PR in storybook to address the dependency upgrade? I'm a bit of a OS / Storybook noob, so not completely sure what the best approach is.

There will need to be a PR here too yes, once that PR for @storybook/csf is merged and released.

from storybook.

Related Issues (20)

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.