X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/41af4e92ea22b885a6651537e8780d7be6d27287..9ab0df43bbb8c43a31403d7e6810588e9de08da3:/common.inc.plp diff --git a/common.inc.plp b/common.inc.plp index 4bc68a6..fec7b57 100644 --- a/common.inc.plp +++ b/common.inc.plp @@ -54,8 +54,7 @@ our $style; $header{content_type} = 'text/html; charset=utf-8'; sub stylesheet { - my ($avail) = @_; - my @avail = ref $avail eq 'ARRAY' ? @{$avail} : $avail or return; + my @avail = qw( light dark circus mono red ); my %styles = map {$_ => $_} @avail; if (defined( my $setstyle = $get{style} )) { @@ -72,8 +71,8 @@ sub stylesheet { } or warn "Unable to create style cookie: $@"; } - $style ||= $styles{$_} for $cookie{style} || (); my $setstyle = $style; + $style ||= $styles{$_} for $cookie{style} || (); $style ||= $avail[0]; return $setstyle; } @@ -127,7 +126,6 @@ sub Html { } # default fallbacks - $meta->{stylesheet} ||= [qw( light dark circus mono red )]; $meta->{charset} ||= 'utf-8'; $meta->{lang} ||= 'en'; @@ -143,7 +141,7 @@ sub Html { unshift @{ $meta->{raw} }, ( '', ); - $meta->{stylesheet} = stylesheet($meta->{stylesheet}); + $meta->{stylesheet} = stylesheet(); if (my $img = $meta->{image}) { my $proto = sprintf('http%s://', !!$ENV{HTTPS} && 's'); @@ -180,19 +178,7 @@ sub Html { say ''; say for map { @{$_} } $meta->{raw} || (); say '' if $Dev; - say "" for join($/, - "docroot = document.documentElement;", - "if (docroot.className == '') {", - "new Map([", - "['s-mono','(monochrome)'],", - "['s-dark','(prefers-color-scheme: dark)'],", - "['s-circus','(prefers-contrast: more)'],", - "]).forEach((q,c) => {", - "if (m = window.matchMedia(q))", - "(m.onchange = e => docroot.classList.toggle(c, e.matches))(m)", - "})", - "}", - ); + say ''; say ''; say ''; say sprintf '', $file;