mskocik / svelecte

Flexible autocomplete/select component written in Svelte,
https://svelecte.vercel.app
MIT License
471 stars 43 forks source link

Added options-slot (Variant 2) #251

Closed jbirtel closed 1 month ago

jbirtel commented 1 month ago

I actually implemented this as an alternative to the first option. I actually like that one a bit better, because it is simpler imo. Link to the Other PR

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
svelecte βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Sep 27, 2024 3:53pm
svelecte-v5 βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Sep 27, 2024 3:53pm
mskocik commented 1 month ago

Why the example implementation for this use case (display icon in dropdown based on selection state) is not enough for you?

jbirtel commented 1 month ago

I already implemented it this way right now. However, I want to keep the search highlighting with the custom icon.

mskocik commented 1 month ago

You can provide custom icon and keep the highlighting image

The only downside is that you can't pass icon as svelte component. Is this what you are trying to do?

Can you show me in REPL what would you like to achieve?

jbirtel commented 1 month ago

How did you insert the icon here? I think it would be enough for now πŸ€” However, I cannot not insert it as a string, but rather directly as HTML

<div class="multiselect-options" slot="option" let:item>
    <div class="icon-checkbox" class:selected={item.$selected}
            class:borderless={!autocompleteConfig.multiple}></div>
    <div class="sv-item--content">{@html item?.label || item?.text}</div>
</div>

Then, the icon is inserted in the css as background of the .icon-checkbox::before

mskocik commented 1 month ago

REPL with your slot and inserting icon as ::before pseudo-element. Still I don't understand what is missing in current implementation πŸ€”

jbirtel commented 1 month ago

That is exactly how I implemented it. However, the highlighting of the search is missing in that case, so when I type β€žonβ€œ I expext One and Second to be highlighted. And I just wanted to get that status quo back with my implementation

mskocik commented 1 month ago

Oh yes, I got sidetracked from original issue to 'icon' discussion.

I am closing this as it is achievable by other means. And let's continue discussion on #250