Coder Social home page Coder Social logo

Comments (4)

d9k avatar d9k commented on June 3, 2024 2

Ladlescoop doesn't support generation controls from inherited props yet

Please consider controls autogeneration feature as top 🔝 priority.

⚡ Instant startup time is cool but syncing ladle controls manually on each component change is a boring 🥵 tedious task which outweights ⚖️ all developer's time saved by ladle optimisations. It breaks single-source-of-truth principle.

Because of this can't switch from Storybook to Ladle yet and can't advice switching to friends/colleagues 🤷‍♂️

from ladle.

d9k avatar d9k commented on June 3, 2024 1

Found https://github.com/lukifer/ladlescoop enthusiast project for that:

Automatically generate Ladle stories from existing React components, extracting Props definitions and default values, and automatically creating controls from types.

from ladle.

matthewwolfe avatar matthewwolfe commented on June 3, 2024

I did a little bit of discovery on the viability of this, and it looks like react-docgen can reliably generate values depending on how the props are typed in the stories file.

❌ Does not generate type information

const Card: Story<Props> = ({ label }) => <p>Label: {label}</p>;

✅ Generates type information

const Card: Story<Props> = ({ label }: Props) => <p>Label: {label}</p>;

Considerations

  • react-docgen is not a heavy dependency, but it is also not super lightweight, optional flag to enable?
  • Must work with hot reload
  • Types that do not map cleanly to a control

@tajo do you have any opinion on if this is something that you'd like implemented? If so, could you provide a bit of direction on how you'd like this structured? Any info would be appreciated if you are interested in this, and I'd be happy to take a stab at an implementation.

from ladle.

tajo avatar tajo commented on June 3, 2024

It would nice to have this as an opt-in feature through config.mjs. I guess you don't want to automatically add control everywhere just because you use TypeScript, so users need to consent to it. This way we can make react-docgen dependency optional. It can be still in dependencies but should be used dynamically (or just make sure it doesn't get bundled by default) and added into optimizeDeps.

Also, I assume, when enabled and args/argTypes are defined at the same time, args/argTypes should take the precedence.

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.