Skip to content

Commit c12031c

Browse files
authored
Merge pull request #649 from alan-turing-institute/iss604/dark_mode
[Ready for Review] Implement dark theme option
2 parents 23352dd + 99909f6 commit c12031c

File tree

6 files changed

+626
-16
lines changed

6 files changed

+626
-16
lines changed

server/apps/main/templates/main/help.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ <h5 class="heading-blue" id="sharing-stories">What Stories Should I Share On Aut
4646
<p>
4747
<div class="row ">
4848
<div class="col">
49-
<a class="btn btn-outline-dark float-end"
49+
<a class="btn btn-outline-primary float-end"
5050
href="{% url 'main:content_moderation_guidelines' %}" rel="noopener noreferrer">
5151
Read the code of conduct
5252
</a>
@@ -66,7 +66,7 @@ <h5 class="heading-blue" id="who-can-share">Who Can Share Stories On AutSPACEs?<
6666
<p>
6767
<div class="row ">
6868
<div class="col">
69-
<a class="btn btn-outline-dark float-end"
69+
<a class="btn btn-outline-primary float-end"
7070
href="{% url 'main:content_moderation_guidelines' %}" rel="noopener noreferrer">
7171
Read the code of conduct
7272
</a>
@@ -108,7 +108,7 @@ <h5 class="heading-blue" id="what-happens-to-stories">What Happens To The Storie
108108
<p>
109109
<div class="row">
110110
<div class="col">
111-
<a class="btn btn-outline-dark float-end"
111+
<a class="btn btn-outline-primary float-end"
112112
href="{% url 'main:content_moderation_guidelines' %}" rel="noopener noreferrer">
113113
Read the code of conduct
114114
</a>
@@ -126,7 +126,7 @@ <h5 class="heading-blue" id="how-to-decide">How Do You Decide Which Stories To P
126126
<p>
127127
<div class="row">
128128
<div class="col">
129-
<a class="btn btn-outline-dark float-end"
129+
<a class="btn btn-outline-primary float-end"
130130
href="{% url 'main:content_moderation_guidelines' %}" rel="noopener noreferrer">
131131
Read the code of conduct
132132
</a>
@@ -143,7 +143,7 @@ <h5 class="heading-blue" id="what-if-not-accepted">What Can I Do If I Want My St
143143
<p>
144144
<div class="row">
145145
<div class="col">
146-
<a class="btn btn-outline-dark float-end"
146+
<a class="btn btn-outline-primary float-end"
147147
href="{% url 'main:content_moderation_guidelines' %}" rel="noopener noreferrer">
148148
Read the code of conduct
149149
</a>
@@ -184,7 +184,7 @@ <h5 class="heading-blue" id="share-someone-else">Can I Share A Story About Someo
184184
<p>
185185
<div class="row">
186186
<div class="col">
187-
<a class="btn btn-outline-dark float-end"
187+
<a class="btn btn-outline-primary float-end"
188188
href="{% url 'main:content_moderation_guidelines' %}" rel="noopener noreferrer">
189189
Read the code of conduct
190190
</a>
@@ -199,7 +199,7 @@ <h5 class="heading-blue" id="share-someone-else">What's the Process for Sharing
199199
page</a> when you are logged in and write in the text box about any time you have been effected by your senses.
200200
Then you can submit your experience for research or to share publicly on our website. The flow chart below shows
201201
the steps you can take to share an experience on AutSPACEs.</p>
202-
<p><img src="{% static '/images/submit-experience.svg' %}" class="mx-auto d-block" alt="Flow chart showing the
202+
<p><img src="{% static '/images/submit-experience_grey.svg' %}" class="mx-auto d-block" alt="Flow chart showing the
203203
process for submitting a story"/></p>
204204
</div>
205205
<div class="faq-class">

server/apps/main/templates/main/partials/navigation.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
</li>
2929
{% endif %}
3030
{% endif %}
31-
3231
<li class="nav-item dropdown">
3332
<a class="nav-link nav-link-menu dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button"
3433
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@@ -41,6 +40,9 @@
4140
<li><a class="dropdown-item" href="{% url 'main:help' %}">Help</a></li>
4241
</ul>
4342
</li>
43+
<li class="nav-item">
44+
<a class="nav-link nav-link-menu" id="theme-toggle"><i class="bi bi-circle-half"></i> Switch Light/Dark</a>
45+
</li>
4446
</ul>
4547

4648

