Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to change the Localized/Overlay element type #696

Closed
macabeus opened this issue Feb 21, 2023 · 1 comment
Closed

Allow to change the Localized/Overlay element type #696

macabeus opened this issue Feb 21, 2023 · 1 comment
Labels
wontfix This will not be worked on

Comments

@macabeus
Copy link

macabeus commented Feb 21, 2023

Currently, <Overlay> outputs a <span> wrapping the result:

<Overlay id="foo">

outputs something like:

<span>foo text</span>

But we may need to render a specific element, such as <p>.

Perhaps we can use <svelte:element> and let the user decides which element is better for the use case, defaulting to <p> if no one is defined.

The same can be useful for <Localized>.
Currently, it doesn't have a wrapper element. Then, if we need to wrap it, we need to write more:

<Localized id="foo" let:text>
  <p>{text}</p>
</Localized>

If would be good if we could have an API like this:

<Localized id="foo" element="p" />
@sfriedel
Copy link
Collaborator

@macabeus <Overlay> outputting an additional wrapper element is a technical necessity that I'd very much like to eliminate in the long run. It should currently be considered an implementation detail. I'd recommend against relying on the container for styling purposes.
The next release will actually change that container to a <div> with display: contents similar to the wrappers that svelte injects for setting css variables when using the <Component --some-css-var="value"> syntax.

<Localized> does not add any additional wrappers to make it usable in situations where the additional element would be detrimental. You could always have your own component that wraps <Localized> with an additional wrapper using <svelte:element> or similar if that is something that you often need.

@sfriedel sfriedel closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2023
@sfriedel sfriedel added the wontfix This will not be worked on label Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants