Large refactor on the front end

Created pages directory
Added night mode
This commit is contained in:
Max G
2019-07-30 19:10:31 +00:00
parent fcee24a61d
commit 7806a206b2
14 changed files with 98 additions and 79 deletions

View File

@@ -9,7 +9,8 @@ export default new Vuex.Store({
count: 0,
message: 'Get out me yard ya wankers',
token: null,
username: null
username: null,
nightMode: false,
},
mutations: {
increment (state) {
@@ -40,6 +41,33 @@ export default new Vuex.Store({
delete axios.defaults.headers.common['Authorization']
state.token = null
state.username = null
},
toggleNightMode(state){
//Toggle state and save to local storage
state.nightMode = !(state.nightMode)
localStorage.setItem('nightMode', state.nightMode)
//Default theme colors
let themeColors = {
'background_color': '#fff',
'text_color': '#3d3d3d',
'outline_color': 'rgba(34,36,38,.15)',
}
//Night mode colors
if(state.nightMode){
themeColors = {
'background_color': '#000',
'text_color': '#a98457',
'outline_color': '#a98457',
}
}
//Go through each color and set CSS variable
let root = document.documentElement
Object.keys(themeColors).forEach( attribute => {
root.style.setProperty('--'+attribute, themeColors[attribute])
})
}
},
getters: {
@@ -55,6 +83,9 @@ export default new Vuex.Store({
getLoggedIn: state => {
let weIn = (state.token !== null && state.token != undefined && state.token.length > 0)
return weIn
}
},
getIsNightMode: state => {
return state.nightMode
},
}
})