Set theme color depending on DevDocs theme

pull/1022/head
Jasper van Merle 6 years ago
parent c28305b0b7
commit ba46b7841b

@ -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')

@ -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 %>">

@ -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 %>">

Loading…
Cancel
Save