madskristensen / EditorColorPreview

Apache License 2.0
21 stars 5 forks source link

Add support for CSS Color Module Level 4 #5

Closed y2k4life closed 2 years ago

y2k4life commented 2 years ago

What started out as adding supporting for hsl(200deg 75% 5%) turned into a project to support all of CSS Color Module Level 4.

Add support for serializing spaces, comas, %, deg, slash, and none. Add support for resolving all sRGB functions rgb(), rgba(), hsl(), hsla(), hwb(). Add resolving support for none sRGB functions lab(), lch(), oklab(), and oklch(). Add support for resolving color spaces using the color function color(). There is one caveats, not with the code, but with supporting color spaces with large gamut than the sRGB color space. Without support for different color spaces and large gamut the colors are converted to sRGB. Some colors might not convert properly. Knowing these are edge cases I added them anyways. For future proofing, when Windows, Visual Studio, web browsers, and the hardware is there to support them and people buy the hardware. At that time the code can be changed 😀.

I added unit testing to help support the various color functions and the regex matching logic. I'm no regex expert, but I think I have that nailed down.

Here is an example in a SASS file

image

madskristensen commented 2 years ago

This is absolutely fantastic. Thank you so much. It looks like a .props file is missing which is why the build failed?

y2k4life commented 2 years ago

Thank you. The build failed due to a reference used for Unit Testing.

This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. MSTest.TestAdapter.2.2.7

y2k4life commented 2 years ago

I don't know if this will help, when I created the test project the targeted framework was 4.7.2. I changed to 4.8 but the packages did not update. I made those changes. I update the packages and the targeted framework.

madskristensen commented 2 years ago

Ah, it's the restore that fails in the GitHub Action. It may be because you're using packages.config instead of <packagereference>

madskristensen commented 2 years ago

In .github/workflows/build.yaml you can add a Restore task like this if you don't want to convert to :

- name: Restore
  run: nuget restore -v quiet

- name: Build
  run: msbuild /v:m -restore /p:OutDir=\_built
y2k4life commented 2 years ago

It has been a while since I used Framework, never knew there was a PackageReference thing. Odd that the VS tooling implemented the old way.

madskristensen commented 2 years ago

Thank you!

madskristensen commented 2 years ago

I disabled the lch tests, since they didn't pass (except for one of them)