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

Suggester could set a data-attribute with the current selection #475

Closed
3 tasks done
Cube707 opened this issue Nov 29, 2024 · 2 comments
Closed
3 tasks done

Suggester could set a data-attribute with the current selection #475

Cube707 opened this issue Nov 29, 2024 · 2 comments
Labels
feature request New feature or request

Comments

@Cube707
Copy link
Contributor

Cube707 commented Nov 29, 2024

Please fill out these Check-boxes

  • I checked for existing similar feature requests
  • I have read the docs and checked that the feature I am requesting is not already implemented
  • My feature request consists of only one feature

Is your Feature Request related to a Problem or Annoyance?

I would like to modify some styles depending on a user selected value while still having the value available for calculations. Here it would be helpfull if the suggester would set a data-attribute containing the current selection on itself, which could be use inside a css selector.

Describe the Feature you'd like

The current value of a selector should be available as for example the attribute data-selected, which would make it selectable via css.

The html would look something like this:

<div class="mb-input-wrapper my-custom-class mb-input-type-suggester" data-selected="1">
    <div class="mb-suggest-input">
        <div class="mb-suggest-text">
            <span>1</span>
        </div>
        <button class="mb-button-inner mod-plain" aria-label="">
            <div class="mb-icon-wrapper"></div>
        </button>
    </div>
</div>

which would allow you to write this css selector:

.my-custom-class[data-selected="1"] {...}

Alternatives

No response

Additional Context

full context of what I am working on, in case I am overlooking things:

I am trying to create a Ability-table for DnD 5e, which should display different proficiency-levels with different styling:

image

The first column "prof" is a INPUT[selector] which has for options 0, 0.5, 1, 2 which correspond to the for icons shown. The selected values are used to calculate the last column "bonus". Currently I can't select the styling depending on the made selection but have to hard-code a classname. I would like to change that.

@Cube707 Cube707 added the feature request New feature or request label Nov 29, 2024
@mProjectsCode
Copy link
Owner

This sounds like a good addition, but it should be added to all input fields. However, I am not sure how more complex values can be stringified. Probably a simple JSON.stringify.

@Cube707
Copy link
Contributor Author

Cube707 commented Dec 3, 2024

I am not sure how more complex values can be stringified. Probably a simple JSON.stringify

JSON will work, but " would need to be escaped as both HML and JSON require double-quotes, which makes it a little anoying?

Maybe relying on the String-constructor would be enough. Its not really realistic to write styles for every permutation of a complex object and this way the developer could provide his own toString() implementation and match that in his css.
That's at least how I would do it in python, not sure how well this concept translates to JavaScript

mProjectsCode added a commit that referenced this issue Dec 9, 2024
mProjectsCode added a commit that referenced this issue Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants