Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP 🚀: Dark mode #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Darkmode: refactor switch
  • Loading branch information
lucasjs committed Oct 30, 2019
commit 91493c0f4e0225acc0ff376c3ca84c58fbf5efa5
4 changes: 4 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -17,6 +17,10 @@ export default {
Header,
Footer,
},
mounted() {
const bodyTag = document.body;
bodyTag.classList.add(this.$store.state.theme);
},
};
</script>

6 changes: 6 additions & 0 deletions src/components/Header/Header.vue
Original file line number Diff line number Diff line change
@@ -50,7 +50,13 @@ export default {
},
methods: {
switchTheme(event) {
const bodyTag = document.body;
// eslint-disable-next-line no-unused-expressions
bodyTag.classList.contains('light')
? bodyTag.classList.remove('light')
: bodyTag.classList.remove('dark');
this.$store.commit('currentTheme', event.target.checked);
bodyTag.classList.add(this.$store.state.theme);
},
},
};