Coder Social home page Coder Social logo

Comments (4)

tajo avatar tajo commented on June 11, 2024 1

Closing, since this is not technically feasible. Anyway, we might have some better & analyzable controls API in the future.

from ladle.

tajo avatar tajo commented on June 11, 2024

Good question, I would like to use something like this too. The issue is that args / argTypes are not statically analyzable and they need to be executed (if we want to stay Storybook compatible). So you can't just simply export them through meta.json. There was a similar discussion about this here: #127 (comment)

I see two solutions:

  • propose a new (different) format for controls that will be strictly static
  • add some argStatic mode that would attempt to statically analyze args/argTypes and throw an error if not possible Your example would work just fine:
Index.argTypes = {
  variant: {
    options: ["default", "primary", "danger"],
    control: { type: "inline-radio" },
  }
};

however, this would fail

const variant = {
  options: ["default", "primary", "danger"],
  control: { type: "inline-radio" },
}
Index.argTypes = { variant };

Does it make sense?

from ladle.

madebyherzblut avatar madebyherzblut commented on June 11, 2024

Thanks for the link @tajo–I always assumed args/argTypes are statically analyzable as well and it would be easy to export them. Are there any use cases where those are not strictly static?

Personally, I think the CSF compatibility of Ladle is a great feature and it is worth the wait until a mutual standard has been set.

from ladle.

tajo avatar tajo commented on June 11, 2024

Are there any use cases where those are not strictly static?

They could be static, it's all simple arrays/objects but it's not been enforced in Storybook ecosystem (same with story titles, which Ladle actually strictly enforces and diverges from Storybook on that since it's critical for code-splitting and other features). Typically, devs assign args into a variable so they can spread it out over multiple stories.

from ladle.

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.