From: aklhfex at gmail.com (Chris Mayo)
Subject: [PATCH 1/5] ui-diff: use SVG for diffstat graphs
Date: Mon, 18 Feb 2019 20:46:40 +0000 [thread overview]
Message-ID: <20190218204644.440-2-aklhfex@gmail.com> (raw)
In-Reply-To: <20190218204644.440-1-aklhfex@gmail.com>
Only absolute positioning in SVG so draw a bar in removed colour of
length representing all the changes and then draw additions on top.
Signed-off-by: Chris Mayo <aklhfex at gmail.com>
---
cgit.css | 16 +++++-----------
ui-diff.c | 16 ++++++++--------
2 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/cgit.css b/cgit.css
index d4aadbf..2321333 100644
--- a/cgit.css
+++ b/cgit.css
@@ -511,22 +511,16 @@ div#cgit table.diffstat td.graph {
vertical-align: middle;
}
-div#cgit table.diffstat td.graph table {
- border: none;
-}
-
-div#cgit table.diffstat td.graph td {
- padding: 0px;
- border: 0px;
+div#cgit table.diffstat td.graph svg {
height: 7pt;
}
-div#cgit table.diffstat td.graph td.add {
- background-color: #5c5;
+div#cgit table.diffstat td.graph rect.add {
+ fill: #5c5;
}
-div#cgit table.diffstat td.graph td.rem {
- background-color: #c55;
+div#cgit table.diffstat td.graph rect.rem {
+ fill: #c55;
}
div#cgit div.diffstat-summary {
diff --git a/ui-diff.c b/ui-diff.c
index 70dcc91..001d77e 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -51,6 +51,7 @@ struct diff_filespec *cgit_get_current_new_file(void)
static void print_fileinfo(struct fileinfo *info)
{
char *class;
+ int total_changes;
switch (info->status) {
case DIFF_STATUS_ADDED:
@@ -111,16 +112,15 @@ static void print_fileinfo(struct fileinfo *info)
info->old_size, info->new_size);
return;
}
- htmlf("%d", info->added + info->removed);
+ total_changes = info->added + info->removed;
+ htmlf("%d", total_changes);
html("</td><td class='graph'>");
- htmlf("<table summary='file diffstat' width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes));
- htmlf("<td class='add' style='width: %.1f%%;'/>",
+ htmlf("<svg aria-label='file diffstat' width='%d%%'>", (max_changes > 100 ? 100 : max_changes));
+ htmlf("<rect class='rem' width='%.1f%%' height='100%%'/>",
+ total_changes * 100.0 / max_changes);
+ htmlf("<rect class='add' width='%.1f%%' height='100%%'/>",
info->added * 100.0 / max_changes);
- htmlf("<td class='rem' style='width: %.1f%%;'/>",
- info->removed * 100.0 / max_changes);
- htmlf("<td class='none' style='width: %.1f%%;'/>",
- (max_changes - info->removed - info->added) * 100.0 / max_changes);
- html("</tr></table></td></tr>\n");
+ html("</svg></td></tr>\n");
}
static void count_diff_lines(char *line, int len)
--
2.20.1
next prev parent reply other threads:[~2019-02-18 20:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-18 20:46 [PATCH 0/5] SVG diffstat graphs and HTML5 aklhfex
2019-02-18 20:46 ` aklhfex [this message]
2019-02-18 20:46 ` [PATCH 2/5] Replace table summary attribute with aria-label aklhfex
2019-02-18 20:46 ` [PATCH 3/5] Replace self-closing syntax on non-void elements aklhfex
2019-02-18 20:46 ` [PATCH 4/5] ui-log,ui-refs: ensure there are cells for each column aklhfex
[not found] ` <CAGFiPxeyoWYT44SUOo-isKeErvYu-c4J78HtWnwse3ueKQV0fA@mail.gmail.com>
[not found] ` <CAGFiPxfmGgy0OVCnxNs6aY5RG9XNQGohOerv2Xu0GhV2KHpG5g@mail.gmail.com>
2019-02-18 21:15 ` [PATCH 4/5] ui-log, ui-refs: " 1melissadenee
2019-02-18 20:46 ` [PATCH 5/5] ui-shared: add encoding declaration aklhfex
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190218204644.440-2-aklhfex@gmail.com \
--to=cgit@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).