-
Notifications
You must be signed in to change notification settings - Fork 265
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
Should we use svelte namespace for slots #7189
Comments
IMHO there was a good argument in #7150 for leaving a default (unnamed) slot and not changing the behaviour for the simple case - tooltips will always have a direct child that they're providing the tooltip for. Maybe we should have already done that for components like NavPage. I dislike |
If the In our import Content from './Content.svelte';
import Tip from './Tip.svelte';
import Tooltip from './Tooltip.svelte';
export default Object.assign(Tooltip, {
Content: Content,
Tip: Tip,
}); Allowing us to make the following in other components import Tooltip from '@podman-desktop/ui-svelte/Tooltip';
...
<Tooltip top>
<Tooltip.Content>
Hover me
</Tooltip.Content>
<Tooltip.Tip>
Hello world
</Tooltip.Tip>
</Tooltip> Both solution are fine for me |
Thanks, that is better. Personally I still prefer the pattern like And yes, I still think TooltipTip or FormPageIcon is a nice way to avoid exposing named slots in the api, but if we have something named 'content' it should probably just be default slot. :) |
Totally agree with this one, most of the time, we often just want a string in the tip! |
Closing as we started using it, and it is nice |
Is your enhancement related to a problem? Please describe
After #7150 has been merged I was wondering, could we improve the slot stuff as it is pretty ugly (IMO)
Describe the solution you'd like
Svelte allows easily to make some Namespacing1 for components.
Currently if I want a tooltip we do the following
podman-desktop/packages/ui/src/lib/alert/ErrorMessage.svelte
Lines 13 to 24 in 17d4db0
However with the svelte namespacing I could do the following
This makes easier the usage, as we do not hardcode the slot, and reduce the risk of misusing the component. It requires a bit more code on the library side, as I have to declare an
index.ts
file with the followingAnd here is an example of the
Tips.svelte
Describe alternatives you've considered
No response
Additional context
cc @deboer-tim @benoitf @luc
Footnotes
https://svelte.dev/repl/18f41adb56fa46ff8b25cad7c1a388a4?version=3.38.3 ↩
The text was updated successfully, but these errors were encountered: