Menu

Server-rendered color conversion: making a utility work with JavaScript off
πŸ“°

Server-rendered color conversion: making a utility work with JavaScript off

DEV Community: cssΒ·neo xiaΒ·10 days ago
#iaAO3OdM
#devtocss#devto#dev#result#form
Long article (603 words) β€” no AI summary yet.
Reading 0:00
15s threshold

Most color converters are a small client-side app wrapped around a hex field. That works until someone opens the link in a locked-down browser, a print shop machine with half the extensions disabled, or wants to hand the result to a colleague and have the URL actually mean something.

I built HueConvert around the opposite constraint: the conversion happens on the server, and the URL carries the state. These are the choices that came out of it β€” useful if you maintain a small utility site where a JavaScript error should never be the reason someone cannot get an answer.

One field, four formats

The main input accepts all four syntaxes people actually paste:

#F26B4F and the short #F64

rgb(242, 107, 79) , and percentage channels

cmyk(0%, 60%, 69%, 0%)

hsl(10, 100%, 66%)

Parsing order matters. Try HEX first because a leading # is unambiguous, then the function forms with a strict regex, then reject everything else with a message that shows a valid example instead of a generic "invalid input".…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.