Mercurial > hg
diff mercurial/templates/static/style-gitweb.css @ 33390:32331f54930c
hgweb: re-implement followlines UI selection using buttons
This changeset attempts to solve two issues with the "followlines" UI in
hgweb. First the "followlines" action is currently not easily discoverable
(one has to hover on a line for some time, wait for the invite message to
appear and then perform some action). Second, it gets in the way of natural
line selection, especially in filerevision view.
This changeset introduces an additional markup element (a <button
class="btn-followlines">) alongside each content line of the view. This button
now holds events for line selection that were previously plugged onto content
lines directly. Consequently, there's no more action on content lines, hence
restoring the "natural line selection" behavior (solving the second problem).
These buttons are hidden by default and get displayed upon hover of content
lines; then upon hover of a button itself, a text inviting followlines section
shows up. This solves the first problem (discoverability) as we now have a
clear visual element indicating that "some action could be perform" (i.e. a
button) and that is self-documented.
In followlines.js, all event listeners are now attached to these <button>
elements. The custom "floating tooltip" element is dropped as <button>
elements are now self-documented through a "title" attribute that changes
depending on preceding actions (selection started or not, in particular).
The new <button> element is inserted in followlines.js script (thus only
visible if JavaScript is activated); it contains a "+" and "-" with a
"diff-semantics" style; upon hover, it scales up.
To find the parent element under which to insert the <button> we either rely
on the "data-selectabletag" attribute (which defines the HTML tag of children
of class="sourcelines" element e.g. <span> for filerevision view and <tr> for
annotate view) or use a child of the latter elements if we find an element
with class="followlines-btn-parent" (useful for annotate view, for which we
have to find the <td> in which to insert the <button>).
On noticeable change in CSS concerns the "margin-left" of span:before
pseudo-elements in filelog view that has been increased a bit in order to
leave space for the new button to appear between line number column and
line content one.
Also note the "z-index" addition for "annotate-info" box so that the latter
appears on top of new buttons (instead of getting hidden).
In some respect, the UI similar to line commenting feature that is implemented
in popular code hosting site like GitHub, BitBucket or Kallithea.
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Mon, 03 Jul 2017 13:49:03 +0200 |
parents | 1c97df5e3b46 |
children | 875b054e5b95 |
line wrap: on
line diff
--- a/mercurial/templates/static/style-gitweb.css Sat Jul 01 20:51:19 2017 -0700 +++ b/mercurial/templates/static/style-gitweb.css Mon Jul 03 13:49:03 2017 +0200 @@ -86,6 +86,7 @@ white-space: nowrap; } div.annotate-info { + z-index: 5; display: none; position: absolute; background-color: #FFFFFF; @@ -152,7 +153,7 @@ -ms-user-select: none; user-select: none; display: inline-block; - margin-left: -5em; + margin-left: -6em; width: 4em; color: #999; text-align: right; @@ -177,11 +178,6 @@ } /* Followlines */ -div.page_body table tbody.sourcelines > tr.followlines-select:hover, -div.page_body pre.sourcelines > span.followlines-select:hover { - cursor: cell; -} - tbody.sourcelines > tr.followlines-selected, pre.sourcelines > span.followlines-selected { background-color: #99C7E9 !important; @@ -219,21 +215,62 @@ font-family: sans-serif; } -div#followlines-tooltip { +.btn-followlines { display: none; - position: fixed; - background-color: #ffc; - border: 1px solid #999; - padding: 2px; + cursor: pointer; + box-sizing: content-box; + font-size: 11px; + width: 13px; + height: 13px; + border-radius: 3px; + margin: 0px; + margin-top: -2px; + padding: 0px; + background-color: #E5FDE5; + border: 1px solid #9BC19B; + font-family: monospace; + text-align: center; + line-height: 5px; +} + +tr .btn-followlines { + position: absolute; } -.sourcelines:hover > div#followlines-tooltip { +span .btn-followlines { + float: left; +} + +span.followlines-select .btn-followlines { + margin-left: -1.6em; +} + +.btn-followlines:hover { + transform: scale(1.1, 1.1); +} + +.btn-followlines .followlines-plus { + color: green; +} + +.btn-followlines .followlines-minus { + color: red; +} + +.btn-followlines-end { + background-color: #ffdcdc; +} + +.sourcelines tr:hover .btn-followlines, +.sourcelines span.followlines-select:hover > .btn-followlines { display: inline; } -.sourcelines:hover > div#followlines-tooltip.hidden { +.btn-followlines-hidden, +.sourcelines tr:hover .btn-followlines-hidden { display: none; } + /* Graph */ div#wrapper { position: relative;