danielo515 / obsidian-modal-form

Define forms for filling data that you will be able to open from anywhere you can run JS
https://danielorodriguez.com/obsidian-modal-form/
MIT License
175 stars 13 forks source link

[Feature request] selected form input value as `data-value` attribute for styling w/ CSS #279

Open ClaudiaJ opened 3 weeks ago

ClaudiaJ commented 3 weeks ago

Is your feature request related to a problem? Please describe.

No problem, just a nice to have.

Describe the solution you'd like

I would like to style the modal form based on selected values.

This could be achieved by setting data-value parameter on the inputs corresponding to the selected value, something like oninput="this.dataset.value=this.value"[^credit-connexo-so] should make that work easy squeezy.

[^credit-connexo-so]: credit: user connexo on Stack Overflow from a quick searchy search

Additional context

Example: image In this form, I would like to apply a color mapping by the Subjective Unit of Distress value, ranging from green to blue to red, and prefix the description input with a cute little temperature icons from Font Awesome.

With the described potential implementation, I could likely achieve what I'm imagining here w/ CSS by matching [data-value="N"] (where N is 0-10).

Thank you for considering this Feature Request

danielo515 commented 3 weeks ago

that is an interesting use case, and can definitely add nice touches to certain forms. Let me think about it. Adding every field as a property to the form can very quickly bloat it, so it will need to be an optional thing, and will probably not make sense for all the input types.