Skip to content

Commit d780532

Browse files
committed
Moved docs search bar to top navigation in prep for global search.
1 parent 7700f0e commit d780532

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
@@ -13,6 +13,8 @@
1313
from django.urls import reverse
1414
from django.utils import timezone, translation
1515

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

@@ -210,7 +212,7 @@ def test_past_future_ordering(self):
210212
)
211213

212214

213-
class ViewsTestCase(DateTimeMixin, TestCase):
215+
class ViewsTestCase(ReleaseMixin, DateTimeMixin, TestCase):
214216
def test_detail_view_html_meta(self):
215217
headline = "Pride and Prejudice - Review"
216218
author = "Jane Austen"
@@ -474,7 +476,7 @@ def test_user_cannot_see_unpublished_entries(self):
474476
+ ["django.middleware.cache.FetchFromCacheMiddleware"]
475477
),
476478
)
477-
class ViewsCachingTestCase(DateTimeMixin, TestCase):
479+
class ViewsCachingTestCase(ReleaseMixin, DateTimeMixin, TestCase):
478480
def test_drafts_have_no_cache_headers(self):
479481
"""
480482
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
@@ -347,20 +347,28 @@ html[data-theme="light"] .theme-toggle .theme-label-when-light {
347347
background-color: var(--body-bg);
348348
}
349349

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

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

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

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
}
@@ -3008,14 +3009,10 @@ form {
30083009
height: 40px;
30093010
padding: 0;
30103011
position: absolute;
3011-
right: 2%;
3012+
right: 0;
30123013
top: 6%;
30133014
width: 40px;
30143015

3015-
@include respond-min(768px) {
3016-
right: 1%;
3017-
}
3018-
30193016
i {
30203017
@include font-size(20);
30213018
line-height: 1;
@@ -3057,16 +3054,15 @@ form {
30573054
}
30583055

30593056
&.search {
3060-
@include respond-min(768px) {
3061-
flex: 0 0 40%;
3062-
margin: 10px 0;
3063-
}
3064-
3065-
flex: 0 0 100%;
3066-
margin: 0 0 10px 0;
3067-
3068-
button {
3069-
top: 19%;
3057+
width: 20%;
3058+
min-width: 200px;
3059+
margin: 10px;
3060+
margin-left: 0;
3061+
input {
3062+
margin: 0;
3063+
@include respond-min(1080px) {
3064+
margin: 0 10px;
3065+
}
30703066
}
30713067
}
30723068
}
@@ -3605,7 +3601,7 @@ ul.corporate-members li {
36053601
justify-content: space-between;
36063602
}
36073603

3608-
@include respond-max(1200px) {
3604+
@include respond-max(1080px) {
36093605
.community-title {
36103606
text-align: center;
36113607
}
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)