@@ -73,3 +75,5 @@
7375
</div>
7476
</nav>
7577
</div>
78+
79+
<script src="{% static 'js/theme-checker.js' %}"></script>

server/apps/main/templates/main/what_autism_is.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h5 class="heading-blue" id="about-autspaces"><em></em>About Autism</h5>
3838
<p>
3939
<div class="row">
4040
<div class="col">
41-
<a class="btn btn-outline-dark float-end"
41+
<a class="btn btn-outline-primary float-end"
4242
href="https://www.autistica.org.uk/what-is-autism/what-is-autism"
4343
target="_blank" rel="noopener noreferrer" >
4444
Find Out More from Autistica
@@ -61,7 +61,7 @@ <h5 class="heading-blue" id="platform-usage"><em></em>About Sensory Processing</
6161
<p>
6262
<div class="row">
6363
<div class="col">
64-
<a class="btn btn-outline-dark view-btn float-end"
64+
<a class="btn btn-outline-primary view-btn float-end"
6565
href="https://www.autism.org.uk/advice-and-guidance/topics/sensory-differences/sensory-differences/all-audiences"
6666
target="_blank" rel="noopener noreferrer">
6767
Find Out More from the National Autistic Society

static/css/main.css

+19-6
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ body {
146146
line-height: 1.5;
147147
font-weight: bold;
148148
text-align: center;
149-
color: #fff;
149+
/* color: #fff; */
150+
color: var(--bs-tertiary-bg);
150151
text-decoration: none;
151152
}
152153
.usage-box a:hover {
@@ -181,7 +182,7 @@ body {
181182
#value {
182183
padding: 4% 5%;
183184
background: #309FDC;
184-
color: #fff;
185+
color: var(--bs-body-bg);
185186
}
186187
.value-text {
187188
line-height: 2;
@@ -284,7 +285,7 @@ body {
284285
/*Platform Information*/
285286

286287
#platform_info {
287-
background: #FFFFFF;
288+
background: var(--bs-body-bg);
288289
padding: 4% 5%;
289290
color: #1BB5AF;
290291
}
@@ -319,7 +320,7 @@ body {
319320
#platform_usage {
320321
background: #FAC145;
321322
padding: 4% 5%;
322-
color: #ffffff;
323+
color: var(--bs-body-bg);
323324
}
324325

325326
.platform-title {
@@ -359,9 +360,21 @@ body {
359360
}
360361

361362
.cta-header, .card-text {
362-
color: #000;
363+
/* color: var(--bs-primary-text-emphasis) */
364+
color: var(--bs-body-color);
363365
}
364366

367+
@include color-mode(dark) {
368+
.card-text{
369+
color: #fff;
370+
}
371+
}
372+
373+
.cta-header, .card-text-dark {
374+
color: #fff;
375+
}
376+
377+
365378
/*Responsive Design*/
366379
@media (max-width: 992px) {
367380

@@ -507,11 +520,11 @@ body {
507520
}
508521

509522
.story-card-text {
510-
color: #000000;
511523
line-height: 2;
512524
padding: 0 2%;
513525
}
514526

527+
515528
.story-text {
516529
padding: 2% 11% 3%;
517530
text-align: cetner;

static/images/submit-experience_grey.svg

+564
Loading

static/js/theme-checker.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
document.addEventListener('DOMContentLoaded', (event) => {
3+
// Check if the user has set a theme before
4+
let storedTheme = localStorage.getItem('theme');
5+
6+
if (storedTheme !== null) {
7+
document.body.setAttribute('data-bs-theme', storedTheme);
8+
footer.setAttribute('data-bs-theme', storedTheme);
9+
} else {
10+
// Get the system theme
11+
let systemTheme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
12+
document.body.setAttribute('data-bs-theme', systemTheme);
13+
footer.setAttribute('data-bs-theme', systemTheme);
14+
}
15+
});
16+
17+
18+
document.getElementById('theme-toggle').addEventListener('click', function() {
19+
let currentTheme = document.body.getAttribute('data-bs-theme');
20+
if (currentTheme === 'dark') {
21+
document.body.setAttribute('data-bs-theme', 'light');
22+
footer.setAttribute('data-bs-theme', 'light');
23+
localStorage.setItem('theme', 'light');
24+
} else {
25+
document.body.setAttribute('data-bs-theme', 'dark');
26+
footer.setAttribute('data-bs-theme', 'dark');
27+
localStorage.setItem('theme', 'dark');
28+
}
29+
});

0 commit comments

Comments
 (0)