[devdocsgjs/main: 659/1867] Set theme color depending on DevDocs theme




commit ba46b7841b8bdd9153f76f00621a66f3f5399e48
Author: Jasper van Merle <jaspervmerle gmail com>
Date:   Fri Jul 12 17:13:27 2019 +0200

    Set theme color depending on DevDocs theme

 assets/javascripts/app/settings.coffee | 4 ++++
 views/index.erb                        | 1 +
 views/other.erb                        | 1 +
 3 files changed, 6 insertions(+)
---
diff --git a/assets/javascripts/app/settings.coffee b/assets/javascripts/app/settings.coffee
index af298250..636da4e0 100644
--- a/assets/javascripts/app/settings.coffee
+++ b/assets/javascripts/app/settings.coffee
@@ -114,16 +114,20 @@ class app.Settings
     @toggleDark(@get('dark') is 1)
     @toggleLayout(layout, @hasLayout(layout)) for layout in @LAYOUTS
     @initSidebarWidth()
+    return
 
   toggleDark: (enable) ->
     classList = document.documentElement.classList
     classList.toggle('_theme-default', !enable)
     classList.toggle('_theme-dark', enable)
+    $('meta[name=theme-color]').setAttribute('content', if enable then '#1c1c1c' else '#eee')
+    return
 
   toggleLayout: (layout, enable) ->
     classList = document.body.classList
     classList.toggle(layout, enable) unless layout is '_sidebar-hidden'
     classList.toggle('_overlay-scrollbars', $.overlayScrollbarsEnabled())
+    return
 
   initSidebarWidth: ->
     size = @get('size')
diff --git a/views/index.erb b/views/index.erb
index c161fe3c..4fb96153 100644
--- a/views/index.erb
+++ b/views/index.erb
@@ -14,6 +14,7 @@
   <meta name="apple-mobile-web-app-capable" content="yes">
   <meta name="apple-mobile-web-app-status-bar-style" content="black">
   <meta name="format-detection" content="telephone=no">
+  <meta name="theme-color" content="#eee">
   <meta name="robots" content="noodp">
   <title>DevDocs API Documentation</title>
   <link rel="canonical" href="<%= canonical_origin %>">
diff --git a/views/other.erb b/views/other.erb
index 63577029..45cab943 100644
--- a/views/other.erb
+++ b/views/other.erb
@@ -5,6 +5,7 @@
   <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
   <% if doc_index_page? %><meta name="description" content="<%= @doc['name'] %> <%= @doc['release'] %> API 
documentation with instant search, offline support, keyboard shortcuts, mobile version, and more."><% else 
%><meta name="robots" content="noindex"><% end %>
   <meta name="format-detection" content="telephone=no">
+  <meta name="theme-color" content="#eee">
   <meta property="og:image" content="<%= App.cdn_origin %>/images/icon-320.png">
   <title>DevDocs<%= " &mdash; #{@doc['full_name']} documentation" if doc_index_page? %></title>
   <link rel="canonical" href="<%= canonical_origin %><%= request.path %>">


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]