Skip to content

Commit 61c8772

Browse files
committed
Made the language and documentation version switcher accessible by keyboard.
1 parent e81dd71 commit 61c8772

File tree

2 files changed

+77
-77
lines changed

2 files changed

+77
-77
lines changed

djangoproject/scss/_style.scss

Lines changed: 69 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,88 +2286,96 @@ h2+.list-link-soup {
22862286
z-index: 1;
22872287
pointer-events: none;
22882288

2289-
list-style: none;
2290-
2291-
.icon {
2292-
margin-right: 4px;
2293-
}
2289+
display: flex;
2290+
flex-direction: column;
2291+
align-items: flex-end;
2292+
gap: 0.6em;
22942293

22952294
ul {
22962295
text-align: right;
2296+
margin: 0;
2297+
padding: 0;
2298+
list-style: none;
2299+
display: inline-flex;
2300+
align-items: center;
2301+
justify-content: flex-end;
2302+
gap: 3px;
22972303
}
22982304
}
22992305

2300-
#doc-versions,
2301-
#doc-languages,
2302-
#faq-link,
2303-
#backtotop-link {
2304-
margin: 0;
2305-
padding-top: 0.25em;
2306-
padding-bottom: 0.25em;
2307-
2308-
&.open {
2309-
li {
2310-
display: inline-block;
2306+
#doc-versions li,
2307+
#doc-languages li,
2308+
#faq-link li,
2309+
#backtotop-link li {
2310+
margin: 0 3px;
2311+
background: var(--body-bg);
2312+
border: 1px solid var(--hairline-color);
2313+
border-radius: 4px;
2314+
cursor: pointer;
2315+
pointer-events: auto;
23112316

2312-
&.current {
2313-
border: 1px solid $green-light;
2314-
}
2315-
}
2317+
a,
2318+
button {
2319+
display: inline-block;
2320+
background: var(--body-bg);
2321+
padding: 8px 15px;
2322+
border-radius: 4px;
2323+
border: none;
2324+
@include sans-serif;
2325+
font-size: 12px;
2326+
line-height: inherit;
23162327
}
23172328

2318-
li {
2319-
display: none;
2320-
margin: 0 3px;
2321-
@include sans-serif;
2322-
color: var(--body-fg);
2323-
@include font-size(12);
2324-
pointer-events: auto;
2329+
a {
2330+
text-decoration: none;
2331+
font-weight: 700;
2332+
color: var(--primary);
2333+
}
23252334

2326-
&.current {
2327-
display: inline-block;
2328-
background: var(--body-bg);
2329-
padding: 8px 15px;
2330-
border: 1px solid var(--hairline-color);
2331-
border-radius: 4px;
2332-
cursor: pointer;
2335+
&:hover,
2336+
&:focus-within {
2337+
border-color: $green-light;
2338+
a {
2339+
color: var(--secondary);
23332340
}
2341+
}
2342+
}
23342343

2335-
&.current-link {
2336-
display: inline-block;
2337-
}
2344+
#doc-languages,
2345+
#doc-versions {
2346+
position: relative;
23382347

2339-
a {
2340-
display: inline-block;
2341-
background: var(--body-bg);
2342-
color: var(--primary);
2343-
text-decoration: none;
2344-
font-weight: 700;
2345-
padding: 8px 15px;
2346-
border: 1px solid var(--hairline-color);
2347-
border-radius: 4px;
2348+
li {
2349+
display: inline-block;
2350+
padding: 0;
2351+
position: relative;
23482352

2349-
&:hover {
2350-
color: var(--secondary);
2351-
border: 1px solid $green-light;
2353+
&.current {
2354+
&::after {
2355+
content: "";
2356+
position: absolute;
2357+
top: 0;
2358+
left: -8px;
2359+
width: 8px;
2360+
height: 100%;
23522361
}
23532362
}
23542363

2355-
a.icon-chevron-up-align {
2356-
// Should be removed when icon-chevron-up image have the same black space on both sides.
2357-
padding-right: 11px;
2364+
&.other {
2365+
display: none;
2366+
position: absolute;
2367+
right: 100%;
2368+
top: 0;
2369+
margin-right: 2px;
2370+
white-space: nowrap;
2371+
z-index: 2;
23582372
}
23592373
}
23602374

2361-
&:hover {
2362-
pointer-events: auto;
2363-
padding: 2em 0;
2364-
margin: -1.75em 0;
2365-
2366-
li {
2367-
display: inline-block;
2368-
}
2375+
&:hover li.other,
2376+
&:focus-within li.other {
2377+
display: inline-block;
23692378
}
2370-
23712379
}
23722380

23732381
#dev-warning,

docs/templates/docs/doc.html

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
</li>
6363
</ul>
6464
<ul id="doc-languages" class="language-switcher doc-switcher">
65+
<li class="current">
66+
<button>{% trans "Language:" %} <strong>{{ lang }}</strong></button>
67+
</li>
6568
{% for available_lang in available_languages %}
6669
{% if lang != available_lang %}
6770
<li class="other">
@@ -74,14 +77,15 @@
7477
</li>
7578
{% endif %}
7679
{% endfor %}
77-
<li class="current"
78-
title="{% blocktrans %}Click on the links on the left to switch to another language.{% endblocktrans %}">
79-
<span>{% trans "Language:" %} <strong>{{ lang }}</strong></span>
80-
</li>
8180
</ul>
8281

8382
{% get_all_doc_versions docurl as other_versions %}
8483
<ul id="doc-versions" class="version-switcher doc-switcher">
84+
<li class="current {% if release.is_dev %}dev{% endif %}">
85+
<button>{% trans "Documentation version:" %}
86+
<strong>{% if release.is_dev %}development{% else %}{{ version }}{% endif %}</strong>
87+
</button>
88+
</li>
8589
{% for other_version in other_versions %}
8690
{% if version != other_version %}
8791
<li class="other">
@@ -94,18 +98,6 @@
9498
</li>
9599
{% endif %}
96100
{% endfor %}
97-
<li class="current{% if release.is_dev %} dev{% endif %}"
98-
title="{% if release.is_dev %}{% blocktrans trimmed %}
99-
This document is for Django's development version, which can be significantly different from previous releases.
100-
{% endblocktrans %}{% else %}{% blocktrans trimmed %}
101-
This document describes Django {{ version }}.
102-
{% endblocktrans %}{% endif %} {% blocktrans trimmed %}
103-
Click on the links on the left to see other versions.
104-
{% endblocktrans %}">
105-
<span>{% trans "Documentation version:" %}
106-
<strong>{% if release.is_dev %}development{% else %}{{ version }}{% endif %}</strong>
107-
</span>
108-
</li>
109101
</ul>
110102
<ul id="backtotop-link">
111103
<li class="current-link">

0 commit comments

Comments
 (0)