1
Fork 0
mirror of https://github.com/RGBCube/ThemeNix synced 2025-07-28 17:07:46 +00:00

Only add prefix if field is a valid color

This commit is contained in:
RGBCube 2023-11-30 11:58:26 +03:00
parent fc43add106
commit de638a3a6f
No known key found for this signature in database

View file

@ -3,14 +3,17 @@
outputs = { self }: let
raw = import ./themes.nix;
isValidColor = thing: if builtins.isString thing then
(builtins.match "^[0-9a-fA-F]{6}" thing) != null
else
false;
in {
inherit raw;
custom = theme: let
onlyColors = builtins.removeAttrs theme [ "name" "author" ];
with0x = theme // (builtins.mapAttrs (_: value: "0x" + value) onlyColors);
withHashtag = theme // (builtins.mapAttrs (_: value: "#" + value) onlyColors);
with0x = theme // (builtins.mapAttrs (_: value: if isValidColor value then "0x" + value else value) theme);
withHashtag = theme // (builtins.mapAttrs (_: value: if isValidColor value then "#" + value else value) theme);
themeFull = theme // {
inherit with0x withHashtag;