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

Should the selected-value be able to contain SVG tags provided in the <option> #652

Closed
brechtDR opened this issue Jan 6, 2023 · 3 comments

Comments

@brechtDR
Copy link
Collaborator

brechtDR commented Jan 6, 2023

While creating a demo, I was wondering about something.

When using an SVG inside of an option. Do we expect the "selected-value" to also contain the SVG inside of it when selected? This doesn't seem the case at the moment.

This could really help with styling some sort of UI patterns.

Personally, I believe it should contain everything the option has inside of it. If the developer does not want to show the SVG inside of the selected-value, this could be easily achieved by targeting and hiding it with CSS.
This at least would be easier than the other way around.

Another (maybe far fetched) possibility is to add an extra attribute to the "selected-value" such as
allow-all="true"which would then take the full content of the option.

The demo can be found here (use Chrome Canary):
https://codepen.io/utilitybend/pen/zYLoqge

And example code

<selectmenu class="potion-select">
        <button class="potion-equipped" slot="button" behavior="button">
            <span behavior="selected-value" class="selected-value">
                <!-- this will only show the text -->
            </span>
        </button>
        <div slot="listbox">
            <div popover="" behavior="listbox">
                    <option value="health">
                        <div class="potion-holder">
                            <svg class="icon icon-health" aria-hidden="true">
                                <use xlink:href="#potion" />
                            </svg>
                        </div>
                        <span>Health</span>
                    </option>
                   <!-- and others -->
       
            </div>
        </div>
    </selectmenu>
@jonathantneal
Copy link
Contributor

Hey, @brechtDR. Would this be thematically covered by #571?

I’ve been following along with this conversation there. I find it quite valuable, too.

@brechtDR
Copy link
Collaborator Author

This is sort of a duplicate of the issue you mentioned indeed. Although my question was about inner content specific. I'll try to follow along with the related issue as this is also discussed there.

Thank you for linking this.

@gregwhitworth
Copy link
Member

@brechtDR that topic does pivot to discuss the inner content since we noticed that while the OP asked about styles authors may want the internal content as well (as you've brought up).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants