diff options
author | Bastien Wirtz <bastien.wirtz@gmail.com> | 2020-05-30 23:22:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-30 23:22:02 -0700 |
commit | 5fa6b6cfa6b3010279ead23088add5c5664e8ac0 (patch) | |
tree | 5f3ffa4dc62b4355d38346ef0155878ca6aeedcd /src/components/DynamicTheme.vue | |
parent | ab7ac44c191e3b7dea696e76b74097e23f73b18c (diff) | |
parent | 9052ec59b75a37b4518ad39c493ee6c2d4198b98 (diff) | |
download | homer-5fa6b6cfa6b3010279ead23088add5c5664e8ac0.tar.gz homer-5fa6b6cfa6b3010279ead23088add5c5664e8ac0.tar.zst homer-5fa6b6cfa6b3010279ead23088add5c5664e8ac0.zip |
Merge pull request #62 from bastienwirtz/dev/build-system120405250
Build system integration using vue-cli.
Diffstat (limited to 'src/components/DynamicTheme.vue')
-rw-r--r-- | src/components/DynamicTheme.vue | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/components/DynamicTheme.vue b/src/components/DynamicTheme.vue new file mode 100644 index 0000000..cf9963b --- /dev/null +++ b/src/components/DynamicTheme.vue | |||
@@ -0,0 +1,34 @@ | |||
1 | <template> | ||
2 | <DynamicStyle> | ||
3 | /* light / dark theme switch based on system pref if available */ body #app | ||
4 | { | ||
5 | {{ getVars(themes.light) }} | ||
6 | } @media (prefers-color-scheme: light), (prefers-color-scheme: | ||
7 | no-preference) { body #app { | ||
8 | {{ getVars(themes.light) }} | ||
9 | } } @media (prefers-color-scheme: dark) { body #app { } } /* light / dark | ||
10 | theme override base on user choice. */ body #app.is-dark { | ||
11 | {{ getVars(themes.dark) }} | ||
12 | } body #app.is-light { | ||
13 | {{ getVars(themes.light) }} | ||
14 | } | ||
15 | </DynamicStyle> | ||
16 | </template> | ||
17 | |||
18 | <script> | ||
19 | export default { | ||
20 | name: "DynamicTheme", | ||
21 | props: { | ||
22 | themes: Object, | ||
23 | }, | ||
24 | methods: { | ||
25 | getVars: function (theme) { | ||
26 | let vars = []; | ||
27 | for (const themeVars in theme) { | ||
28 | vars.push(`--${themeVars}: ${theme[themeVars]}`); | ||
29 | } | ||
30 | return vars.join(";"); | ||
31 | }, | ||
32 | }, | ||
33 | }; | ||
34 | </script> | ||