feat: better header styling for basic
This commit is contained in:
parent
caf60bb107
commit
1a3b70b4c3
10
css.nix
10
css.nix
@ -3,18 +3,16 @@ let
|
|||||||
inherit (utils) mapAttrsToList concatStringsSep isList toString map;
|
inherit (utils) mapAttrsToList concatStringsSep isList toString map;
|
||||||
|
|
||||||
evalCssValue = value: if isList value then concatStringsSep ", " (map toString value) else toString value;
|
evalCssValue = value: if isList value then concatStringsSep ", " (map toString value) else toString value;
|
||||||
evalInner = inner: concatStringsSep "\n" (mapAttrsToList (name: value: "${name}: ${evalCssValue value};") inner);
|
evalInner = inner: concatStringsSep " " (mapAttrsToList (name: value: "${name}: ${evalCssValue value};") inner);
|
||||||
css = maybeAttrs:
|
css = maybeAttrs:
|
||||||
if isList maybeAttrs
|
if isList maybeAttrs
|
||||||
then concatStringsSep "\n" maybeAttrs
|
then concatStringsSep " " maybeAttrs
|
||||||
else concatStringsSep "\n" (mapAttrsToList (name: inner: "${name} {\n${evalInner inner}\n}") maybeAttrs);
|
else concatStringsSep " " (mapAttrsToList (name: inner: "${name} { ${evalInner inner} }") maybeAttrs);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit css;
|
inherit css;
|
||||||
|
|
||||||
media = rule: inner: ''
|
media = rule: inner: ''
|
||||||
@media (${rule}) {
|
@media (${rule}) { ${css inner} }
|
||||||
${css inner}
|
|
||||||
}
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
2
tags.nix
2
tags.nix
@ -6,7 +6,7 @@ let
|
|||||||
evalChildren = children: if isList children then concatStrings children else children;
|
evalChildren = children: if isList children then concatStrings children else children;
|
||||||
tag = name: maybeAttrs:
|
tag = name: maybeAttrs:
|
||||||
if isAttrs maybeAttrs
|
if isAttrs maybeAttrs
|
||||||
then (children: "<${name}${evalAttrs maybeAttrs}>\n ${evalChildren children}\n</${name}>\n")
|
then (children: "<${name}${evalAttrs maybeAttrs}>${evalChildren children}</${name}>")
|
||||||
else tag name { } maybeAttrs;
|
else tag name { } maybeAttrs;
|
||||||
noChildrenTag = name: attrs: "<${name} ${evalAttrs attrs}>";
|
noChildrenTag = name: attrs: "<${name} ${evalAttrs attrs}>";
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{ utils, posts, pkgs, config, pages, site, baseurl, ... }@context:
|
{ utils, posts, pkgs, config, pages, site, baseurl, ... }@context:
|
||||||
let
|
let
|
||||||
inherit (utils) readFile mapAttrsToList mapAttrs tags fetchGit map elemAt foldl';
|
inherit (utils) readFile mapAttrsToList mapAttrs tags fetchGit map elemAt foldl' concatStrings genAttrs toString;
|
||||||
inherit (pkgs.lib) optional length splitString nameValuePair;
|
inherit (pkgs.lib) optional length splitString nameValuePair toInt range mapAttrs';
|
||||||
|
|
||||||
stylesheets = map tags.mkStylesheet [
|
stylesheets = map tags.mkStylesheet [
|
||||||
"https://unpkg.com/purecss@2.0.6/build/pure-min.css"
|
"https://unpkg.com/purecss@2.0.6/build/pure-min.css"
|
||||||
@ -15,8 +15,8 @@ let
|
|||||||
id = elemAt parts 1;
|
id = elemAt parts 1;
|
||||||
in
|
in
|
||||||
with tags; article [
|
with tags; article [
|
||||||
(a { href = "#${id}"; class = "postheader"; } (h3 { inherit id; } ("## " + id)))
|
(a { href = "#${id}"; class = "postheader"; } (h2 { inherit id; } id))
|
||||||
(h6 ("date: " + (elemAt parts 0)))
|
(h3 ("date: " + (elemAt parts 0)))
|
||||||
value
|
value
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -26,12 +26,12 @@ let
|
|||||||
(mapAttrsToList (name: _: name) pages)) ++ [ (tags.div { class = "pure-u-1"; } (tags.a { href = "${baseurl}"; class = "pagelink"; } "posts")) ];
|
(mapAttrsToList (name: _: name) pages)) ++ [ (tags.div { class = "pure-u-1"; } (tags.a { href = "${baseurl}"; class = "pagelink"; } "posts")) ];
|
||||||
|
|
||||||
postsSectionContent = with tags; [
|
postsSectionContent = with tags; [
|
||||||
(a { href = "#posts"; class = "postheader"; } (h1 "# posts"))
|
(a { href = "#posts"; class = "postheader"; } (h1 "posts"))
|
||||||
] ++ (map renderPost posts);
|
] ++ (map renderPost posts);
|
||||||
|
|
||||||
sidebarSection = optional ((length pagesSection) > 0) (
|
sidebarSection = optional ((length pagesSection) > 0) (
|
||||||
with tags; nav { class = "sidebar"; } ([
|
with tags; nav { class = "sidebar"; } ([
|
||||||
(a { href = "#pages"; class = "postheader"; } (h1 "# pages"))
|
(a { href = "#pages"; class = "postheader"; } (h1 "pages"))
|
||||||
(div { class = "pure-g"; } pagesSection)
|
(div { class = "pure-g"; } pagesSection)
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
@ -57,43 +57,49 @@ let
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
css [
|
css [
|
||||||
(css {
|
(css (
|
||||||
body = {
|
(
|
||||||
font-family = [ "Raleway" "Helvetica" "Arial" "sans-serif" ];
|
mapAttrs'
|
||||||
background = "#111111";
|
(name: value: nameValuePair value { content = "\"${concatStrings (map (_: "#") (range 1 (toInt name)))} \""; })
|
||||||
color = "#eeeeee";
|
(genAttrs (n: "h${toString n}:before") (map toString (range 1 6)))
|
||||||
};
|
) // {
|
||||||
pre = {
|
body = {
|
||||||
font-family = [ "Iosevka Term" "Iosevka" "monospace" ];
|
font-family = [ "Raleway" "Helvetica" "Arial" "sans-serif" ];
|
||||||
background = "#171A21";
|
background = "#111111";
|
||||||
color = "#eeeeee";
|
color = "#eeeeee";
|
||||||
};
|
};
|
||||||
"a,a:hover" = {
|
pre = {
|
||||||
color = "#ffd814";
|
font-family = [ "Iosevka Term" "Iosevka" "monospace" ];
|
||||||
text-decoration = "none";
|
background = "#171A21";
|
||||||
};
|
color = "#eeeeee";
|
||||||
"a:hover" = {
|
};
|
||||||
text-decoration = "underline";
|
"a,a:hover" = {
|
||||||
};
|
color = "#ffd814";
|
||||||
"a.postheader,a.postheader:hover" = {
|
text-decoration = "none";
|
||||||
color = "#fc6711";
|
};
|
||||||
};
|
"a:hover" = {
|
||||||
"a.pagelink,a.pagelink:hover" = {
|
text-decoration = "underline";
|
||||||
color = "#ffd814";
|
};
|
||||||
};
|
"a.postheader,a.postheader:hover" = {
|
||||||
"div.content" = {
|
color = "#fc6711";
|
||||||
margin-top = "5%";
|
};
|
||||||
margin-bottom = "5%";
|
"a.pagelink,a.pagelink:hover" = {
|
||||||
margin-left = "20%";
|
color = "#ffd814";
|
||||||
margin-right = "10%";
|
};
|
||||||
};
|
"div.content" = {
|
||||||
"nav.sidebar" = {
|
margin-top = "5%";
|
||||||
position = "fixed";
|
margin-bottom = "5%";
|
||||||
top = 0;
|
margin-left = "20%";
|
||||||
margin-left = "3%";
|
margin-right = "10%";
|
||||||
z-index = 1000;
|
};
|
||||||
};
|
"nav.sidebar" = {
|
||||||
})
|
position = "fixed";
|
||||||
|
top = 0;
|
||||||
|
margin-left = "3%";
|
||||||
|
z-index = 1000;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
))
|
||||||
(media "max-width: 48em" {
|
(media "max-width: 48em" {
|
||||||
"nav.sidebar" = {
|
"nav.sidebar" = {
|
||||||
position = "relative";
|
position = "relative";
|
||||||
|
Loading…
Reference in New Issue
Block a user