Skip to content

Commit 4c539f8

Browse files
authored
Story 2212: Contributors List Component (boostorg#2268)
1 parent 006f32b commit 4c539f8

7 files changed

Lines changed: 109 additions & 2 deletions

File tree

core/views.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,30 @@ def get_context_data(self, **kwargs):
16751675
},
16761676
]
16771677

1678+
context["contributor_data"] = 10 * [
1679+
{
1680+
"name": "John Doe",
1681+
"profile_url": "#",
1682+
"role": "Author",
1683+
"avatar_url": f"{settings.STATIC_URL}img/v3/demo_page/Avatar.png",
1684+
"badge_url": f"{settings.STATIC_URL}img/v3/badges/badge-first-place.png",
1685+
"badge": "",
1686+
"bio": "",
1687+
}
1688+
] + 10 * [
1689+
{
1690+
"name": "Richard Thomson",
1691+
"profile_url": "#",
1692+
"role": "Contributor",
1693+
"avatar_url": "",
1694+
"badge_url": f"{settings.STATIC_URL}img/v3/badges/badge-bronze.png",
1695+
"badge": "",
1696+
"bio": "",
1697+
}
1698+
]
1699+
1700+
context["release_contributor_data"] = context["contributor_data"][:8]
1701+
16781702
latest = Version.objects.most_recent()
16791703
if latest:
16801704
lv = (

static/css/v3/card.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
.card__hr {
7171
width: 100%;
7272
height: 1px;
73+
min-height: 1px;
7374
background: var(--color-stroke-weak);
7475
border: none;
7576
margin: 0;

static/css/v3/components.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@
4444
@import "./user-card.css";
4545
@import "./post-filter.css";
4646
@import "./library-filter.css";
47+
@import "./contributors-list.css";
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.contributors-list :is(h2, h3, h4, h5, h6) {
2+
margin: 0;
3+
}
4+
5+
.contributors-list .card__column {
6+
gap: var(--space-medium);
7+
}
8+
9+
.contributors-list.all-contributors {
10+
max-width: 100%;
11+
}
12+
13+
.contributors-list.all-contributors .card__column {
14+
display: grid;
15+
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
16+
gap: var(--space-medium);
17+
}
18+
19+
@media (max-width: 768px) {
20+
.contributors-list.all-contributors .card__column {
21+
grid-template-columns: 1fr;
22+
overflow-y: auto;
23+
}
24+
25+
.contributors-list {
26+
max-height: 80vh;
27+
}
28+
}

templates/v3/examples/_v3_example_section.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,24 @@ <h3>{{ section_title }}</h3>
703703
</div>
704704
{% endwith %}
705705

706+
{% with contributors=release_contributor_data section_title="Contributors List (release)" %}
707+
<div class="v3-examples-section__block" id="{{ section_title|slugify }}">
708+
<h3>{{ section_title }}</h3>
709+
<div class="v3-examples-section__example-box">
710+
{% include "v3/includes/_contributors_list.html" with title="Contributors: This Release" variant="release" contributors=contributors %}
711+
</div>
712+
</div>
713+
{% endwith %}
714+
715+
{% with contributors=contributor_data section_title="Contributors List (all)" %}
716+
<div class="v3-examples-section__block" id="{{ section_title|slugify }}">
717+
<h3>{{ section_title }}</h3>
718+
<div class="v3-examples-section__example-box">
719+
{% include "v3/includes/_contributors_list.html" with title="All Contributors" variant="all" contributors=contributors %}
720+
</div>
721+
</div>
722+
{% endwith %}
723+
706724
{% comment %}
707725
Position Fixed dark mode toggle for quick theme switching without scrolling to the header.
708726
{% endcomment %}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{% comment %}
2+
Vertical list showing all contributors to a library or release.
3+
Has two variants: Contributors in release, or all contributors. The release variant is a single column,
4+
all contributors is a differing number of columns depending on screen size.
5+
6+
Inputs:
7+
- title: str, required - top title of card
8+
- variant: str, required - choice of release or all, determines display layout
9+
- contributors: list, required - List of contributors, matching the author input of _user_profile.html
10+
- heading_level: int, optional - Set the semantic leve of the heading, defaults to 2, does not allow for h1
11+
12+
Usage:
13+
{% include "v3/includes/_contributors_list.html" with title="Contributors: This Release" variant="release" contributors=contributors %}
14+
{% endcomment %}
15+
<div class="basic-card card py-large contributors-list {% if variant == 'all' %} all-contributors {% endif %}">
16+
<div class="card__header">
17+
{% if heading_level == '2' or not heading_level %}
18+
<h2 class="card__title">{{ title }}</h2>
19+
{% elif heading_level == '3' %}
20+
<h3 class="card__title">{{ title }}</h3>
21+
{% elif heading_level == '4' %}
22+
<h4 class="card__title">{{ title }}</h4>
23+
{% elif heading_level == '5' %}
24+
<h5 class="card__title">{{ title }}</h5>
25+
{% elif heading_level == '6' %}
26+
<h6 class="card__title">{{ title }}</h6>
27+
{% endif %}
28+
</div>
29+
<hr class="card__hr" />
30+
<div class="card__column px-large">
31+
{% for contributor in contributors %}
32+
{% include "v3/includes/_user_profile.html" with author=contributor only %}
33+
{% endfor %}
34+
</div>
35+
</div>

templates/v3/includes/_user_profile.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
<div class="user-profile{% if author.bio %} user-profile--has-bio{% endif %}" role="group" aria-label="{{ author.name }}">
1515
{% if author.profile_url %}
1616
<a href="{{ author.profile_url }}" class="user-profile__avatar-link">
17-
{% include "v3/includes/_avatar_v3.html" with src=author.avatar_url name=author.name size="xl" %}
17+
{% include "v3/includes/_avatar_v3.html" with src=author.avatar_url name=author.name size="xl" only %}
1818
</a>
1919
{% else %}
20-
{% include "v3/includes/_avatar_v3.html" with src=author.avatar_url name=author.name size="xl" %}
20+
{% include "v3/includes/_avatar_v3.html" with src=author.avatar_url name=author.name size="xl" only %}
2121
{% endif %}
2222

2323
<div class="user-profile__content">

0 commit comments

Comments
 (0)