added user config for dark mode and navigation

This commit is contained in:
Brian McGonagill 2024-07-25 10:25:56 -05:00
parent 1d7ecc3efa
commit 40af926104
7 changed files with 82 additions and 16 deletions

View file

@ -1,3 +1,21 @@
<template name="userConfig">
<h4>My Settings</h4>
<div class="row">
<div class="col s12 m6 l4">
<div class="card">
<div class="card-content">
<span class="card-title">Dark / Light Mode</span>
<div class="switch">
<label>
Light
<input type="checkbox" id="darkMode">
<span class="lever"></span>
Dark
</label>
</div>
</div>
</div>
</div>
</div>
{{> snackbar}}
</template>

View file

@ -5,7 +5,15 @@ Template.userConfig.onCreated(function() {
});
Template.userConfig.onRendered(function() {
let myConfig = UserConfig.findOne({ user: Meteor.userId() });
if (typeof myConfig != 'undefined') {
console.log("My Pref: " + myConfig.darkPref);
if (myConfig.darkMode == 'light') {
$("#darkMode").prop('checked', false);
} else {
$("#darkMode").prop('checked', true);
}
}
});
Template.userConfig.helpers({
@ -13,5 +21,24 @@ Template.userConfig.helpers({
});
Template.userConfig.events({
'click #darkMode' (event) {
let darkModePref = $("#darkMode").prop('checked');
if (darkModePref == true) {
Meteor.call('update.darkModePref', 'dark', function(err, reuslt) {
if (err) {
console.log(" ERROR: could not set dark mode preference to dark: " + err);
} else {
showSnackbar("Dark Mode Preference Set to Dark", "green");
}
});
} else {
Meteor.call('update.darkModePref', 'light', function(err, result) {
if (err) {
console.log(" ERROR: could not set dark mode preference to light: " + err);
} else {
showSnackbar("Dark Mode Preference Set to Light", "green");
}
});
}
},
});