nixfiles/libs/web/lib/css/default.nix
Sebastian Walz 860d31cee1
Tohu vaBohu
2023-04-21 00:22:52 +02:00

54 lines
1.5 KiB
Nix

{ core, ... }:
let
inherit(core) debug indentation list path set string type;
formatAttributes
= prefix:
{ ... } @ attributes:
list.concat
(
set.mapToList
(
name:
value:
if set.isInstanceOf value
&& value.__toString or null == null
then
formatAttributes "${prefix}${name}-" value
else
[ "${prefix}${name}: ${string value};" ]
)
attributes
);
CSS
= type "CSS"
{
from
= { ... } @ definition:
CSS.instanciate
{
inherit definition;
__toString
= { definition, ... }:
indentation {}
(
list.concat
(
set.mapToList
(
selector:
{ ... } @ attributes:
[ "${selector} {" indentation.more ]
++ (formatAttributes "" attributes)
++ [ indentation.less "}" ]
)
definition
)
);
};
};
in
CSS // { inherit CSS; }