UI Selector Ideas?

I am making these plus & minus selectors for a client, the image is from the Figma. I'm a bit stuck with how to best go about making them, specifically with the text/select options. For the Quantity, I can use a number input and have the buttons add or subtract vrom the value. But for the Grind Size and Bag Size I'd appreciate any ideas. - Vanilla JS - As a11y friendly as possible Also, is there a UI term for this kind of component? I hit a dead end on google.
No description
30 Replies
ἔρως
ἔρως8mo ago
where's the code?
Trey.Will
Trey.WillOP8mo ago
@ἔρως No code yet. I'm more looking for what the community thinks would be the best way to tackle this. A pseudo-code discussion.
Trey.Will
Trey.WillOP8mo ago
@Mannix I like that, and that's what I've done on the quantity input. What makes that nice is there is a semantic html "number" input. But for options that are strings, what might be best?
syntax
syntax8mo ago
Are you confused with the styling and functionality or only the functionality?
ἔρως
ἔρως8mo ago
that's nearly impossible to respond then
Trey.Will
Trey.WillOP8mo ago
@syntax Just the functionality
ἔρως
ἔρως8mo ago
if you want the most accessible, a simple <input> is the best
Trey.Will
Trey.WillOP8mo ago
@ἔρως Great, how would you set up a simple <input> to do behave like what is shown in the design?
ἔρως
ἔρως8mo ago
you do nothing to do if you want numbers, use the number input if you want whatever the first thingy is, use a <select> but those elements are ugly af you can make them look like how you have it, but problem is: it tells us nothing about how accessible it is it's pretty, but it's a jpeg
Trey.Will
Trey.WillOP8mo ago
@ἔρως So the question is how to implement the ui and "a11y friendly as possible". I realize it wont be the most accessible, but we can still implement best practices.
ἔρως
ἔρως8mo ago
yeah, but short of writting it all for you, it's impossible to answer
syntax
syntax8mo ago
For all the icons(+, -) , use an onClick property to change the elements between them
Trey.Will
Trey.WillOP8mo ago
@ἔρως You really like the word "impossible". @syntax For what's in the middle, between the + and -, do you think re-styling some other input, like a radio or dropdown, or just having text?
ἔρως
ἔρως8mo ago
i love the word
syntax
syntax8mo ago
For the grand size: Store all the values you would like to change them to into an array. So when you click on the + icon allow it to increase the value +1 then pick the value in an array A <p> element
ἔρως
ἔρως8mo ago
don't use an array, use a pojo
Trey.Will
Trey.WillOP8mo ago
@syntax That tracks. Just change the innerText according to the position on the array.
ἔρως
ἔρως8mo ago
don't use a <p>, since it has some meaning use a span
syntax
syntax8mo ago
Yes
ἔρως
ἔρως8mo ago
dont change innertext, use textcontent
syntax
syntax8mo ago
You can use any element but it will depend on the styling <p> is a block element while <span> is an inline element Anyone works
ἔρως
ἔρως8mo ago
yes, but better to use an element with no semantic meaning than bashing an element with a specific meaning to work as you want no, they do different things innertext replaces everything inside the element, while textContent doesn't
Trey.Will
Trey.WillOP8mo ago
@syntax Thanks for your constructive help.
ἔρως
ἔρως8mo ago
that means, if you have a <b>, innetText deletes it while textContent doesn't
syntax
syntax8mo ago
I said both works, they are not the same
ἔρως
ἔρως8mo ago
that depends on how it is implemented
syntax
syntax8mo ago
Am glad I could help☺️
ἔρως
ἔρως8mo ago
since we don't have code, it's an important thing to have into consideration
syntax
syntax8mo ago
Yeah right
Want results from more Discord servers?
Add your server