Component B is included as a part of the slot
html for the Component A. The code below doesn't work as it may be expected, because components don't share styles by default (svelte-${hash(css)}
is used to make a set of different "virtual" namespaces during the compilation):
// Component A - ./Menu.svelte
<Router>
<ul class="menu">
<Delimiter label={$format('Menu label')}></Delimiter>
{#each routes as route}
{#if route.url?.length > 0}
<li class="menu-item">
<Link to={route.url} getProps={onLinkUpdate}>
{route.title}
</Link>
</li>
{/if}
{/each}
</ul>
</Router>
// Component B - ./Menu/Delimiter.svelte
<li class="divider" data-content={label} {...$$restProps} />
Router and Link here are parts of the separate package (so, considering as a Namespace A). Delimiter is a project-level component (Namespace B). They all use the same style sheets, i.e. the same CSS framework environment.
An example above has been compiled into something like this:
<ul class="menu">
<li class="divider" data-content="..."></li>
<li class="menu-item">...</li>
</ul>
And li
with divider
class didn't receive its styles. But if the Delimiter component (this line):
<Delimiter label={$format('Menu label')}></Delimiter>
will be replaced with its direct contents:
<li class="divider" data-content="..."></li>
The compiled source will be like:
<li class="divider svelte-sipu9k" data-content="..."></li>
So, the question is - how to properly "share" a style base with the external components, which are included (nested) to the original namespace? (or is it an architecture problem and I should try a different approach?)
<style src="./Menu.scss"></style>
, this file describes styling for the.divider
class, without any :global (or similar) directives. Just an @import from the framework's code base. – itnelo