Skip to content
This repository has been archived by the owner on Apr 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #8 from mikojimnz/dev
Browse files Browse the repository at this point in the history
Implement Dark Mode
  • Loading branch information
mikojimnz authored Oct 31, 2021
2 parents abef13c + dfcd204 commit e232ce7
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 21 deletions.
35 changes: 20 additions & 15 deletions app/preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<header>
<div class="banner-top">
<nav class="row navbar navbar-toggleable-lg navbar-inverse bg-inverse bg-faded">
<div class="col col-2"><button onclick="window.history.go(-1); return false;" class="btn btn-link btn-sm back"><i class="fas fa-chevron-left fa-2x"></i></button></div>
<div class="col col-2"><button onclick="location.href='home.html'" return false;" class="btn btn-link btn-sm back"><i class="fas fa-chevron-left fa-2x"></i></button></div>
<div class="col col-8 text-center">
<a class="btn" href="home.html"><h6 class="text-uppercase banner-logo-text" role="button">UCF Downtown</h6></a>
</div>
Expand Down Expand Up @@ -67,7 +67,8 @@
<h1 class="heading-underline">Preferences</h1>

<div class="pt-5 pb-5">
<h2 class="heading-underline" id="campus">Change Campus</h2>
<a class="anchor" id="campus"></a>
<h2 class="heading-underline">Change Campus</h2>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownCampus" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Select Campus
Expand All @@ -80,15 +81,17 @@ <h2 class="heading-underline" id="campus">Change Campus</h2>
</div>
</div>
</div>

<div class="pb-5">
<h2 class="heading-underline" id="location">Location Preferences</h2>
<hr>
<div class="pt-5 pb-5">
<a class="anchor" id="location"></a>
<h2 class="heading-underline">Location Preferences</h2>
<p>Allow location services.</p>
<button type="button" class="btn btn-success btn-toggle">Enabled</button>
</div>

<div class="pb-5">
<h2 class="heading-underline" id="notification">Notification Preferences</h2>
<hr>
<div class="pt-5 pb-5">
<a class="anchor" id="notification"></a>
<h2 class="heading-underline">Notification Preferences</h2>
<h4 class="pt-4">Emergency Notifications</h4>
<p>Emergency alerts and notifications.</p>
<button type="button" class="btn btn-success btn-toggle">Enabled</button>
Expand All @@ -99,9 +102,10 @@ <h4 class="pt-4">Transit Notifications</h4>
<p>Parking, travel time.</p>
<button type="button" class="btn btn-success btn-toggle">Enabled</button>
</div>

<div class="pb-5">
<h2 class="heading-underline" id="language">Language Preferences</h2>
<hr>
<div class="pt-5 pb-5">
<a class="anchor" id="language"></a>
<h2 class="heading-underline">Language Preferences</h2>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownLanguage" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Change Language
Expand All @@ -114,9 +118,10 @@ <h2 class="heading-underline" id="language">Language Preferences</h2>
</div>
</div>
</div>

<div class="pb-5">
<h2 class="heading-underline" id="accessibility">Accessibility</h2>
<hr>
<div class="pt-5 pb-5">
<a class="anchor" id="accessibility"></a>
<h2 class="heading-underline">Accessibility</h2>

<h4 class="pt-4">Text Size</h4>
<div class="btn-group" role="group" aria-label="Basic example">
Expand All @@ -129,7 +134,7 @@ <h4 class="pt-4">High Contrast Colors</h4>
<button type="button" class="btn btn-default btn-toggle">Disabled</button>

<h4 class="pt-4">Dark Mode</h4>
<button type="button" class="btn btn-default btn-toggle">Disabled</button>
<button type="button" class="btn btn-default btn-toggle" id="dark-mode-toggle">Disabled</button>
</div>

</div>
Expand Down
22 changes: 22 additions & 0 deletions css/styles.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion css/styles.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions css/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

/* Classes */

a.anchor {
display: block;
position: relative;
top: -250px;
visibility: hidden;
}

.back {
color: #ffffff;
}
Expand Down Expand Up @@ -125,4 +132,26 @@ footer {

.nav-link > .fas:hover {
color: $brightGold50;
}

/* Dark Mode Stylings */

.darkmode, .fas.darkmode {
color: white;
}

.alert-warning.darkmode {
background-color: #f9e7c950!important;
}

.alert-info.darkmode {
background-color: #dcf3f850!important;
}

.btn.darkmode {
background-color: black;
}

body.darkmode {
background-color: black;
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dig4104c",
"version": "0.1.0",
"version": "0.2.0",
"description": "UCF Mobile App Prototype",
"main": "index.html",
"scripts": {
Expand Down
35 changes: 33 additions & 2 deletions scripts/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Set font size based on preferences*/
/* Get font size based on preferences */
function setFontSize() {
let accessibleText = "a, button:not('.text-size-toggle'), h1, h2, h3, h4, h5, h6, p";

Expand Down Expand Up @@ -42,6 +42,25 @@ function setFontSize() {
}
};

/* Get dark mode based on preferences */
function setDarkMode() {
let accessibleElements = "a, body, button, h1, h2, h3, h4, h5, h6, .alert, .fas";

if(Cookies.get('darkMode') == "true") {
$("#dark-mode-toggle").addClass("btn-success");
$("#dark-mode-toggle").removeClass("btn-default");
$("#dark-mode-toggle").text("Enabled");

$(accessibleElements).addClass("darkmode");
} else {
$("#dark-mode-toggle").addClass("btn-default");
$("#dark-mode-toggle").removeClass("btn-success");
$("#dark-mode-toggle").text("Disabled");

$(accessibleElements).removeClass("darkmode");
}
}

/* Toggle clickable buttons */
$(".btn-toggle").on("click", function(){
if ($(this).hasClass("btn-success")) {
Expand All @@ -55,7 +74,7 @@ $(".btn-toggle").on("click", function(){
}
});

/* Toggle font size buttons */
/* Set font size preferences */
$("#text-size-sm").on("click", function() {
Cookies.set('fontSize', 'sm');
setFontSize()
Expand All @@ -69,4 +88,16 @@ $("#text-size-lg").on("click", function() {
setFontSize()
});

/* Set dark mode preferences */
$("#dark-mode-toggle").on("click", function() {
if($(this).hasClass("btn-success")) {
Cookies.set('darkMode', 'true');
setDarkMode();
} else {
Cookies.set('darkMode', 'false');
setDarkMode();
}
});

setFontSize()
setDarkMode();

0 comments on commit e232ce7

Please sign in to comment.