11.stylix/stylix/colors.nix
eveeifyeve 1a83d26d4c
stylix: add config.lib.stylix.{mkHexColor,mkOpacityHexColor} functions
Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
2025-09-08 18:55:38 +02:00

16 lines
486 B
Nix

{ lib, ... }:
{
config.lib.stylix = {
mkHexColor = color: "0x${lib.removePrefix "#" color}";
mkOpacityHexColor =
let
opacityHex =
percentage:
lib.throwIfNot (percentage >= 0 && percentage <= 1)
"value must be between 0 and 1 (inclusive): ${toString percentage}"
(lib.toHexString (builtins.floor (percentage * 255 + 0.5)));
in
color: opacity: "0x${opacityHex opacity}${lib.removePrefix "#" color}";
};
}