Skip to content

Commit

Permalink
Slightly better way to display the nearby contributors list
Browse files Browse the repository at this point in the history
This switches to `display: inline-block` and adds
`max-width: 110px` and `text-overflow: ellipsis` to guard
against long usernames making this content too wide.

Also make sure the user-links include their parent span so the
:last-of-type selector can work to add commas between the list items.
Before it didn't work beacuse of the "and {n} others".
(the {n} becomes the last-of-type, and the last username got a trailing comma)
  • Loading branch information
bhousel committed Nov 12, 2024
1 parent a06a64f commit 7464e2d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 11 additions & 1 deletion css/80_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -4534,7 +4534,17 @@ li.issue-fix-item button:not(.actionable) .fix-icon {
border-left: 1px solid rgba(255,255,255,.5);
}

.map-footer-info .contributors a:not(:last-child):after {
.contributors span {
display: inline-flex;
}
.contributors a {
display: inline-block;
max-width: 110px;
overflow: hidden;
text-overflow: ellipsis;
padding: 0 2px;
}
.contributors a.user-link:not(:last-of-type):after {
content: ', ';
}

Expand Down
12 changes: 7 additions & 5 deletions modules/ui/UiContributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,26 @@ export class UiContributors {
.attr('target', '_blank')
.text(d => d);

const linksHTML = $$links.node().outerHTML;

if (seen.size > MAXUSERS) {
const othersNum = seen.size - MAXUSERS;
const $$count = select(document.createElement('span'));
const $$count = select(document.createElement('a'));

$$count
.append('a')
.attr('target', '_blank')
.attr('href', osm.changesetsURL(viewport.centerLoc(), viewport.transform.zoom))
.text(othersNum);

const countHTML = $$count.node().outerHTML;

$wrap.selectAll('.user-list') // "Edits by {users} and {n} others"
.html(l10n.tHtml('contributors.truncated_list', { n: othersNum, users: $$links.html(), count: $$count.html() }));
.html(l10n.t('contributors.truncated_list', { n: othersNum, users: linksHTML, count: countHTML }));

} else {
$wrap.selectAll('.user-list') // "Edits by {users}"
.html(l10n.tHtml('contributors.list', { users: $$links.html() }));
.html(l10n.t('contributors.list', { users: linksHTML }));
}

}

}

0 comments on commit 7464e2d

Please sign in to comment.