Implement Bun.color(input: string, outputFormat)#14170
Merged
Jarred-Sumner merged 18 commits intozack/cssfrom Sep 26, 2024
Merged
Implement Bun.color(input: string, outputFormat)#14170Jarred-Sumner merged 18 commits intozack/cssfrom
Bun.color(input: string, outputFormat)#14170Jarred-Sumner merged 18 commits intozack/cssfrom
Conversation
Collaborator
|
❌ @Jarred-Sumner, your commit bae1e69 has 10 failures in test/js/node/watch/fs.watch.test.ts - 2 failing on 🍎 14 x64test/js/web/fetch/fetch-tcp-stress.test.ts - timeout on 🍎 13 x64test/js/web/fetch/fetch-tcp-stress.test.ts - timeout on 🍎 14 x64test/integration/next-pages/test/dev-server.test.ts - 1 failing on 🍎 14 aarch64test/cli/install/bunx.test.ts - timeout on 🐧 12 aarch64test/js/web/streams/streams.test.js - 1 failing on 🍎 14 aarch64test/js/web/streams/streams.test.js - 1 failing on 🍎 13 x64test/js/web/streams/streams.test.js - 1 failing on 🍎 14 x64test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🍎 13 x64test/cli/install/registry/bun-install-registry.test.ts - 1 failing on 🍎 14 x64test/cli/hot/watch.test.ts - 1 failing on 🪟 x64test/cli/hot/watch.test.ts - 1 failing on 🪟 x64-baselinetest/cli/watch/watch.test.ts - 2 failing on 🪟 x64test/cli/watch/watch.test.ts - 2 failing on 🪟 x64-baselinetest/js/bun/http/fetch-file-upload.test.ts - 1 failing on 🪟 x64-baselinetest/js/bun/css/color.test.ts - annotation error on 🪟 x64-baselinetest/js/bun/css/color.test.ts - annotation error on 🪟 x64test/js/bun/css/color.test.ts - annotation error on 🐧 12 x64-baselinetest/js/bun/css/color.test.ts - annotation error on 🐧 22.04 x64-baselinetest/js/bun/css/color.test.ts - annotation error on 🐧 20.04 x64-baselinetest/js/bun/css/color.test.ts - annotation error on 🍎 13 aarch64test/js/bun/css/color.test.ts - annotation error on 🍎 14 aarch64test/js/bun/css/color.test.ts - annotation error on 🐧 22.04 x64test/js/bun/css/color.test.ts - annotation error on 🐧 12 x64test/js/bun/css/color.test.ts - annotation error on 🐧 20.04 x64test/js/bun/css/color.test.ts - annotation error on 🍎 13 x64test/js/bun/css/color.test.ts - annotation error on 🐧 22.04 aarch64test/js/bun/css/color.test.ts - annotation error on 🐧 20.04 aarch64test/js/bun/css/color.test.ts - annotation error on 🐧 12 aarch64test/js/bun/css/color.test.ts - annotation error on 🍎 14 x64 |
190n
reviewed
Sep 25, 2024
|
|
||
| ```ts | ||
| Bun.color("red", "css"); // "red" | ||
| Bun.color(0xff0000, "css"); // "#f000" |
Contributor
There was a problem hiding this comment.
Isn't this wrong? #f000 (4 digits) is transparent but #ff0000 (6 digits) is opaque. Was the input meant to be #ff000000 (eight digits)?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Bun.color(input, outputFormat?)leverages Bun's CSS parser to parse, normalize, and convert colors from user input to a variety of output formats, including:"css""red""ansi""\x1b[38;2;255;0;0m""ansi-16""\x1b[38;5;\tm""ansi-256""\x1b[38;5;196m""ansi-16m""\x1b[38;2;255;0;0m""number"0x1a2b3c"rgb""rgb(255, 99, 71)""rgba""rgba(255, 99, 71, 0.5)""hsl""hsl(120, 50%, 50%)""hex""#1a2b3c""HEX""#1A2B3C""{rgb}"{ r: 255, g: 99, b: 71 }"{rgba}"{ r: 255, g: 99, b: 71, a: 1 }"[rgb]"[ 255, 99, 71 ]"[rgba]"[ 255, 99, 71, 255]How did you verify your code works?
Tests