Commit 3f067ade authored by Johannes Tomren Røsvik's avatar Johannes Tomren Røsvik
Browse files

Merge branch 'dev' into 'master'

Dev

See merge request !5
parents 77cafbaa 716c480d
Pipeline #74309 passed with stages
in 3 minutes and 10 seconds
......@@ -4,6 +4,9 @@
{% block title %}Error{% endblock %}
{% block content %}
<h2 class="mt-5">Woops this page doesn't exist.</h2>
<p>Go back to safe ground by clicking here: <a href="{% url 'home' %}">Home</a></p>
<h2 class="mt-5">Let’s agree to disagree, this page does not exist.</h2>
<br>
<img class="ml-1 honey" src="https://248.no/img/cat.gif" alt="Very funny cat"/>
<p><br>Go back to safe ground by clicking here: <a href="{% url 'home' %}">Home</a></p>
{% endblock %}
......@@ -57,6 +57,17 @@
-->
</ul>
<div class="my-2 my-lg-0 mr-5">
<!-- Darkmode toggleswich -->
<a class="btn btn-link my-sm-0 mr-2">
<div class="custom-control custom-switch">
<input onclick="darkMode()" type="checkbox" class="custom-control-input" id="customSwitch1">
<label class="custom-control-label" for="customSwitch1">Dark Mode</label>
<svg class="bi bi-moon" width="1em" height="1em" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M17.293 13.293A8 8 0 016.707 2.707a8.002 8.002 0 1010.586 10.586z"></path>
</svg>
</div>
</a>
{% if user.is_authenticated %}
<a role="button" class="btn btn-outline-primary my-2 my-sm-0" href="{% url 'new_project' %}">New project</a>
<a class="btn btn-link my-2 my-sm-0" href="{% url 'logout' %}" role="button">Sign out</a>
......@@ -77,5 +88,9 @@
{% endif %}
{% block content %}{% endblock content %}
</div>
<script src="{% static 'js/darkmode.js' %}"></script>
</body>
</html>
......@@ -66,3 +66,12 @@
.permis{
max-width:1000px;
}
.darkmode{
filter: invert(100%);
background-color: black;
}
.darkmode img{
filter: invert(100%);
}
\ No newline at end of file
// Initialize variables
let darkModeState = false;
let body = document.body;
let toggleButton = document.getElementById('customSwitch1');
// Set default value of localstorage if not set
if(localStorage.getItem("darkmode") == "true") {
darkModeState = true;
darkModeOn();
} else {
darkModeState = false;
darkModeOff();
}
// Toggle dark mode
function darkMode() {
if(darkModeState) {
darkModeOff();
} else {
darkModeOn();
}
}
// Turn on dark mode
function darkModeOn() {
darkModeState = true;
body.classList.add("darkmode");
localStorage.setItem("darkmode", "true");
toggleButton.checked = true
}
// Turn off dark mode
function darkModeOff() {
darkModeState = false;
body.classList.remove("darkmode");
localStorage.setItem("darkmode", "false");
toggleButton.checked = false
}
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import os
url = "http://127.0.0.1:8000/"
class AgreelanceDarkMode(unittest.TestCase):
def setUp(self):
if os.name == "nt":
self.driver = webdriver.Chrome("./bin/chromedriver.exe")
else:
self.driver = webdriver.Chrome("./bin/chromedriver")
#Checks that toggleelement should be availeble through togglebar
def test_dark_mode_in_toggle(self):
driver = self.driver
driver.get(url)
self.assertNotIn(driver.find_element_by_class_name("custom-control-label"), driver.find_elements_by_class_name("navbar navbar-expand-lg navbar-light bg-light"))
#Find the darkmode elements
def test_dark_mode_elements(self):
driver = self.driver
driver.get(url)
darkmode_control_label = driver.find_element_by_class_name("custom-control-label")
darkmode_control_input = driver.find_element_by_class_name("custom-control-input")
self.assertTrue(darkmode_control_label)
self.assertTrue(darkmode_control_input)
#Checks if CSS changes if button is clicked
def test_dark_mode_clicked(self):
driver = self.driver
driver.get(url)
try:
toggler = driver.find_element_by_class_name("navbar-toggler")
toggler.click()
time.sleep(1)
finally:
darkmode_click = driver.find_element_by_class_name("custom-control-label")
darkmode_click.click()
time.sleep(1)
self.assertEqual(driver.find_element_by_tag_name("body").value_of_css_property("background-color"), "rgba(0, 0, 0, 1)")
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
unittest.main()
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment