neighbour-hoods / design-system-components

Storybook and UI component library for the Neighbourhoods design system.
0 stars 0 forks source link

`design-system-imports.stories` tests crash when viewed in Storybook via browser #7

Closed pospi closed 11 months ago

pospi commented 1 year ago

_shared_customElements.ts should be deprecated in favour of a generator function which can dynamically create wrapper CustomElement classes that have unique tag names bound to each story. This would be the more robust way of ensuring that there are no conflicts in the global customElements registry definitions.

However, this may be more complicated than the simple case since many components use slotted children; meaning that the rendering of child elements is occasionally the responsibility of the root shadow DOM rather than that of the containing component.

(via #3)

pospi commented 12 months ago

Updated the issue title as this does actually manifest in an error due to multiple registration of the NHButton class within these two files.

This does not affect the test runner since that builds a static Storybook to execute against and thus has a different module resolution behaviour at runtime than the development Storybook that executes via npm start.

Some additional unforseen complexity in resolving the problem: @storybook/web-components.Meta accepts an args property to render and does not operate as a 'normal' CustomElement, meaning that elementDefinitions is not usable with the root-level component in a test. Working on a resolution.

pospi commented 11 months ago

resolved earlier