Unattached docs not rendering theme #28495
Replies: 1 comment 9 replies
-
Ok after quite a bit of fiddling, i've got it working. So for anyone else in the future looking for a quick and dirty way to style vanilla mdx (especially in an Angular app, as the docs for writing a custom docs wrapper just didn't work) Assuming you have
Next add this function to your docs property in
Appreciate getting it from the store is likely to break at some point, but for now, it works and can't find any other Angular friendly solutions. Would be nice to have this working for unattached mdx out of the box so you can use your design systems themes without a load of extra config |
Beta Was this translation helpful? Give feedback.
-
Summary
Hello, hoping someone can help me with an Angular based storybook implementation (v8).
I've got my
preview.ts
set up with the below config to add a data attribute (which renders on the html tag to set the theme)This works perfectly for Stories, and for
.mdx
files that contain a story, but for vanilla unattached.mdx
files with just static content, this does not work, the prop on the html tag does not update.A few other oddities i've noticed. The api docs for
storybook-addon-themes
say : "target (string - optional): Target element selected with document.querySelector() to which classes are applied. Defaults to body, root if classes should be applied to documentElement." - however no matter what i set the target to, the attribute always renders on the html tag.Another one, is if i visit a story and switch the theme (which works) and then go to an unattached mdx page, the html data attribute leaks onto the new page, i.e the theme i've switched to renders, however it still cannot be switched.
Any help is super appreciated, tried all sorts of config and no joy so far!
edit - Looks to be similar to #26625 and the last comment in #25183
Additional information
No response
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions