Skip to content

Commit

Permalink
Merge pull request #649 from alan-turing-institute/iss604/dark_mode
Browse files Browse the repository at this point in the history
[Ready for Review] Implement dark theme option
  • Loading branch information
helendduncan authored Feb 12, 2024
2 parents 23352dd + 99909f6 commit c12031c
Show file tree
Hide file tree
Showing 6 changed files with 626 additions and 16 deletions.
14 changes: 7 additions & 7 deletions server/apps/main/templates/main/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h5 class="heading-blue" id="sharing-stories">What Stories Should I Share On Aut
<p>
<div class="row ">
<div class="col">
<a class="btn btn-outline-dark float-end"
<a class="btn btn-outline-primary float-end"
href="{% url 'main:content_moderation_guidelines' %}" rel="noopener noreferrer">
Read the code of conduct
</a>
Expand All @@ -66,7 +66,7 @@ <h5 class="heading-blue" id="who-can-share">Who Can Share Stories On AutSPACEs?<
<p>
<div class="row ">
<div class="col">
<a class="btn btn-outline-dark float-end"
<a class="btn btn-outline-primary float-end"
href="{% url 'main:content_moderation_guidelines' %}" rel="noopener noreferrer">
Read the code of conduct
</a>
Expand Down Expand Up @@ -108,7 +108,7 @@ <h5 class="heading-blue" id="what-happens-to-stories">What Happens To The Storie
<p>
<div class="row">
<div class="col">
<a class="btn btn-outline-dark float-end"
<a class="btn btn-outline-primary float-end"
href="{% url 'main:content_moderation_guidelines' %}" rel="noopener noreferrer">
Read the code of conduct
</a>
Expand All @@ -126,7 +126,7 @@ <h5 class="heading-blue" id="how-to-decide">How Do You Decide Which Stories To P
<p>
<div class="row">
<div class="col">
<a class="btn btn-outline-dark float-end"
<a class="btn btn-outline-primary float-end"
href="{% url 'main:content_moderation_guidelines' %}" rel="noopener noreferrer">
Read the code of conduct
</a>
Expand All @@ -143,7 +143,7 @@ <h5 class="heading-blue" id="what-if-not-accepted">What Can I Do If I Want My St
<p>
<div class="row">
<div class="col">
<a class="btn btn-outline-dark float-end"
<a class="btn btn-outline-primary float-end"
href="{% url 'main:content_moderation_guidelines' %}" rel="noopener noreferrer">
Read the code of conduct
</a>
Expand Down Expand Up @@ -184,7 +184,7 @@ <h5 class="heading-blue" id="share-someone-else">Can I Share A Story About Someo
<p>
<div class="row">
<div class="col">
<a class="btn btn-outline-dark float-end"
<a class="btn btn-outline-primary float-end"
href="{% url 'main:content_moderation_guidelines' %}" rel="noopener noreferrer">
Read the code of conduct
</a>
Expand All @@ -199,7 +199,7 @@ <h5 class="heading-blue" id="share-someone-else">What's the Process for Sharing
page</a> when you are logged in and write in the text box about any time you have been effected by your senses.
Then you can submit your experience for research or to share publicly on our website. The flow chart below shows
the steps you can take to share an experience on AutSPACEs.</p>
<p><img src="{% static '/images/submit-experience.svg' %}" class="mx-auto d-block" alt="Flow chart showing the
<p><img src="{% static '/images/submit-experience_grey.svg' %}" class="mx-auto d-block" alt="Flow chart showing the
process for submitting a story"/></p>
</div>
<div class="faq-class">
Expand Down
6 changes: 5 additions & 1 deletion server/apps/main/templates/main/partials/navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
</li>
{% endif %}
{% endif %}

<li class="nav-item dropdown">
<a class="nav-link nav-link-menu dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button"
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Expand All @@ -41,6 +40,9 @@
<li><a class="dropdown-item" href="{% url 'main:help' %}">Help</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link nav-link-menu" id="theme-toggle"><i class="bi bi-circle-half"></i> Switch Light/Dark</a>
</li>
</ul>


Expand Down Expand Up @@ -73,3 +75,5 @@
</div>
</nav>
</div>

<script src="{% static 'js/theme-checker.js' %}"></script>
4 changes: 2 additions & 2 deletions server/apps/main/templates/main/what_autism_is.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h5 class="heading-blue" id="about-autspaces"><em></em>About Autism</h5>
<p>
<div class="row">
<div class="col">
<a class="btn btn-outline-dark float-end"
<a class="btn btn-outline-primary float-end"
href="https://www.autistica.org.uk/what-is-autism/what-is-autism"
target="_blank" rel="noopener noreferrer" >
Find Out More from Autistica
Expand All @@ -61,7 +61,7 @@ <h5 class="heading-blue" id="platform-usage"><em></em>About Sensory Processing</
<p>
<div class="row">
<div class="col">
<a class="btn btn-outline-dark view-btn float-end"
<a class="btn btn-outline-primary view-btn float-end"
href="https://www.autism.org.uk/advice-and-guidance/topics/sensory-differences/sensory-differences/all-audiences"
target="_blank" rel="noopener noreferrer">
Find Out More from the National Autistic Society
Expand Down
25 changes: 19 additions & 6 deletions static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ body {
line-height: 1.5;
font-weight: bold;
text-align: center;
color: #fff;
/* color: #fff; */
color: var(--bs-tertiary-bg);
text-decoration: none;
}
.usage-box a:hover {
Expand Down Expand Up @@ -181,7 +182,7 @@ body {
#value {
padding: 4% 5%;
background: #309FDC;
color: #fff;
color: var(--bs-body-bg);
}
.value-text {
line-height: 2;
Expand Down Expand Up @@ -284,7 +285,7 @@ body {
/*Platform Information*/

#platform_info {
background: #FFFFFF;
background: var(--bs-body-bg);
padding: 4% 5%;
color: #1BB5AF;
}
Expand Down Expand Up @@ -319,7 +320,7 @@ body {
#platform_usage {
background: #FAC145;
padding: 4% 5%;
color: #ffffff;
color: var(--bs-body-bg);
}

.platform-title {
Expand Down Expand Up @@ -359,9 +360,21 @@ body {
}

.cta-header, .card-text {
color: #000;
/* color: var(--bs-primary-text-emphasis) */
color: var(--bs-body-color);
}

@include color-mode(dark) {
.card-text{
color: #fff;
}
}

.cta-header, .card-text-dark {
color: #fff;
}


/*Responsive Design*/
@media (max-width: 992px) {

Expand Down Expand Up @@ -507,11 +520,11 @@ body {
}

.story-card-text {
color: #000000;
line-height: 2;
padding: 0 2%;
}


.story-text {
padding: 2% 11% 3%;
text-align: cetner;
Expand Down
564 changes: 564 additions & 0 deletions static/images/submit-experience_grey.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions static/js/theme-checker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

document.addEventListener('DOMContentLoaded', (event) => {
// Check if the user has set a theme before
let storedTheme = localStorage.getItem('theme');

if (storedTheme !== null) {
document.body.setAttribute('data-bs-theme', storedTheme);
footer.setAttribute('data-bs-theme', storedTheme);
} else {
// Get the system theme
let systemTheme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
document.body.setAttribute('data-bs-theme', systemTheme);
footer.setAttribute('data-bs-theme', systemTheme);
}
});


document.getElementById('theme-toggle').addEventListener('click', function() {
let currentTheme = document.body.getAttribute('data-bs-theme');
if (currentTheme === 'dark') {
document.body.setAttribute('data-bs-theme', 'light');
footer.setAttribute('data-bs-theme', 'light');
localStorage.setItem('theme', 'light');
} else {
document.body.setAttribute('data-bs-theme', 'dark');
footer.setAttribute('data-bs-theme', 'dark');
localStorage.setItem('theme', 'dark');
}
});

0 comments on commit c12031c

Please sign in to comment.