Replies: 9 comments 13 replies
-
I think it would help to elaborate a bit on what problem you’re trying to solve. E.g. |
Beta Was this translation helpful? Give feedback.
-
I want to use So, it takes a DOM CSS string value ( |
Beta Was this translation helpful? Give feedback.
-
I use Color.js without the dependency because users pass in a Color instance. All I want is to be able to say something like:
though that would obviously require another property name. The tree-shakeable API also requires an |
Beta Was this translation helpful? Give feedback.
-
I’m sorry, I want to help, but I still don’t understand the use case. 😭 Let’s suppose Color.js had a colorInstance.coords = magic("color(display-p3 1 0.5 0)"); Wouldn’t you still have to import that function from Color.js? How would you use anything from Color.js without an import? 🤔
Not sure if that's the root of the confusion, but the tree-shakeable API does not use |
Beta Was this translation helpful? Give feedback.
-
@LeaVerou - Thanks for continuing to try :) I have definitely learned about the difference between
That snippet illustrates exactly how I do this without importing anything, all because the user provides me with As for the separate discussion about |
Beta Was this translation helpful? Give feedback.
-
Well, constraints are all self-imposed in this case, for what that's worth. This is a javascript library that allows doing more extreme animations, e.g. multiple timing functions, one for each of the three color parameters. In fleshing out the ability to animate colors, it struck me that I should allow users to use Color.js objects and avail themselves of the extended set of color spaces in their animations, as well as the ability to convert their CSS to other color spaces for purposes of animation (via each space's unique interpolation of changing values - did I use "interpolation" correctly there?). This library has no external dependencies at this time, and I am just trying to avoid adding one. I would be adding the only external dependency so that I could write a couple of lines of code differently, in a library that is not focused specifically on color. But this is a personal project and I can do whatever I want. I'm open to being convinced to add a dependency to Color.js, so give it your best shot. I am relatively new to javascript, and know next to nothing about building distribution packages with npm, pnpm, or yarn. I am learning everything as I go and haven't gotten there yet, though I hope to get there in the next couple of months. That's just some additional context regarding my ignorance and phobia of external dependencies here. I'll open a discussion on |
Beta Was this translation helpful? Give feedback.
-
You may not think you have any external dependencies right now but you have tied your library to objects that conform to portions of the Color.js api. So at some point the Color.js library will have to be bundled into an app using your library either by you or users of your library. I have a side project where I initially decided I didn't want to tie myself to a specific color library and I was going to create adapters for different javascript color libraries. I very quickly realized that was going to make things incredibly complicated and decided to go with Color.js as the color library for my project. |
Beta Was this translation helpful? Give feedback.
-
So what do you suggest that I do? And is "bundle" the same as "package" in the npm context? Or are you talking about some other kind of bundling? |
Beta Was this translation helpful? Give feedback.
-
Effectively that's correct. The detail being that the goal is to collect the coords + alpha (in They can also provide an array of Color instances (of any space) as a stand-in for the actual DOM values (animations generally start from an element's current value, but some jump to a new value at the start of playback). That's the case where I convert the color space id to snake_case so that I can use it as a property name. It's still simpler than using |
Beta Was this translation helpful? Give feedback.
-
Is there a way to set a Color instance's coordinates using a string, they way you can when you instantiate a Color, but without creating a new Color instance? Is there a way to do that via some subset of the
parse()
function? The idea is to workaroundnew Color()
because this is a library with no dependencies. I am currently faking it withnew colorInstance.constructor()
and passing in the string that way.Beta Was this translation helpful? Give feedback.
All reactions