-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Implement Bun.color(input: string, outputFormat)
#14170
Conversation
❌ @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 |
|
||
```ts | ||
Bun.color("red", "css"); // "red" | ||
Bun.color(0xff0000, "css"); // "#f000" |
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.
Isn't this wrong? #f000
(4 digits) is transparent but #ff0000
(6 digits) is opaque. Was the input meant to be #ff000000
(eight digits)?
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.
@zackradisic do you know
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