So we have input for text. We have input for numbers but many of the inputs in PS are numbers + units.
E.g. 10px30mm5in. It also has possibility to change units in context menu or by writing text. You can also do math in it. With shift it increments more and you can change values with scrolling or by dragging label.
Can we have the same UI also in UXP without writing everything from scratch?
Maybe this helps someone (if you’re using React), until Adobe release native components for that, which I don’t really see coming in the near future
I know that I saw it in your plugin but I did not expect you to open source it Thanks a lot! This could possibly reduce the development time of my next plugin to half since it has a very easy UI.
Anyway, you are currently using HTML component that will be later removed from UXP although I like more this compact native-looking input
You’re welcome
Yes I know, I’m still ignoring that as long as possible, because I hate the bulky look of some of the Spectrum Components By the time they will be deprecated, I’ll hopefully have all my components sourced out in a package that I just need to update and reimport in all the plugins.
Sounds more like application logic to me, not like state that the input should manage.
The other ideas are very good and should only require a few more lines all together.
At one point I even had an “allowedUnits” array, but I think it got lost on the way as I never really used it.
For the other ones, if you want to share the code or create a PR, I can surely add this to the repo. I’m still busy finishing the next plugin I’ve been working on for months, so I’ll probably not make any edits to the components myself right now.
For mixed values I simply added mixed:boolean property. If this is true then shown value in input field is empty. That is all it does. Looks good for me so far.
I could do pull request but I was focused on make it work instead of improving reusable component so it might require additional changes
Ah okay, got it. But alternatively you could also just set the value to undefined whenever your app finds more than one selected layer. Then this additional property would be obsolete and the input would be decoupled even more from that piece of logic. But then again… one additional property doesn’t cost anything
I did another change which is enforing units. If there are not units then units are not undefined but “px” instead and thats internal behavior of component. Also if you have same value but different unit then it should be blank.
That’s weird, what does it stand for? But I guess localization is a whole new story, all my plugins are only in english, so I also didn’t localize any specific components.
Is it document somewhere or did you just play around with the units to see the actual PS conversion?
I honestly never used pica in my life and just took the formula from here.