ladle icon indicating copy to clipboard operation
ladle copied to clipboard

Any plan to allow user to create custom plugins ?

Open nathanguigui opened this issue 1 year ago • 5 comments

Is your feature request related to a problem? Please describe. I would like to add a plugin for figma preview

Describe the solution you'd like The best option would be to add the possibility to create custom plugins for ladle

Thanks you for the job you are doing on this project

nathanguigui avatar Jul 18 '23 13:07 nathanguigui

I am open to it.

There is already quite a lot you can achieve just with https://ladle.dev/docs/providers#ladle-context

I would like to add a plugin for figma preview

Can you document in detail what this integration would look like, including what APIs Ladle should expose/add?

tajo avatar Jul 18 '23 20:07 tajo

We can imagine an API like in the storybook to register custom addon in the bottom bar and display custom panel component on open

addons.register(ADDON_ID, (api) => {
  addons.add(PANEL_ID, {
    type: types.PANEL,
    title: 'My Addon',
    render: ({ active, key }) => (
      <AddonPanel active={active} key={key}>
        <div> Storybook addon panel </div>
      </AddonPanel>
    ),
  });
});

For my case (figma addon) I will display inside the panel and iframe linked to my figma in order to simplify the review of the designers.

nathanguigui avatar Jul 19 '23 09:07 nathanguigui

I created a package to inject buttons into the addon bar so that they appear the same as the Ladle built-in addons do. If you would like to use it, here's the repo https://github.com/hiddenist/ladle-inject-custom-addons

image

hiddenist avatar Jun 25 '24 20:06 hiddenist

@hiddenist nice, using your lib + https://ladle.dev/docs/providers#ladle-context is basically what the built-in addons are today

we could maybe inline your lib into Ladle directly since it's pretty lightweight integration and opens a lot of possibilities when it comes adding more features into Ladle

tajo avatar Jun 27 '24 17:06 tajo

@tajo Certainly! I would be glad if this could be officially incorporated into Ladle.

I've had pretty good success with this so far, though I had to chase down a strange bug on the built bundle when using MUI for the button icons after upgrading from v2 to v3/v4 🤷🏻

The add-ons that I'm using in my private project could also probably be useful as official add-ons, too. I have a theme color selector, and one that collapses/expands the story sidebar.

hiddenist avatar Jun 27 '24 17:06 hiddenist