termcol: float text samples in cells
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 1 Nov 2015 20:21:41 +0000 (21:21 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 5 Jan 2016 00:05:07 +0000 (01:05 +0100)
Simplify to 1 column per colour with more flexible sample styling, at the
cost of difficulty matching line height.

base.css
termcol.plp

index eb181287143f8c86dd6644f121e0efbf2a6753a9..fa7d04a7d40310bfe8ca9436c66f520c7486f52e 100644 (file)
--- a/base.css
+++ b/base.css
@@ -258,13 +258,21 @@ tfoot .cat th {
 
 /* colour map */
 
 
 /* colour map */
 
-table.color th {
+table.color td {
        border: 1px solid #555;
        font-weight: normal;
        border: 1px solid #555;
        font-weight: normal;
-       padding: 0 1ex;
+       padding: 0 8px;
 }
 }
-table.color th ~ td {
-       font-family: monospace;
+table.color td samp {
+       margin: 0 -8px 0 8px;
+       font-family: inherit;
+       float: right;
+}
+table.color td samp ~ samp {
+}
+table.color td samp small {
+       font: 100% monospace;
+       padding: 0 .5ex;
 }
 
 /* digraphs map */
 }
 
 /* digraphs map */
index 0c5d3e4d27819484ea19e4c54a047b2939bfea43..0b3d2364a11ed39824afd06ca979833a12ea0f1f 100644 (file)
@@ -49,7 +49,7 @@ my $palettes = do 'termcol.inc.pl';
 die "Cannot open palette data: $_\n" for $@ || $! || ();
 
 sub colcell {
 die "Cannot open palette data: $_\n" for $@ || $! || ();
 
 sub colcell {
-       my $name = shift // return "<td colspan=3>\n";
+       my $name = shift // return "<td>\n";
        my $col = Shiar_Sheet::Colour->new(@_);
        my $minhex = $col->rgb24;
        my $css     = '#' . $col->rgb48;
        my $col = Shiar_Sheet::Colour->new(@_);
        my $minhex = $col->rgb24;
        my $css     = '#' . $col->rgb48;
@@ -58,13 +58,14 @@ 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('<th title="%s" style="%s">%s',
+       my $out = sprintf('<td title="%s" style="%s">%s',
                join(',', map { int } @$col),
                "background:$css; color:$inverse",
                $name,
        );
                join(',', map { int } @$col),
                "background:$css; color:$inverse",
                $name,
        );
-       $out .= sprintf '<td style="%s">%s', "background:$_; color:$css", $minhex
-               for @$sample;
+       $out .= sprintf('<samp style="%s"><small>%s</small></samp>',
+               "background:$_; color:$css", $minhex
+       ) for @$sample;
        return "$out\n";
 }
 
        return "$out\n";
 }
 
@@ -149,7 +150,7 @@ sub coltable_hsv {
        }
 
        my $out = '';
        }
 
        my $out = '';
-       $out .= sprintf '<colgroup span=%d>', 3 * @{$_} for @colmap;
+       $out .= sprintf '<colgroup span=%d>', scalar @{$_} for @colmap;
        my $huerow = $colmap[0][0]; # first {$_} map { @{$_} } @colmap;
        for my $h (grep { $huerow->[$_] } 0 .. $#{$huerow}) {
                $out .= '<tr>';
        my $huerow = $colmap[0][0]; # first {$_} map { @{$_} } @colmap;
        for my $h (grep { $huerow->[$_] } 0 .. $#{$huerow}) {
                $out .= '<tr>';