-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
[color-scale] editable
prop (MVP)
#167
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for color-elements ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
84a42f8
to
0792983
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments. Also I don't see anything about what keywords are used in editable
37ee22b
to
09f62b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some (possibly non-exhaustive) comments:
- High level: I would have expected this to involve a lot more changes in
<color-swatch>
. Why is it trying to do everything in<color-scale>
? A lot of this functionality is useful for individual swatches too. I'd expect mainly the list stuff to be in<color-scale>
. Also, [color-swatch] Decouple color and label concepts #107 seems to be causing issues here too (see below).
Delete button:
- Remove button should be a part
- I'd use "delete" rather than "remove" consistently
- The delete button should only appear on interaction, otherwise it adds too much visual noise
- The current styling is more "not allowed" rather than "delete"
Docs:
- Don't show the edge cases before the simple syntax. start from simple, then complex. I'd show the boolean
editable
first, and then the values to customize the behavior.
Other:
- Why are colors displayed twice in
Food for thought:
- It would be good to start thinking how we can support the common need of modifying colors in a scale with a more elaborate UI, such as the one by our
<color-picker>
or even a third-party one, e.g. like
e896f77
to
055af05
Compare
3d82691
to
2da444c
Compare
I know the change was my idea, but seeing it now, I think Also, could we add an |
No worries—it's an easy change. I see nothing wrong with trying things out and reverting to one of the previous options if the new ones fail.
Sure. It was exactly the next step I was going to take. I just keep the things around so I don't lose progress. |
3900dff
to
77499a0
Compare
I think the PR is ready for another iteration. Now, it does even more than before:
The first are the color names, and the second are the colors themselves. Since we are editing colors here, the names are still visible. Anyway, I updated the example to be less confusing. I addressed most of your feedback. Thank you for it (as always, it's highly valuable). 🙏 Still to implement: reordering colors, changing the number of "stops," enabling edit mode with a pencil button next to the color label, and changing colors with a popup. Probably, next iteration? @LeaVerou, could you please give the PR another shot? |
I have not yet properly reviewed it, just wanted to share some rendering glitches on Safari iOS: also, the + button needs and outline so that it looks a bit more visually similar to the swatches can we make the name editing UI a bit less prominent than the color editing UI? When both are editable, there is currently nothing to guide the eye, and I think when both are editable, the color is edited a lot more |
// Re-render swatches | ||
// Only if nothing is being edited, otherwise the input would be lost | ||
// or, e.g., "red" would be converted to "rgb(100%, 0%, 0%)" right after the typing is done | ||
this.render(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest instead checking if it's focused (via document.activeElement
IIRC). It's entirely possible that it's editable but nobody is interacting with it right now, in which case re-rendering would be fine, right?
Though re-rendering seems a very crude reaction to computedColors
changing, when does this actually happen? Is it when the entire array if overwritten? In that case I guess it makes sense…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest instead checking if it's focused (via
document.activeElement
IIRC). It's entirely possible that it's editable but nobody is interacting with it right now, in which case re-rendering would be fine, right?
You are absolutely right. Thank you for the idea. It works brilliantly.
Though re-rendering seems a very crude reaction to
computedColors
changing, when does this actually happen? Is it when the entire array if overwritten?
It does happen when this.colors
is overwritten; you are right.
Accept either the swatch to be updated or its index
Accept either the swatch to be updated or its index
Accept either the swatch to be deleted or its index
Don't handle `*-change` events until the newly created swatch is fully initialized.
Buttons in Safari don't have borders. As a result, the `Add button` doesn't look like a swatch (like it does in other browsers).
…n't need to use it with inline SVGs)
424a32b
to
49fb4d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to review the code, but left some comments about the design/docs.
Live preview: https://deploy-preview-167--color-elements.netlify.app/src/color-scale/#the-editable-attribute