From: Mischa POSLAWSKY Date: Sun, 1 Nov 2015 20:21:41 +0000 (+0100) Subject: termcol: float text samples in cells X-Git-Tag: v1.9~73 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/d04b40e629676a9b8fdd015d4b432e121925749b termcol: float text samples in cells Simplify to 1 column per colour with more flexible sample styling, at the cost of difficulty matching line height. --- diff --git a/base.css b/base.css index eb18128..fa7d04a 100644 --- a/base.css +++ b/base.css @@ -258,13 +258,21 @@ tfoot .cat th { /* colour map */ -table.color th { +table.color td { 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 */ diff --git a/termcol.plp b/termcol.plp index 0c5d3e4..0b3d236 100644 --- a/termcol.plp +++ b/termcol.plp @@ -49,7 +49,7 @@ my $palettes = do 'termcol.inc.pl'; die "Cannot open palette data: $_\n" for $@ || $! || (); sub colcell { - my $name = shift // return "\n"; + my $name = shift // return "\n"; 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 $out = sprintf('%s', + my $out = sprintf('%s', join(',', map { int } @$col), "background:$css; color:$inverse", $name, ); - $out .= sprintf '%s', "background:$_; color:$css", $minhex - for @$sample; + $out .= sprintf('%s', + "background:$_; color:$css", $minhex + ) for @$sample; return "$out\n"; } @@ -149,7 +150,7 @@ sub coltable_hsv { } my $out = ''; - $out .= sprintf '', 3 * @{$_} for @colmap; + $out .= sprintf '', scalar @{$_} for @colmap; my $huerow = $colmap[0][0]; # first {$_} map { @{$_} } @colmap; for my $h (grep { $huerow->[$_] } 0 .. $#{$huerow}) { $out .= '';