Skip to content

Commit a22aff4

Browse files
committed
Moved docs search bar to top navigation in prep for global search.
1 parent bc187c5 commit a22aff4

File tree

23 files changed

+244
-103
lines changed

23 files changed

+244
-103
lines changed

accounts/tests.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@
66
from django_hosts.resolvers import reverse
77

88
from accounts.forms import DeleteProfileForm
9+
from djangoproject.tests import ReleaseMixin
910
from foundation import models as foundationmodels
1011
from tracdb.models import Revision, Ticket, TicketChange
1112
from tracdb.testutils import TracDBCreateDatabaseMixin
1213

1314

1415
@override_settings(TRAC_URL="https://code.djangoproject.com/")
15-
class UserProfileTests(TracDBCreateDatabaseMixin, TestCase):
16+
class UserProfileTests(TracDBCreateDatabaseMixin, ReleaseMixin, TestCase):
1617
databases = {"default", "trac"}
1718

1819
@classmethod
1920
def setUpTestData(cls):
21+
super().setUpTestData()
2022
User.objects.create_user(username="user1", password="password")
2123
User.objects.create_user(username="user2", password="password")
2224
cls.user1_url = reverse("user_profile", args=["user1"])
@@ -175,7 +177,7 @@ def test_caches_trac_stats(self):
175177
self.assertIsNotNone(cache.get(key))
176178

177179

178-
class ViewsTests(TestCase):
180+
class ViewsTests(ReleaseMixin, TestCase):
179181

180182
def test_login_redirect(self):
181183
credentials = {"username": "a-user", "password": "password"}
@@ -193,7 +195,7 @@ def test_profile_view_reversal(self):
193195
reverse("user_profile", host="www", args=[username])
194196

195197

196-
class UserDeletionTests(TestCase):
198+
class UserDeletionTests(ReleaseMixin, TestCase):
197199
def create_user_and_form(self, bound=True, **userkwargs):
198200
userkwargs.setdefault("username", "test")
199201
userkwargs.setdefault("email", "[email protected]")

aggregator/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def setUp(self, mocker):
9292
def test_community_index_number_of_queries(self):
9393
"""Intended to prevent an n+1 issue on the community index view"""
9494
url = reverse("community-index")
95-
with self.assertNumQueries(6):
95+
with self.assertNumQueries(7):
9696
self.client.get(url)
9797

9898
def test_empty_feed_type_not_rendered(self):
@@ -119,7 +119,7 @@ def test_feed_list_number_of_queries(self):
119119
url = reverse(
120120
"community-feed-list", kwargs={"feed_type_slug": self.feed_type.slug}
121121
)
122-
with self.assertNumQueries(7):
122+
with self.assertNumQueries(8):
123123
self.client.get(url)
124124

125125
def test_management_command_sends_no_email_with_no_pending_feeds(self):

blog/tests.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
from django.urls import reverse
1313
from django.utils import timezone, translation
1414

15+
from djangoproject.tests import ReleaseMixin
16+
1517
from .models import ContentFormat, Entry, Event, ImageUpload
1618
from .sitemaps import WeblogSitemap
1719

@@ -189,7 +191,7 @@ def test_past_future_ordering(self):
189191
)
190192

191193

192-
class ViewsTestCase(DateTimeMixin, TestCase):
194+
class ViewsTestCase(ReleaseMixin, DateTimeMixin, TestCase):
193195
def test_staff_with_change_permission_can_see_unpublished_detail_view(self):
194196
"""
195197
Staff users with change permission on BlogEntry can't see unpublished entries
@@ -418,7 +420,7 @@ def test_user_cannot_see_unpublished_entries(self):
418420
+ ["django.middleware.cache.FetchFromCacheMiddleware"]
419421
),
420422
)
421-
class ViewsCachingTestCase(DateTimeMixin, TestCase):
423+
class ViewsCachingTestCase(ReleaseMixin, DateTimeMixin, TestCase):
422424
def test_drafts_have_no_cache_headers(self):
423425
"""
424426
Draft (unpublished) entries have no-cache headers.

contact/tests.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from django.test import TestCase
77
from django.test.utils import override_settings
88

9+
from djangoproject.tests import ReleaseMixin
10+
911
from .views import FoundationContactForm
1012

1113

@@ -21,7 +23,7 @@ def check_network_connection():
2123

2224

