Skip to content

Commit 9d39380

Browse files
committed
Moved node-vibrant to index.html
Themeing via index.js / App.vue was buggy and unreliable, this is a temporary workaround for "real time" themeing from the logo colours. Have to build in fallbacks if colours are not found.
1 parent 8465c1d commit 9d39380

File tree

4 files changed

+20
-44
lines changed

4 files changed

+20
-44
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# pogo-vue
2+
3+
This repository holds the source code for the new Vue.js-based webapps for Pogo's frontend. It's divided into two directories.
4+
5+
- `admin/` is the where the admin interface is, ported from the DeV interface in the main Pogo repository.
6+
7+
- `main/` is the client frontend for perusing the feed and listening to episodes.

main/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,16 @@
88
<body>
99
<div id="app"></div>
1010
<!-- built files will be auto injected -->
11+
<script type="text/javascript" src="./node_modules/node-vibrant/dist/vibrant.js"></script>
12+
<script>
13+
Vibrant.from('logo.png').getPalette().then(function(palette) {
14+
var css = document.createElement('style')
15+
css.type = 'text/css'
16+
var styles = 'a {color:' + palette.Vibrant.getHex() + ';} footer {background-color:' + palette.DarkMuted.getHex() + ';}'
17+
if (css.styleSheet) css.styleSheet.cssText = style
18+
else css.appendChild(document.createTextNode(styles))
19+
document.getElementsByTagName('head')[0].appendChild(css)
20+
});
21+
</script>
1122
</body>
1223
</html>

main/src/App.vue

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div id="app">
3-
<router-link to="/"><img src="/assets/logo-large.png" class="logo"></router-link>
3+
<router-link to="/"><img src="logo.png" class="logo"></router-link>
44
<a href="/admin" class="admin">Admin</a>
55
<router-view/>
66
<footer>
@@ -11,22 +11,7 @@
1111

1212
<script>
1313
export default {
14-
name: 'app',
15-
created () {
16-
this.setStyling()
17-
},
18-
methods: {
19-
setStyling () {
20-
var store = window.localStorage
21-
var css = document.createElement('style')
22-
css.type = 'text/css'
23-
var styles = 'a {color:' + store.getItem('colourLink') + ';} footer {background-color:' + store.getItem('colourAccent') + ';}'
24-
if (css.styleSheet) css.styleSheet.cssText = styles
25-
else css.appendChild(document.createTextNode(styles))
26-
document.getElementsByTagName('head')[0].appendChild(css)
27-
store.setItem('applied', true)
28-
}
29-
}
14+
name: 'app'
3015
}
3116
</script>
3217

main/src/main.js

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,6 @@
33
import Vue from 'vue'
44
import App from './App'
55
import router from './router'
6-
import * as Vibrant from 'node-vibrant'
7-
8-
Vue.mixin({
9-
created: function () {
10-
var colours = this.$options.colours
11-
var store = window.localStorage
12-
Vibrant.from('/assets/logo-large.png').getPalette((err, p) => {
13-
if (err === null) {
14-
colours = p
15-
console.log(p)
16-
var colourLink = colours.Vibrant.getHex()
17-
try {
18-
var colourAccent = colours.LightVibrant.getHex()
19-
} catch (e) {
20-
colourAccent = colours.DarkVibrant.getHex()
21-
}
22-
store.setItem('colourLink', colourLink)
23-
store.setItem('colourAccent', colourAccent)
24-
if (!store.getItem('applied')) {
25-
location.reload()
26-
}
27-
} else {
28-
console.log(err)
29-
}
30-
})
31-
}
32-
})
336

347
Vue.config.productionTip = false
358

0 commit comments

Comments
 (0)