npm package published! #33
Replies: 8 comments 10 replies
-
Thanks! Great news! We are going to check it out. |
Beta Was this translation helpful? Give feedback.
-
Fantastic, thank you! |
Beta Was this translation helpful? Give feedback.
-
That's great! We'll pull these updates in soon. |
Beta Was this translation helpful? Give feedback.
-
@Myndex it may be easier to use if the JS you distribute on npm is exported as a javascript module. Eg, at the end of the file, adding
Prior to the npm module release, I manually added this module exports statement to the end of the APCA file in order to access the functions in my own scripts. Then, for the npm readme guidelines, I would expect to see an example of the import as well:
It's also unclear if the
Additional CSS Module level 4 color formats that would be desirable:
The specifics behind the request to support those string formats is that they are more likely to be used in web applications. However, object or coordinate arrays would be ok as well, however more formatting structure would be needed (eg, Example of basic usage that I would expect
Please let me know if I'm missing something obvious that would have answered these questions/concerns elsewhere :-) |
Beta Was this translation helpful? Give feedback.
-
@Myndex @NateBaldwinDesign my 2c for the discussion: I think we definitely need module exports to be able to use the package but I would say I'd prefer to remove any color parsing from the package. E.g., in Chrome DevTools we already have code dealing with color parsing and there is no need to duplicate the code inside the APCA package. I assume there are many 3rd party libs for color parsing too. Therefore, I'd suggest to consider removing color parsing in the NPM package and accepting only the raw color data (e.g., ints or rgb array). Converting different color spaces to Y would also ideally accept raw data so that the package does not need to contain parsing logic. |
Beta Was this translation helpful? Give feedback.
-
@Myndex this got me thinking. Does APCA return different contrast values between sRGB and Display P3? If so, this could be a complex issue. Colors for user interface design are typically used across devices (iOS/Android/Web) so one platform may render the RGB in Display P3, whereas another would render it in sRGB. And while there are ways to transform between those spaces for platforms that support one or the other, desktop can be a different beast. For example, you may design an application that on MacOS is shown in Display P3 on the native display (eg, the display of a macbook pro). A user, however, may have peripheral displays (like I do) that only support sRGB. So the application may meet contrast requirements when displayed in Display P3, but not in sRGB (or vice versa) if that's what I'm reading into here. What are your thoughts? |
Beta Was this translation helpful? Give feedback.
-
An npm version apca-w3-0.0.98-g-4g.2. that should address the export issue is just published, and next I will address the array-as-input A question: so in the npm package, is the preferred embodiment to leave the parsing function, bu just have it so that if can be imported or not imported? So:
And then you just not import colorParsley() if it's not needed? I would prefer to keep this as all one package with no dependencies... |
Beta Was this translation helpful? Give feedback.
-
Here's a stab at supporting all the various JS module formats, using some build tooling: Myndex/apca-w3#1 Also added a demo page, to test out the NPM package, as well as start exploring a "calculator"/"checker" interface that's more plug-and-play than the table format. That's a separate discussion though. Would appreciate if anyone with strong opinions on how to publish NPM packages in 2021 could weigh in on the dist output (it's currently cjs, esm, and umd via |
Beta Was this translation helpful? Give feedback.
-
Hello -- @tkeenoy @joshuakraemer @OrKoN @UXPublishing @abdulmhamid @NateBaldwinDesign @markov00
Just wanted to let you know that we finally have an npm package to make APCA updates easier.
https://www.npmjs.com/package/apca-w3
And the new API is trivially easy — you can send the colors as hex strings (#abc123), as rgb(0,0,0), as named colors (magenta, aquamarine), or as a 24 bit number (i.e. hex 0xf279a or decimal int 16123456)
Usage:
Lc = APCAcontrast(sRGBtoY(textColor),sRGBtoY(backgroundColor));
It returns a signed int, rounded to the nearest whole number.
Also, the font lookup table has been modified.
Thank you!
Andy
Beta Was this translation helpful? Give feedback.
All reactions