Skip to content

Commit ac9b635

Browse files
asimpsonnkanaev
authored andcommitted
app: add support for theme-color
I use the "web app" version of yarr on my iPhone and the area around the notch/island is un-themed. Using [theme-color][1] we can control that color. [1]: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta/name/theme-color
1 parent 72a1930 commit ac9b635

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/assets/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<link rel="icon" href="./static/graphicarts/favicon.svg" type="image/svg+xml">
99
<link rel="alternate icon" href="./static/graphicarts/favicon.png" type="image/png">
1010
<link rel="manifest" href="./manifest.json" />
11+
<meta name="theme-color" content="" />
1112
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
1213
<script>
1314
window.app = window.app || {}

src/assets/javascripts/app.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ var vm = new Vue({
211211
api.feeds.list_errors().then(function(errors) {
212212
vm.feed_errors = errors
213213
})
214+
this.updateMetaTheme(app.settings.theme_name)
214215
},
215216
data: function() {
216217
var s = app.settings
@@ -249,6 +250,11 @@ var vm = new Vue({
249250
'font': s.theme_font,
250251
'size': s.theme_size,
251252
},
253+
'themeColors': {
254+
'night': '#0e0e0e',
255+
'sepia': '#f4f0e5',
256+
'light': '#fff',
257+
},
252258
'refreshRate': s.refresh_rate,
253259
'authenticated': app.authenticated,
254260
'feed_errors': {},
@@ -330,6 +336,7 @@ var vm = new Vue({
330336
'theme': {
331337
deep: true,
332338
handler: function(theme) {
339+
this.updateMetaTheme(theme.name)
333340
document.body.classList.value = 'theme-' + theme.name
334341
api.settings.update({
335342
theme_name: theme.name,
@@ -405,6 +412,9 @@ var vm = new Vue({
405412
},
406413
},
407414
methods: {
415+
updateMetaTheme: function(theme) {
416+
document.querySelector("meta[name='theme-color']").content = this.themeColors[theme]
417+
},
408418
refreshStats: function(loopMode) {
409419
return api.status().then(function(data) {
410420
if (loopMode && !vm.itemSelected) vm.refreshItems()

0 commit comments

Comments
 (0)