$(function(){
- const nav = $('nav')[0];
+ const nav = q('nav');
nav.classList.add('hidden-xs');
- $('#title')[0].insertAdjacentHTML('beforebegin', '<div class="text-center visible-xs-block">Tap title to toggle menu</div>');
+ q('#title').insertAdjacentHTML('beforebegin', '<div class="text-center visible-xs-block">Tap title to toggle menu</div>');
- $('#title').on('click', () => nav.classList.toggle('hidden-xs'));
+ $('#title,#logo').on('click', () => nav.classList.toggle('hidden-xs'));
});
document.body.classList.add('transition-color');
setTimeout(() => document.body.classList.remove('transition-color'), 1000);
}
- $('link[title]').each(e => e.disabled = true);
- $('link[title="' + name + '"]')[0].disabled = false;
+ q('html').className = name;
localStorage.setItem("theme", name);
+ $(function() {
+ if(name == 'slate' || name == 'cyborg')
+ $('img').each(e => e.setAttribute('src', e.getAttribute('src').replace('logos/light', 'logos/dark')));
+ else
+ $('img').each(e => e.setAttribute('src', e.getAttribute('src').replace('logos/dark', 'logos/light')));
+ });
}
$(function() {
\@blocks
}
-my $default_theme = 'cyborg';
++my $default_theme = 'slate';
+
+ sub theme_prefix {
+ my ($theme, $decl, $default) = @_;
+ return $decl if $theme eq $default_theme || !$decl;
+ return '' if $decl eq $default;
+
+ $default =~ s/[^{]*{\n//;
+ $default =~ s/\n}[^}]*//;
+ $decl =~ s/^$_$//m for split "\n", $default;
+ $decl =~ s/\n+/\n/g;
+
+ my $prefix = "html.$theme";
+ my ($first_line) = $decl =~ /([^{]*){/;
+ $first_line =~ s/(,\s+)/$1 $prefix /g;
+ $first_line = "$prefix $first_line";
+ $decl =~ s/([^{]*){/$first_line\{/;
+ $decl
+ }
+
sub make_css {
- my %css;
- $css{common} .= read_file $_ for <css/*.css>;
+ my $css = join '', map { read_file $_ } <css/*.css>;
- my (%themes, $rndtheme);
+ my (%themes);
for (<css/themes/*>) {
- ($rndtheme) = m,themes/(.*)\.css,;
- $themes{$rndtheme} = read_css_into_blocks $_;
+ my ($theme) = m,themes/(.*)\.css,;
+ $themes{$theme} = read_css_into_blocks $_;
}
+ my @themes = sort grep { $_ ne $default_theme } keys %themes;
while (grep { scalar @$_ } values %themes) {
my %blocks = map { $_ => (shift @{$themes{$_}}) // '' } keys %themes;
system 'cp', '-rp', 'js', 'static/';
}
- my $css_mtime = -M 'static/css/slate.css' // 0;
+my $sprite_mtime = -M 'static/logos/dark.svg' // 0;
+for (<logos/*>, <logos-light/*>) {
+ if (!$sprite_mtime || $sprite_mtime > -M) {
+ make_logos;
+ last
+ }
+}
+
+ my $css_mtime = -M 'static/css/all.css' // 0;
for (<css/*>, <css/themes/*>) {
if (!$css_mtime || $css_mtime > -M) {
make_css;
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link href="/static/css/common.css" rel="stylesheet" integrity="x">
- <link href="/static/css/cyborg.css" title="cyborg" rel="alternate stylesheet" integrity="x">
- <link href="/static/css/slate.css" title="slate" rel="stylesheet" integrity="x">
- <link href="/static/css/readable.css" title="readable" rel="alternate stylesheet" integrity="x">
+<link href="/static/favicon.png" rel="shortcut icon">
+ <link href="/static/css/all.css" rel="stylesheet" integrity="x">
<script src="/static/js/all.js" type="text/javascript" async defer integrity="x"></script>
<body>