question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a formatHsl formatter

See original GitHub issue

Firstly, thanks for the great library!

With our usecase we want to be able to output color strings for hex, rgb, and hsl, though culori doesn’t currently support hsl. For now I’ve just written my own stringifier but it feels like this might make sense in the library itself.

Proposed solution

Following the existing formatter API, it would accept a color or string and then return hsl/hsla based on whether there’s an alpha less than 1.

culori.formatHsl('tomato')

I’m not super familiar with culori internals, but I see that hex/rgb handle the fixups from within the rgb color mode. Is there a way we can do the same thing with hsl? Is this something you would accept a PR for?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
danburzocommented, Jul 23, 2021

Added a first pass at the implementation in #130. Currently h, s and l are rounded to the nearest integer. Both rgb() and hsl() color notations explicitly accept float values in CSS Color 4 but I’m not sure what the support story is for floats in the hsl() notation. If it’s as patchy as for rgb(), then I think it would be best to round the values in hsl as well. Otherwise, 2-digit precision floats sound better to me. Maybe there are some Web Platform Tests about this specifically…

1reaction
johnocommented, Jul 30, 2021

Thank you very much @danburzo. Your work and library are greatly appreciated!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Free Online HTML Formatter - FreeFormatter.com
This free online HTML formatter and validator lets you chose your indentation level and also lets you export to file.
Read more >
HTML Formatter
Free online tool to format an ugly HTML code, making it readable and pretty, with the proper indentation. Autodetect HTML XML CSS JavaScript...
Read more >
Online HTML formatter, HTML beautifier - SmallDev.tools
HTML Beautifier /formatter is an online Tool to easily beautify your HTML code. Paste any minified codes or unindented codes and you'll get...
Read more >
HTML Text Formatting - W3Schools
HTML Formatting Elements · <b> - Bold text · <strong> - Important text · <i> - Italic text · <em> - Emphasized text...
Read more >
HTML Viewer - Code Beautify
Online HTML Viewer, HTML Beautifier, HTML Formatter, HTML Editor to Test output - Convert HTML Strings to a Friendly Readable Format, Beautify.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found