here’s my situation
i have a theme (well, a status page) where people can define colors by hex code in config.yml
-
brand: 080d11
ok: 008000
disrupted: d33c0d
down: e60000
notice: 3a5978
problem is, if a hex code like 008000
is inputted, hugo (or i guess golang?) decides to cut off the first 2 digits?
.component[data-status="ok"] .component-status {
color: #8000;
}
it thinks it’s an octal, i believe?
has this behavior ever been discussed? it seems like a hostile default
This is a default in Go and it has come up here before although rarely.
The simplest workaround would be to convert the value into a string i.e. ok: "008000"
Why not defining it with hyphens and hashtag?
brand: "#080d11"
This way people could even use something like '#000" which is valid for black. If you need to do calculations in the back you could use SCSS functions that can work around the # or cut it off before calculating.
I don’t think you understand the nature of the project but I can kinda see where you’re coming from
there is already a # in the code, so “000” is already valid. since the project was supposed to be IE8+ - that browser only supports hex codes
no idea where scss could come into effect if the CSS is hard wired into a HTML style tag
Yes, you are right. But, well, the template should use #-less code.
The SCSS I am talking about is more or less the new pipes thingy that can do a lot of nice stuff compiling paths. You would need it only if you want to change colors to darker or lighter hues so for instance buttons look nicely.
In my opinion though themes should ALWAYS use “hashless” color style tags, because you could use a color like “lightblue” or “green” instead of a hex-code, or even a rgba(0,0,0,0.1) for the colors.
Keeping the hash in the template restricts users of that theme to using just hex-colors and that’s kinda 1990
have no idea what the heck scss pipe thingies are. I know there’s some newfangled stuff but didn’t really read into it
the project is supposed to be dead simple tho. rgba(), as I said, ain’t supported on those legacy browsers. I guess it’d make sense to remove the hash but that is a little bit hostile as it requires people changing an option seemingly no one has had a problem with when upgrading
open an issue?
I am sure if it’s connected to an issue it will be possible to add some kind of “if it has hashtag then … else add hashtag if it’s a hex code of length 6” routine to where ever these options are used. That will make it easy to slowly get people using hashtagged options (by not saying in the docs that they could use the hex-color-code without a hashtag). The easiest change is the one users don’t feel.
ignore me though, because onedrawingperday’s solution above works. I just tried to see the larger picture.
1 Like
thanks for the feedback!
i created an issue for this but it’s one of those things that should have been done properly but isn’t. might be effective to think of other ways people could manipulate the look/css apart from just a few config options.
if you’re interested, you can watch this issue