Browse Source

Moved nightmode toggle to footer

Owen Diffey 4 years ago
parent
commit
79cb059818

+ 80 - 6
frontend/src/components/layout/MainFooter.vue

@@ -20,20 +20,85 @@
 					>
 					>
 					<router-link title="News" to="/news">News</router-link>
 					<router-link title="News" to="/news">News</router-link>
 				</div>
 				</div>
+				<div id="footer-nightmode-toggle">
+					<p class="is-expanded checkbox-control">
+						<label class="switch">
+							<input
+								type="checkbox"
+								id="instant-nightmode"
+								v-model="localNightmode"
+							/>
+							<span class="slider round"></span>
+						</label>
+
+						<label for="instant-nightmode">
+							<p>Nightmode</p>
+						</label>
+					</p>
+				</div>
 			</div>
 			</div>
 		</div>
 		</div>
 	</footer>
 	</footer>
 </template>
 </template>
 
 
 <script>
 <script>
+import Toast from "toasters";
+import { mapState, mapGetters, mapActions } from "vuex";
+
 export default {
 export default {
 	data() {
 	data() {
 		return {
 		return {
-			github: "#"
+			github: "#",
+			localNightmode: null
 		};
 		};
 	},
 	},
+	computed: {
+		...mapState({
+			loggedIn: state => state.user.auth.loggedIn
+		}),
+		...mapGetters({
+			socket: "websockets/getSocket"
+		})
+	},
+	watch: {
+		localNightmode(newValue, oldValue) {
+			if (oldValue === null) return;
+
+			localStorage.setItem("nightmode", this.localNightmode);
+
+			if (this.loggedIn) {
+				this.socket.dispatch(
+					"users.updatePreferences",
+					{ nightmode: this.localNightmode },
+					res => {
+						if (res.status !== "success") new Toast(res.message);
+					}
+				);
+			}
+
+			this.changeNightmode(this.localNightmode);
+		}
+	},
 	async mounted() {
 	async mounted() {
 		this.github = await lofig.get("siteSettings.github");
 		this.github = await lofig.get("siteSettings.github");
+
+		this.localNightmode = JSON.parse(localStorage.getItem("nightmode"));
+
+		this.socket.dispatch("users.getPreferences", res => {
+			if (res.status === "success")
+				this.localNightmode = res.data.preferences.nightmode;
+		});
+
+		this.socket.on("keep.event:user.preferences.updated", res => {
+			if (res.data.preferences.nightmode !== undefined)
+				this.localNightmode = res.data.preferences.nightmode;
+		});
+
+		this.frontendDomain = await lofig.get("frontendDomain");
+		this.siteSettings = await lofig.get("siteSettings");
+	},
+	methods: {
+		...mapActions("user/preferences", ["changeNightmode"])
 	}
 	}
 };
 };
 </script>
 </script>
@@ -51,14 +116,13 @@ export default {
 	position: relative;
 	position: relative;
 	bottom: 0;
 	bottom: 0;
 	flex-shrink: 0;
 	flex-shrink: 0;
-	height: auto;
 	padding: 20px;
 	padding: 20px;
 	border-radius: 33% 33% 0% 0% / 7% 7% 0% 0%;
 	border-radius: 33% 33% 0% 0% / 7% 7% 0% 0%;
 	box-shadow: 0 4px 8px 0 rgba(3, 169, 244, 0.4),
 	box-shadow: 0 4px 8px 0 rgba(3, 169, 244, 0.4),
 		0 6px 20px 0 rgba(3, 169, 244, 0.2);
 		0 6px 20px 0 rgba(3, 169, 244, 0.2);
 	background-color: var(--white);
 	background-color: var(--white);
 	width: 100%;
 	width: 100%;
-	height: 160px;
+	height: 200px;
 	font-size: 16px;
 	font-size: 16px;
 
 
 	.footer-content {
 	.footer-content {
@@ -89,7 +153,7 @@ export default {
 	}
 	}
 
 
 	#footer-links {
 	#footer-links {
-		order: 2;
+		order: 3;
 
 
 		:not(:last-child) {
 		:not(:last-child) {
 			border-right: solid 1px var(--primary-color);
 			border-right: solid 1px var(--primary-color);
@@ -115,15 +179,20 @@ export default {
 	}
 	}
 
 
 	#footer-copyright {
 	#footer-copyright {
-		order: 3;
+		order: 4;
+	}
+
+	#footer-nightmode-toggle {
+		order: 2;
 	}
 	}
 }
 }
 
 
 @media only screen and (min-width: 990px) {
 @media only screen and (min-width: 990px) {
 	.footer {
 	.footer {
-		height: 100px;
+		height: 140px;
 
 
 		#footer-copyright {
 		#footer-copyright {
+			order: 3;
 			left: 0;
 			left: 0;
 			top: 0;
 			top: 0;
 			position: absolute;
 			position: absolute;
@@ -131,11 +200,16 @@ export default {
 		}
 		}
 
 
 		#footer-links {
 		#footer-links {
+			order: 2;
 			right: 0;
 			right: 0;
 			top: 0;
 			top: 0;
 			position: absolute;
 			position: absolute;
 			line-height: 50px;
 			line-height: 50px;
 		}
 		}
+
+		#footer-nightmode-toggle {
+			order: 4;
+		}
 	}
 	}
 }
 }
 </style>
 </style>

+ 1 - 51
frontend/src/components/layout/MainHeader.vue

@@ -52,28 +52,11 @@
 					>Register</a
 					>Register</a
 				>
 				>
 			</span>
 			</span>
