By neildaemond, an 'any-stack' hacking grasshopper.
Taking notes while tinkering with:
Create a hexadecimal colour based on a string with Elm
I had an html table of categorized items, and I wanted to give each category it’s own Color automatically. So I thought I’d hash the category ID String into an HTML Hexidecimal Color. A search will find this stack overflow post, but I was using elm and thought it would be a fun task to translate this function into a funcitonal style. Here’s how that went:
and I ended up with:
then, in each table row’s first
td, I could add I colour indicator as follows:
td [style[("border-left","10pt solid " ++ (stringToHexColor item_variable.id))] ] [ text "The Item Name"]