Closed jaames closed 4 years ago
@rwwagner90 Things are going alright! I'm still working away on updating the documentation website, progress has been a little slow since I've also been busy with freelance work and applying to a job, but it is very nearly done now. I just need to give it a bit more polish and write some examples to demonstrate new features.
At the moment the handle for the currently active color should always be drawn on top of the others. SVG doesn't really support anything like CSS' z-index, so the 'top' handle is always last. As such, it's possible to target the 'active' color's handle with a CSS selector like .IroColorPicker .IroHandle:last-of-type
, but it's not possible to target any handle by its associated color.
I'll look into making it a bit easier to target specific handles after the docs are done :)
@jaames sounds good! Docs in general are definitely more important.
At the moment the handle for the currently active color should always be drawn on top of the others. SVG doesn't really support anything like CSS' z-index, so the 'top' handle is always last. As such, it's possible to target the 'active' color's handle with a CSS selector like .IroColorPicker .IroHandle:last-of-type, but it's not possible to target any handle by its associated color.
Sounds like we may need a function like makeActiveColor
where we could set which color / handle are active and move that svg to last in the list, so it is on top.
@rwwagner90 There's a setActiveColor
method that should do the trick!
Obviously the multicolor stuff isn't publicly documented yet (...heh), but here's the relevant part of the source if you want to see what's available: https://github.com/jaames/iro.js/blob/e66e0ee560bc0be31fe2fb8d8e0af203057380ac/src/ColorPicker.tsx#L79-L113
@jaames setActiveColor
doesn't seem to change the color selected. Are you sure it is working as intended?
@rwwagner90 It's the same method called internally when you interact with one of the UI handles, so as long as the last handle you interacted with is shown on top of all the others, it should definitely be working correctly. setActiveColor
expects to be passed the color index rather than the color value though, maybe that's catching you out?
In lieu of documentation I put together a quick Codepen demo, hopefully that will help make things a bit clearer :) https://codepen.io/rakujira/pen/bGddRyq?editors=0010
@jaames I was passing the index. It still doesn't seem to work for me. However, I do not have a reference to the actual color index, I was just setting to the index it was from the order of colors I had. If I set all the colors a few times, does the index keep growing? I wonder if with several palettes, my indices are like 15, even though I only have 4-5 colors.
I suppose I should find a way to store the index somehow to be sure.
@rwwagner90 Ah, my bad. The color index shouldn't keep growing, assuming that you're using the setColors()
method I posted whenever you switch the color palette? Are you setting the palette as a series of color values (like hex strings or whatever) or are you using the iro.Color
objects that iro.js provides?
I'll take a deeper look tomorrow since it's getting late here, but sounds like there might be a bug on my end somewhere if that doesn't work as expected.
@jaames I'm doing this this.colorPicker.setColors(this.selectedPalette.colors.mapBy('hex'));
so I am setting colors as hex. Should I be doing something else?
@rwwagner90 That looks correct to me.
I made a basic multi-palette demo on Codepen to test, and everything seems to be working okay as far as I can tell. Not sure if there was something I missed? The only change I made was having setColors
fire its own event so I could re-render the color swatch HTML whenever the selected palette is switched.
https://codepen.io/rakujira/pen/poJJYVP?editors=0010
I should maybe mention that only the active color handle is guaranteed to be drawn on top of the other ones. The other handles will be drawn in the same order that they're provided to the color picker with.
@jaames when I call setActiveColor
nothing happens at all for me. The handle does not move, and the slider does not switch to the new color. I'll try to debug more later today. Should I be creating iro color objects instead of using hex values?
@rwwagner90 That's really strange. Just to rule out any potential browser differences, does that last Codepen work for you? It shouldn't matter whether you use color objects or hex values, etc -- setColors()
will work with either.
I'm not extremely familiar with Ember, but is there a chance that it's doing something that affects the color picker in some way? If you don't manage to get to the bottom of it, I think a reproduction repo would be helpful.
@jaames yeah, the codepen works for me. I will debug more later and report back. To confirm, this should work in 5.0.0-5 right?
@rwwagner90 Yeah, 5.0.0-5 is the right version.
@jaames I got it to work. I was doing something dumb. Sorry about that!
I was just looking at the image above of the new stuff like the square picker, additional slider types, etc and I was curious if that stuff had also been implemented? I would love to try some of it out š
@rwwagner90 Hah, no worries!
Yep, those are implemented now! The documentation can be found here: https://iro.js.org/advanced.html#custom-ui-layouts
Also, I finally published iro.js v5 and the new documentation site! I'm going to continue working on things over the course of the next week or two, so there's still some pending changes on the docsite and little bits like the readme that I need to finish. :)
But without further ado, here's the full v5 changelog! š
color.kelvin
, iro.Color.rgbToKelvin()
and iro.Color.kelvinToRgb()
).color
properties for common color channels (red
, green
, blue
, hue
, saturation
, value
, alpha
)color
properties for color-with-alpha formats (rgba
, hslaString
, hex8String
, etc.)index
property, for keeping track of their position in the color arraycolors
property which provides an array of its selectable colors addColor
, removeColor
, setActiveColor
and setColors
methods for manipulating the color arraycolor:setActive
and color:remove
and color:setAll
eventslayoutDirection
property (thanks asonix!)sliderHeight
option renamed to sliderSize
handleOrigin
option renamed to handleProps
iro.Color.onChange
no longer externalcolor:init
event no longer provides color changessetOptions
method to update config options at any pointreset
method to reset all colors back to their initial valuesAdditionally, there's some smaller features that I'm hoping to add next week:
transparency
option from the transparency plugin, to quickly add a transparency slider to the color pickerI'm sorry that it's taken me so long to finish all of this - it's been a pretty big undertaking! I also owe a huge thanks to @rwwagner90 from Ship Shape for sponsoring the project, it's really helped out a lot :)
I'm going to close this thread now, but please feel free to continue the conversation! You can also reach me via email, Twitter or Discord (jaames#9860
)
Thanks so much for all the hard work @jaames! We'll hopefully be announcing our product using your library soon š
What a wild year! iro.js hit 500 stars on Github, over 1000 NPM installs per week, and was featured on a number of web publications such as Creative Bloq, Codrops and JS Weekly!
I've been thinking a lot about what the next steps for this project might look like now that it's finally stable and fitting most people's requirements pretty well. I figured it would be worth sharing my ideas for discussion:
Svelte has matured a lot recently, and it seems like a good time to investigate whether it's worth using it for the standalone version instead of Preact.Wasn't worth it, trying Preact X instead.An option to choose a vertical layout has been requested for a long time, it's probably time to make an effort to implement that.Pull request #85 adds a globallayoutDirection
option, this will be merged after the Typescript + Preact X ports are completedI think this would take iro.js to the next level and make it one of the best damn color picker libraries out there. I welcome everybody's opinions though!