Modules/Color: Add hex string representation (e.g. "#123456" instead of "123456")
This commit is contained in:
@ -16,46 +16,61 @@ in {
|
|||||||
colorKeys = builtins.attrNames lightDefs;
|
colorKeys = builtins.attrNames lightDefs;
|
||||||
|
|
||||||
mkColorAssignment = defs: key: {${key} = defs.${key};};
|
mkColorAssignment = defs: key: {${key} = defs.${key};};
|
||||||
|
mkStringColorAssignment = defs: key: {${key} = "#${defs.${key}}";};
|
||||||
mkRgbColorAssignment = defs: key: {${key} = mylib.color.hexToRGB defs.${key};};
|
mkRgbColorAssignment = defs: key: {${key} = mylib.color.hexToRGB defs.${key};};
|
||||||
mkRgbStringColorAssignment = defs: key: {${key} = mylib.color.hexToRGBString "," defs.${key};};
|
mkRgbStringColorAssignment = defs: key: {${key} = mylib.color.hexToRGBString "," defs.${key};};
|
||||||
in {
|
in {
|
||||||
# This module sets its own options
|
# This module sets its own options
|
||||||
# to the values specified in a colorscheme file.
|
# to the values specified in a colorscheme file.
|
||||||
|
# TODO: This is fucking stupid. Add an option to set a colorscheme,
|
||||||
|
# then provide a single hex/rgb/rgbString set, not this light/dark shit.
|
||||||
modules.color = {
|
modules.color = {
|
||||||
hex = {
|
hex = {
|
||||||
light = lib.pipe colorKeys [
|
light =
|
||||||
(builtins.map (mkColorAssignment lightDefs))
|
colorKeys
|
||||||
lib.mergeAttrsList
|
|> builtins.map (mkColorAssignment lightDefs)
|
||||||
];
|
|> lib.mergeAttrsList;
|
||||||
|
|
||||||
dark = lib.pipe colorKeys [
|
dark =
|
||||||
(builtins.map (mkColorAssignment darkDefs))
|
colorKeys
|
||||||
lib.mergeAttrsList
|
|> builtins.map (mkColorAssignment darkDefs)
|
||||||
];
|
|> lib.mergeAttrsList;
|
||||||
|
};
|
||||||
|
|
||||||
|
hexString = {
|
||||||
|
light =
|
||||||
|
colorKeys
|
||||||
|
|> builtins.map (mkStringColorAssignment lightDefs)
|
||||||
|
|> lib.mergeAttrsList;
|
||||||
|
|
||||||
|
dark =
|
||||||
|
colorKeys
|
||||||
|
|> builtins.map (mkStringColorAssignment darkDefs)
|
||||||
|
|> lib.mergeAttrsList;
|
||||||
};
|
};
|
||||||
|
|
||||||
rgb = {
|
rgb = {
|
||||||
light = lib.pipe colorKeys [
|
light =
|
||||||
(builtins.map (mkRgbColorAssignment lightDefs))
|
colorKeys
|
||||||
lib.mergeAttrsList
|
|> builtins.map (mkRgbColorAssignment lightDefs)
|
||||||
];
|
|> lib.mergeAttrsList;
|
||||||
|
|
||||||
dark = lib.pipe colorKeys [
|
dark =
|
||||||
(builtins.map (mkRgbColorAssignment darkDefs))
|
colorKeys
|
||||||
lib.mergeAttrsList
|
|> builtins.map (mkRgbColorAssignment darkDefs)
|
||||||
];
|
|> lib.mergeAttrsList;
|
||||||
};
|
};
|
||||||
|
|
||||||
rgbString = {
|
rgbString = {
|
||||||
light = lib.pipe colorKeys [
|
light =
|
||||||
(builtins.map (mkRgbStringColorAssignment lightDefs))
|
colorKeys
|
||||||
lib.mergeAttrsList
|
|> builtins.map (mkRgbStringColorAssignment lightDefs)
|
||||||
];
|
|> lib.mergeAttrsList;
|
||||||
|
|
||||||
dark = lib.pipe colorKeys [
|
dark =
|
||||||
(builtins.map (mkRgbStringColorAssignment darkDefs))
|
colorKeys
|
||||||
lib.mergeAttrsList
|
|> builtins.map (mkRgbStringColorAssignment darkDefs)
|
||||||
];
|
|> lib.mergeAttrsList;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -33,6 +33,11 @@ with mylib.modules; {
|
|||||||
description = "Colors in \"RRGGBB\" hexadecimal format";
|
description = "Colors in \"RRGGBB\" hexadecimal format";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
hexString = mkOption {
|
||||||
|
type = types.attrs;
|
||||||
|
description = "Colors in \"#RRGGBB\" hexadecimal format";
|
||||||
|
};
|
||||||
|
|
||||||
rgbString = mkOption {
|
rgbString = mkOption {
|
||||||
type = types.attrs;
|
type = types.attrs;
|
||||||
description = "Colors in \"RR,GG,BB\" decimal format";
|
description = "Colors in \"RR,GG,BB\" decimal format";
|
||||||
|
Reference in New Issue
Block a user