-			<div class="nav-item" id="nightmode-toggle">
-				<p class="is-expanded checkbox-control">
-					<label class="switch">
-						<input
-							type="checkbox"
-							id="instant-nightmode"
-							v-model="localNightmode"
-						/>
-						<span class="slider round"></span>
-					</label>
-
-					<label for="instant-nightmode">
-						<p>Nightmode</p>
-					</label>
-				</p>
-			</div>
 		</div>
 		</div>
 	</nav>
 	</nav>
 </template>
 </template>
 
 
 <script>
 <script>
-import Toast from "toasters";
 import { mapState, mapGetters, mapActions } from "vuex";
 import { mapState, mapGetters, mapActions } from "vuex";
 
 
 export default {
 export default {
@@ -84,7 +67,6 @@ export default {
 	},
 	},
 	data() {
 	data() {
 		return {
 		return {
-			localNightmode: null,
 			isMobile: false,
 			isMobile: false,
 			frontendDomain: "",
 			frontendDomain: "",
 			siteSettings: {
 			siteSettings: {
@@ -104,46 +86,14 @@ export default {
 			socket: "websockets/getSocket"
 			socket: "websockets/getSocket"
 		})
 		})
 	},
 	},
-	watch: {
-		localNightmode(newValue, oldValue) {
-			if (oldValue === null) return;
-
-			localStorage.setItem("nightmode", this.localNightmode);
-
-			if (this.loggedIn) {
-				this.socket.dispatch(
-					"users.updatePreferences",
-					{ nightmode: this.localNightmode },
-					res => {
-						if (res.status !== "success") new Toast(res.message);
-					}
-				);
-			}
-
-			this.changeNightmode(this.localNightmode);
-		}
-	},
 	async mounted() {
 	async mounted() {
-		this.localNightmode = JSON.parse(localStorage.getItem("nightmode"));
-
-		this.socket.dispatch("users.getPreferences", res => {
-			if (res.status === "success")
-				this.localNightmode = res.data.preferences.nightmode;
-		});
-
-		this.socket.on("keep.event:user.preferences.updated", res => {
-			if (res.data.preferences.nightmode !== undefined)
-				this.localNightmode = res.data.preferences.nightmode;
-		});
-
 		this.frontendDomain = await lofig.get("frontendDomain");
 		this.frontendDomain = await lofig.get("frontendDomain");
 		this.siteSettings = await lofig.get("siteSettings");
 		this.siteSettings = await lofig.get("siteSettings");
 	},
 	},
 
 
 	methods: {
 	methods: {
 		...mapActions("modalVisibility", ["openModal"]),
 		...mapActions("modalVisibility", ["openModal"]),
-		...mapActions("user/auth", ["logout"]),
-		...mapActions("user/preferences", ["changeNightmode"])
+		...mapActions("user/auth", ["logout"])
 	}
 	}
 };
 };
 </script>
 </script>

+ 19 - 10
frontend/src/pages/Admin/index.vue

@@ -118,16 +118,20 @@
 			</ul>
 			</ul>
 		</div>
 		</div>
 
 
-		<unverified-songs v-if="currentTab == 'unverifiedsongs'" />
-		<verified-songs v-if="currentTab == 'verifiedsongs'" />
-		<hidden-songs v-if="currentTab == 'hiddensongs'" />
-		<stations v-if="currentTab == 'stations'" />
-		<playlists v-if="currentTab == 'playlists'" />
-		<reports v-if="currentTab == 'reports'" />
-		<news v-if="currentTab == 'news'" />
-		<users v-if="currentTab == 'users'" />
-		<statistics v-if="currentTab == 'statistics'" />
-		<punishments v-if="currentTab == 'punishments'" />
+		<div class="admin-container">
+			<unverified-songs v-if="currentTab == 'unverifiedsongs'" />
+			<verified-songs v-if="currentTab == 'verifiedsongs'" />
+			<hidden-songs v-if="currentTab == 'hiddensongs'" />
+			<stations v-if="currentTab == 'stations'" />
+			<playlists v-if="currentTab == 'playlists'" />
+			<reports v-if="currentTab == 'reports'" />
+			<news v-if="currentTab == 'news'" />
+			<users v-if="currentTab == 'users'" />
+			<statistics v-if="currentTab == 'statistics'" />
+			<punishments v-if="currentTab == 'punishments'" />
+		</div>
+
+		<main-footer />
 	</div>
 	</div>
 </template>
 </template>
 
 
@@ -136,10 +140,12 @@ import { mapGetters } from "vuex";
 import { defineAsyncComponent } from "vue";
 import { defineAsyncComponent } from "vue";
 
 
 import MainHeader from "@/components/layout/MainHeader.vue";
 import MainHeader from "@/components/layout/MainHeader.vue";
+import MainFooter from "@/components/layout/MainFooter.vue";
 
 
 export default {
 export default {
 	components: {
 	components: {
 		MainHeader,
 		MainHeader,
+		MainFooter,
 		UnverifiedSongs: defineAsyncComponent(() =>
 		UnverifiedSongs: defineAsyncComponent(() =>
 			import("./tabs/UnverifiedSongs.vue")
 			import("./tabs/UnverifiedSongs.vue")
 		),
 		),
@@ -240,6 +246,9 @@ export default {
 
 
 .main-container {
 .main-container {
 	height: auto;
 	height: auto;
+	.admin-container {
+		flex: 1 0 auto;
+	}
 }
 }
 
 
 .tabs {
 .tabs {