termcol: move common styling to css include
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 1 Nov 2015 19:06:34 +0000 (20:06 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 5 Jan 2016 00:05:07 +0000 (01:05 +0100)
Reduces page size from 109kB to 88kB (though only 400 bytes over 12kB
compressed) for 140 bytes general css (35 bytes or less download).

base.css
termcol.plp

index 7b8586ec4d436b058e5e3eb1a2d384488434c3e8..eb181287143f8c86dd6644f121e0efbf2a6753a9 100644 (file)
--- a/base.css
+++ b/base.css
@@ -232,7 +232,7 @@ th,
 tfoot td,
 thead td {
        border: 0;
 tfoot td,
 thead td {
        border: 0;
-       background: transparent !important;
+       background: transparent;
 }
 .glyphs thead td {
        width: auto; /* no glyph cells in header */
 }
 .glyphs thead td {
        width: auto; /* no glyph cells in header */
@@ -256,6 +256,17 @@ tfoot .cat th {
        border-top: 1px solid #888;
 }
 
        border-top: 1px solid #888;
 }
 
+/* colour map */
+
+table.color th {
+       border: 1px solid #555;
+       font-weight: normal;
+       padding: 0 1ex;
+}
+table.color th ~ td {
+       font-family: monospace;
+}
+
 /* digraphs map */
 
 table.dimap {
 /* digraphs map */
 
 table.dimap {
index 32a73560285a0fb4a9f096b859b3ee1404536972..e544bf700262ceb10e263a0d11f5d52be024f9f6 100644 (file)
@@ -58,12 +58,12 @@ sub colcell {
        my $sample = [ qw(#000 #FFF) ];
        ($name, $sample) = @$name if ref $name eq 'ARRAY';
 
        my $sample = [ qw(#000 #FFF) ];
        ($name, $sample) = @$name if ref $name eq 'ARRAY';
 
-       my $out = sprintf('<td title="%s" style="%s">%s',
+       my $out = sprintf('<th title="%s" style="%s">%s',
                join(',', map { int } @$col),
                join(',', map { int } @$col),
-               "background:$css; color:$inverse; padding:0 1ex",
+               "background:$css; color:$inverse",
                $name,
        );
                $name,
        );
-       $out .= sprintf '<td style="%s"><code>%s</code>', "background:$_; color:$css", $minhex
+       $out .= sprintf '<td style="%s">%s', "background:$_; color:$css", $minhex
                for @$sample;
        return "$out\n";
 }
                for @$sample;
        return "$out\n";
 }
@@ -83,7 +83,7 @@ for my $term (@termlist) {
        ) if $info->{href} or $info->{title};
 
        if (my $mapinfo = $info->{rgbmap}) {
        ) if $info->{href} or $info->{title};
 
        if (my $mapinfo = $info->{rgbmap}) {
-               print '<table class="mapped">'."\n";
+               print '<table class="color mapped">'."\n";
                printf "<caption>%s</caption>\n", $caption;
                print coltable_hsv(@{$mapinfo});
                print "</table>\n\n";
                printf "<caption>%s</caption>\n", $caption;
                print coltable_hsv(@{$mapinfo});
                print "</table>\n\n";
@@ -94,7 +94,7 @@ for my $term (@termlist) {
                        $colours = [ map { $colours->[$_] =~ s/:|$/:$_/r } @{$reorder} ];
                }
 
                        $colours = [ map { $colours->[$_] =~ s/:|$/:$_/r } @{$reorder} ];
                }
 
-               print '<table>', "\n";
+               print '<table class=color>', "\n";
                printf "<caption>%s</caption>\n", $caption;
                for my $num (0 .. $#{$colours}) {
                        my ($rgb, $name) = split /:/, $colours->[$num], 3;
                printf "<caption>%s</caption>\n", $caption;
                for my $num (0 .. $#{$colours}) {
                        my ($rgb, $name) = split /:/, $colours->[$num], 3;