Skip to content

Commit 92fe4fc

Browse files
committed
Render both install card variants, toggle with CSS
Both the latest and older-version cards are always in the DOM now. A wrapper attribute (data-active-variant) plus one CSS rule controls which one is visible. Server still sets the initial value so nothing changes with JS off.
1 parent abd3006 commit 92fe4fc

3 files changed

Lines changed: 34 additions & 6 deletions

File tree

static/css/v3/install-card.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,15 @@
170170

171171
/* Per-option visibility rules are generated by Django in _install_card.html */
172172

173+
/* ── Latest/older variant toggle ─────────────────────────── */
174+
/* Both variants are always rendered server-side; the wrapper's data-active-variant
175+
attribute controls which one is visible. JS flips it on version-dropdown change;
176+
with JS disabled, the server-rendered value stays and a full request swaps it. */
177+
[data-install-card-wrapper][data-active-variant="latest"] .install-card--older,
178+
[data-install-card-wrapper][data-active-variant="older"] .install-card:not(.install-card--older) {
179+
display: none;
180+
}
181+
173182
/* ── Older-version variant ───────────────────────────────── */
174183
.install-card--older {
175184
gap: var(--space-large);

templates/v3/includes/_install_card.html

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
are visible. Dynamic :checked ~ rules are generated in the inline <style>
1313
block below because the number of options is data-driven.
1414

15+
Both the latest-version and older-version variants are always rendered inside
16+
a wrapper with data-active-variant="latest|older". CSS hides the inactive
17+
one. install-card-version-sync.js (cookie-mode pages only) flips the
18+
attribute on version-dropdown change so the swap happens without a page
19+
refresh; with JS disabled, the server-rendered variant stays and the
20+
dropdown's POST + redirect path handles the swap on the next request.
21+
1522
Variables:
1623
title (optional) — card heading text; defaults to "Install Boost and get started in your terminal."
1724
card_id (IMPORTANT) — unique identifier to scope IDs/names when multiple cards appear on the same page; defaults to slugified title, then "install"
@@ -26,6 +33,7 @@
2633
Dependencies:
2734
CSS: card.css, tab.css, install-card.css, code-block.css, forms.css (.dropdown)
2835
JS: install-card.js (keyboard nav + ARIA updates; optional — core works without it)
36+
install-card-version-sync.js (in-place version swap; optional — server roundtrip works without it)
2937

3038
Accessibility:
3139
- role="tablist" on tab container, role="tab" on labels, role="tabpanel" on panels
@@ -37,24 +45,25 @@
3745
{% endcomment %}
3846
{% with resolved_title=title|slugify|default:"install" %}
3947
{% with card_id=card_id|default:resolved_title %}
40-
{% if selected_version_is_non_latest %}
48+
<div class="install-card-wrapper"
49+
data-install-card-wrapper
50+
data-active-variant="{% if selected_version_is_non_latest %}older{% else %}latest{% endif %}">
4151
<section class="install-card install-card--older card"
42-
aria-labelledby="{{ card_id }}-heading">
52+
aria-labelledby="{{ card_id }}-older-heading">
4353
<div class="card__header">
44-
<h2 id="{{ card_id }}-heading" class="card__title install-card__title">
54+
<h2 id="{{ card_id }}-older-heading" class="card__title install-card__title">
4555
{{ title|default:"Install Boost and get started in your terminal." }}
4656
</h2>
4757
</div>
4858
<div class="install-card__body px-large">
4959
<p class="install-card__older-message">
5060
You are viewing an older version. See the documentation for installation steps.
5161
</p>
52-
<div class="install-card__older-cta">
62+
<div class="install-card__older-cta" data-install-card-doc-link-wrapper>
5363
{% include "v3/includes/_button.html" with label="See Documentation" url=selected_version.documentation_url style="teal" aria_label="See documentation for installation steps" only %}
5464
</div>
5565
</div>
5666
</section>
57-
{% else %}
5867
{# Per-option visibility rules (generated from data, complements static rules in install-card.css) #}
5968
<style>
6069
{% for opt in install_card_pkg_managers %}
@@ -149,6 +158,6 @@ <h2 id="{{ card_id }}-heading" class="card__title install-card__title">
149158
</div>
150159
</div>
151160
</section>
152-
{% endif %}
161+
</div>
153162
{% endwith %}
154163
{% endwith %}

templates/v3/includes/header/_header_version_dropdown.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,17 @@
4242
{% if latest_href %}
4343
<a href="{{ latest_href }}"
4444
class="header__version-option"
45+
data-version-option
46+
data-is-latest="true"
4547
{% if not selected_version_is_non_latest %}aria-current="true"{% endif %}>Latest</a>
4648
{% endif %}
4749
{% for v in version_dropdown_options %}
4850
{% if v.href %}
4951
<a href="{{ v.href }}"
5052
class="header__version-option"
53+
data-version-option
54+
data-is-latest="false"
55+
data-doc-url="{{ v.documentation_url }}"
5156
{% if selected_version_is_non_latest and selected_version and v.slug == selected_version.slug %}aria-current="true"{% endif %}>
5257
{{ v.display_name }}
5358
</a>
@@ -62,12 +67,17 @@
6267
name="version"
6368
value="latest"
6469
class="header__version-option"
70+
data-version-option
71+
data-is-latest="true"
6572
{% if not selected_version_is_non_latest %}aria-current="true"{% endif %}>Latest</button>
6673
{% for v in version_dropdown_options %}
6774
<button type="submit"
6875
name="version"
6976
value="{{ v.slug }}"
7077
class="header__version-option"
78+
data-version-option
79+
data-is-latest="false"
80+
data-doc-url="{{ v.documentation_url }}"
7181
{% if selected_version_is_non_latest and selected_version and v.slug == selected_version.slug %}aria-current="true"{% endif %}>
7282
{{ v.display_name }}
7383
</button>

0 commit comments

Comments
 (0)