Skip to content

Commit bd45b49

Browse files
authored
Add User Card logged-out variant (boostorg#2284)
1 parent 1699e4a commit bd45b49

3 files changed

Lines changed: 107 additions & 3 deletions

File tree

static/css/v3/user-card.css

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
}
120120

121121
html.dark .user-card--green.card {
122-
--user-card-cta-bg: var(--color-primary-grey-700);
122+
--user-card-cta-bg: var(--color-primary-grey-800);
123123
--user-card-cta-bg-hover: var(--color-primary-grey-600);
124124
}
125125

@@ -152,19 +152,86 @@ html.dark .user-card--green.card {
152152
font-size: var(--font-size-xl);
153153
}
154154

155+
/* ==========================================================================
156+
Logged-out variant (heading + description + Sign up CTA)
157+
========================================================================== */
158+
159+
.user-card--logged-out.card {
160+
--user-card-cta-bg: var(--color-surface-strong-accent-teal-default);
161+
--user-card-cta-bg-hover: var(--color-surface-strong-accent-teal-hover);
162+
max-width: 340px;
163+
padding: 0;
164+
gap: var(--space-card);
165+
background-color: var(--color-surface-weak-accent-teal);
166+
}
167+
168+
html.dark .user-card--logged-out.card {
169+
--user-card-cta-bg: var(--color-primary-grey-800);
170+
--user-card-cta-bg-hover: var(--color-primary-grey-600);
171+
}
172+
173+
.user-card--logged-out .user-card__heading,
174+
.user-card--logged-out .user-card__description,
175+
.user-card--logged-out .btn-row {
176+
padding-left: var(--space-card);
177+
padding-right: var(--space-card);
178+
padding-top: 0;
179+
padding-bottom: 0;
180+
}
181+
182+
.user-card--logged-out .user-card__heading {
183+
padding-top: var(--space-card);
184+
}
185+
186+
.user-card--logged-out .btn-row {
187+
padding-bottom: var(--space-card);
188+
}
189+
190+
.user-card--logged-out .user-card__heading {
191+
color: var(--color-text-primary);
192+
font-family: var(--font-display);
193+
font-size: var(--font-size-large);
194+
font-weight: var(--font-weight-medium);
195+
line-height: var(--line-height-tight);
196+
letter-spacing: var(--letter-spacing-display-regular);
197+
margin: 0;
198+
}
199+
200+
.user-card--logged-out .user-card__description {
201+
color: var(--color-text-secondary);
202+
font-size: var(--font-size-base);
203+
font-weight: var(--font-weight-regular);
204+
line-height: var(--line-height-default);
205+
letter-spacing: -0.16px;
206+
margin: 0;
207+
}
208+
155209
/* ==========================================================================
156210
Dark mode — scoped overrides
157211
========================================================================== */
158212

159-
.user-card--green .btn-green {
213+
.user-card--green .btn-green,
214+
.user-card--logged-out .btn-teal {
160215
background-color: var(--user-card-cta-bg);
161216
}
162217

163218
.user-card--green .btn-green:hover,
164-
.user-card--green .btn-green[data-hover] {
219+
.user-card--green .btn-green[data-hover],
220+
.user-card--logged-out .btn-teal:hover,
221+
.user-card--logged-out .btn-teal[data-hover] {
165222
background-color: var(--user-card-cta-bg-hover);
166223
}
167224

225+
/* ==========================================================================
226+
Tablet
227+
========================================================================== */
228+
229+
@media (max-width: 1024px) {
230+
.user-card--logged-out.card {
231+
max-width: 234px;
232+
}
233+
}
234+
168235
/* ==========================================================================
169236
Mobile
170237
========================================================================== */
@@ -185,4 +252,12 @@ html.dark .user-card--green.card {
185252
font-size: var(--font-size-large);
186253
}
187254

255+
.user-card--logged-out.card {
256+
max-width: 100%;
257+
}
258+
259+
.user-card--logged-out .btn {
260+
font-size: var(--font-size-small);
261+
}
262+
188263
}

templates/v3/examples/_v3_example_section.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,15 @@ <h3>{{ section_title }}</h3>
336336
</div>
337337
{% endwith %}
338338

339+
{% with section_title="User Card (logged out)" %}
340+
<div class="v3-examples-section__block" id="{{ section_title|slugify }}">
341+
<h3>{{ section_title }}</h3>
342+
<div class="v3-examples-section__example-box">
343+
{% include "v3/includes/_user_card.html" with logged_out=True cta_url="#" %}
344+
</div>
345+
</div>
346+
{% endwith %}
347+
339348
{% with section_title="Create Account Card" %}
340349
<div class="v3-examples-section__block" id="{{ section_title|slugify }}">
341350
<h3>{{ section_title }}</h3>

templates/v3/includes/_user_card.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
cta_url (string, optional) - CTA button target URL. Omit to hide button.
1414
cta_label (string, optional) - CTA button text. Defaults to "Create Post".
1515
compact (bool, optional) - Render compact variant (no background, no CTA). Default false.
16+
logged_out (bool, optional) - Render logged-out variant (heading, description, Sign up CTA). Default false.
17+
heading (string, optional) - Heading text for logged-out variant.
18+
description (string, optional) - Description text for logged-out variant.
1619
extra_attrs (string, optional) - Extra HTML attributes for analytics (rendered raw)
1720

1821
Usage:
@@ -21,7 +24,23 @@
2124

2225
Compact (no background, no CTA):
2326
{% include "v3/includes/_user_card.html" with username="vinniefalco" avatar_url="/img/avatar.png" compact=True %}
27+
28+
Logged out (heading, description, Sign up CTA):
29+
{% include "v3/includes/_user_card.html" with logged_out=True heading="Join the Boost Community" description="Sign up to create posts, earn badges, and contribute to the community." cta_url="/sign-up/" cta_label="Sign Up" %}
2430
{% endcomment %}
31+
{% if logged_out %}
32+
<section class="user-card user-card--logged-out card" aria-label="{{ heading|default:"Create an account" }}" {{ extra_attrs|safe }}>
33+
<h3 class="user-card__heading">{{ heading|default:"Create an account" }}</h3>
34+
<hr class="card__hr">
35+
<p class="user-card__description">{{ description|default:"Advance your career, learn from experts, and help shape the future of Boost and C++." }}</p>
36+
{% if cta_url %}
37+
<hr class="card__hr">
38+
<div class="btn-row">
39+
{% include "v3/includes/_button.html" with url=cta_url label=cta_label|default:"Sign up now" style="teal" extra_classes="btn-flex" %}
40+
</div>
41+
{% endif %}
42+
</section>
43+
{% else %}
2544
<section class="user-card {% if compact %}user-card--compact{% else %}user-card--lg user-card--green{% endif %} card" aria-label="{{ username }}" {{ extra_attrs|safe }}>
2645

2746
{# Avatar with flag overlay #}
@@ -62,3 +81,4 @@
6281
{% endif %}
6382

6483
</section>
84+
{% endif %}

0 commit comments

Comments
 (0)