2325
@override_settings(AKISMET_TESTING=True)
24-
class ContactFormTests(TestCase):
26+
class ContactFormTests(ReleaseMixin, TestCase):
2527
def setUp(self):
2628
self.url = "/contact/foundation/"
2729

dashboard/tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from django.test import RequestFactory, TestCase
1010
from django_hosts.resolvers import reverse
1111

12+
from djangoproject.tests import ReleaseMixin
1213
from tracdb.models import Ticket
1314
from tracdb.testutils import TracDBCreateDatabaseMixin
1415
from tracdb.tractime import datetime_to_timestamp
@@ -24,7 +25,7 @@
2425
from .views import index, metric_detail, metric_json
2526

2627

27-
class ViewTests(TestCase):
28+
class ViewTests(ReleaseMixin, TestCase):
2829
fixtures = ["dashboard_test_data"]
2930

3031
def setUp(self):

djangoproject/scss/_dark-mode.scss

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -346,20 +346,28 @@ html[data-theme="light"] .theme-toggle .theme-label-when-light {
346346
background-color: var(--body-bg);
347347
}
348348

349-
.mobile-toggle {
350-
width: 45px;
351-
height: 45px;
349+
// Section of the header that is only visible on mobile.
350+
.header-mobile-only {
352351
line-height: 45px;
353352
text-align: center;
354-
margin: 4px 10px;
353+
display: flex;
354+
align-items: center;
355355

356-
@include respond-min(768px) {
356+
@include respond-min(1080px) {
357357
display: none;
358358
}
359+
360+
.light-dark-mode-toggle {
361+
height: 45px;
362+
width: 45px;
363+
margin: 2px;
364+
}
359365
}
360366

361-
header nav li:last-child {
362-
@include respond-max(768px) {
367+
// The last 2 items of the nav list are the searchbar and the light/dark mode toggle.
368+
// These are not visible on mobile as they are within the .header-mobile-only section.
369+
header nav li:nth-last-child(-n+2) {
370+
@include respond-max(1080px) {
363371
display: none;
364372
}
365373
}

djangoproject/scss/_style.scss

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,6 @@ main {
425425
.container {
426426
@include respond-min(768px) {
427427
margin: 0 auto;
428-
max-width: 1400px;
429428
padding: 0 (32/768) * 100%;
430429
}
431430

@@ -463,13 +462,10 @@ header {
463462

464463
.container {
465464
display: flex;
466-
flex-direction: row;
467-
@include respond-min(768px) {
468-
position: relative;
469-
}
465+
align-items: center;
470466
}
471467

472-
.mobile-toggle {margin-left: auto}
468+
.header-mobile-only {margin-left: auto}
473469

474470
.meta {
475471
@include font-size(13);
@@ -479,7 +475,7 @@ header {
479475
margin: 8px 0 0 10px;
480476
display: none;
481477

482-
@include respond-min(1150px) {
478+
@include respond-min(1080px) {
483479
width: 200px;
484480
display: block;
485481
}
@@ -490,19 +486,26 @@ header {
490486
.logo {
491487
@include font-size(40);
492488
@include sans-serif;
493-
background: url(../img/logo-django.svg) center center no-repeat;
489+
// Small screens less than 500px use the dj logo. This gives more
490+
// horizontal space for a searchbar in the header.
491+
background: url(../img/logo-dj.svg) center center no-repeat;
494492
color: var(--white-color);
495493
display: block;
496494
font-weight: 700;
497-
margin: 10px;
495+
margin: 10px 4px;
498496
overflow: hidden;
499497
text-decoration: none;
500498
text-indent: 100%;
501-
width: 104px;
499+
width: 45px;
502500
height: 36px;
503501

504-
@include respond-min(768px) {
505-
margin-left: 0;
502+
@include respond-min(500px) {
503+
background: url(../img/logo-django.svg) center center no-repeat;
504+
width: 104px;
505+
}
506+
507+
@include respond-min(1080px) {
508+
margin-left: 10px;
506509
}
507510
}
508511

@@ -514,13 +517,12 @@ header {
514517
cursor: pointer;
515518
display: block;
516519
height: 45px;
517-
line-height: 48px;
518-
margin: 4px 10px;
520+
margin: 2px;
519521
text-align: center;
520522
text-decoration: none;
521523
width: 45px;
522524

523-
@include respond-min(768px) {
525+
@include respond-min(1080px) {
524526
display: none;
525527
}
526528

@@ -544,7 +546,7 @@ header {
544546
max-height: 580px;
545547
}
546548

547-
@include respond-min(768px) {
549+
@include respond-min(1080px) {
548550
width: auto;
549551
max-height: none; // always show menu on a desktop width
550552
}
@@ -553,7 +555,9 @@ header {
553555
margin: 10px 0 0;
554556
padding: 0;
555557

556-
@include respond-min(768px) {
558+
@include respond-min(1080px) {
559+
display: flex;
560+
align-items: center;
557561
margin: 0;
558562
}
559563
}
@@ -568,14 +572,18 @@ header {
568572
text-transform: uppercase;
569573
margin: 0 10px;
570574
border-top: 1px solid lighten($green-dark, 5%);
571-
padding: 20px 0px;
575+
> :not(.search){
576+
padding: 20px 0px;
577+
}
572578

573-
@include respond-min(768px) {
579+
@include respond-min(1080px) {
574580
margin: 0;
575581
border: 0;
576582
float: left;
577583
text-align: left;
578-
padding: 20px 10px;
584+
> :not(.search){
585+
padding: 10px;
586+
}
579587
}
580588

581589
&.active a {
@@ -608,18 +616,11 @@ header {
608616
color: var(--secondary-accent);
609617
}
610618

611-
@include respond-min(768px) {
619+
@include respond-min(1080px) {
612620
padding: 20px 10px;
613621
}
614622
}
615623

616-
.nav-primary {
617-
@include respond-min(768px) {
618-
position: absolute;
619-
right: 0;
620-
top: 45px;
621-
}
622-
}
623624
}
624625
}
625626

@@ -645,7 +646,7 @@ header {
645646
top: 0;
646647
max-width: 660px;
647648

648-
@include respond-min(768px) {
649+
@include respond-min(1080px) {
649650
position: static;
650651
}
651652
}
@@ -3005,14 +3006,10 @@ form {
30053006
height: 40px;
30063007
padding: 0;
30073008
position: absolute;
3008-
right: 2%;
3009+
right: 0;
30093010
top: 6%;
30103011
width: 40px;
30113012

3012-
@include respond-min(768px) {
3013-
right: 1%;
3014-
}
3015-
30163013
i {
30173014
@include font-size(20);
30183015
line-height: 1;
@@ -3054,16 +3051,15 @@ form {
30543051
}
30553052

30563053
&.search {
3057-
@include respond-min(768px) {
3058-
flex: 0 0 40%;
3059-
margin: 10px 0;
3060-
}
3061-
3062-
flex: 0 0 100%;
3063-
margin: 0 0 10px 0;
3064-
3065-
button {
3066-
top: 19%;
3054+
width: 20%;
3055+
min-width: 200px;
3056+
margin: 10px;
3057+
margin-left: 0;
3058+
input {
3059+
margin: 0;
3060+
@include respond-min(1080px) {
3061+
margin: 0 10px;
3062+
}
30673063
}
30683064
}
30693065
}
@@ -3602,7 +3598,7 @@ ul.corporate-members li {
36023598
justify-content: space-between;
36033599
}
36043600

3605-
@include respond-max(1200px) {
3601+
@include respond-max(1080px) {
36063602
.community-title {
36073603
text-align: center;
36083604
}
Lines changed: 10 additions & 0 deletions
Loading

djangoproject/templates/includes/header.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
{% load docs %}
12
{% if 'preview.djangoproject.com' in request.get_host %}
23
<div class="copy-banner" style="background: #fff78e; padding: 10px;"></div>
34
{% endif %}
45
<header id="top">
56
<div class="container container--flex--wrap--mobile">
67
<a class="logo" href="{% url 'homepage' %}">Django</a>
78
<p class="meta">The web framework for perfectionists with deadlines.</p>
8-
<div class="mobile-toggle">
9-
{% include "includes/toggle_theme.html" %}
9+
<div class="header-mobile-only">
10+
{% search_form %}
11+
<div class="light-dark-mode-toggle">
12+
{% include "includes/toggle_theme.html" %}
13+
</div>
1014
</div>
1115
<button class="menu-button">
1216
<i class="icon icon-reorder"></i>
@@ -42,6 +46,9 @@
4246
<li{% if 'fundraising' in request.path %} class="active"{% endif %}>
4347
<a href="{% url 'fundraising:index' %}">&#9829; Donate</a>
4448
</li>
49+
<li>
50+
{% search_form %}
51+
</li>
4552
<li>
4653
{% include "includes/toggle_theme.html" %}
4754
</li>
File renamed without changes.

0 commit comments

Comments
 (0)