Lullabot / storybook-drupal-addon

Storybook addon to facilitate integrating Storybook with Drupal projects.
MIT License
39 stars 7 forks source link

Have an option to have storybook inside a custom theme folder instead of the Drupal root folder. #35

Closed sagarrchauhan closed 11 months ago

sagarrchauhan commented 11 months ago

Right now the only way Storybook renders the components is by installing storybook in the root folder of Drupal installation. When installed inside a custom theme folder, it generates an error. image Can we make it more flexible with regard to the installation?

danny-englander commented 11 months ago

I got the same error as well when installing storybook in my theme. I would very much like to have this option as well. I installed storybook in my theme the same way I did in the root of the site as per https://github.com/lullabot/storybook-drupal-addon#readme and storybook within my theme runs fine. I just update the paths in my theme's .storybook/main.js file to be:

  stories: [
    "../components/**/*.stories.mdx",
    "../components/**/*.stories.@(json|yml)",
  ],

However, the error seems to point at CL Server:

The website encountered an unexpected error. Please try again later.
TypeError: Drupal\cl_server\Controller\ServerEndpointController::findExtensionName(): Argument #1 ($path) 
must be of type string, null given, called in 
/app/web/modules/contrib/cl_server/src/Controller/ServerEndpointController.php on line 120 in Drupal\cl_server\Controller\ServerEndpointController->findExtensionName() 
(line 210 of modules/contrib/cl_server/src/Controller/ServerEndpointController.php).
dubbs commented 11 months ago

I'm not sure if this will help you but I got this working today with lando. We plan on using SDC components with the story in the component directory. I had to add the full path to the filename in the story file itself.

{
  "title": "Alert",
  "parameters": {
    "fileName": "/app/web/themes/contrib/zu_starterkit/components/alert/alert.stories.json"
  }
}

In the .storybook/main.js file, I adjusted the stories path:

const config = {
  stories: ["../components/**/*.stories.@(json)"]
}

Also, you need to add the "Use the CL Server endpoint" to anonymous users on /admin/people/permissions. I was getting 403 errors, if you know a way that this can be avoided, please let me know!

I hope this helps.

e0ipso commented 11 months ago

@dubbs thanks for the workaround. I think a proper fix for this should live in the Drupal module https://www.drupal.org/project/cl_server/issues/3369045

e0ipso commented 11 months ago

Closing this one for now, as I think the fix is in the other repo mentioned above.