Merge pull request #1805 from penpot/hirunatan-set-html-theme

Hirunatan set html theme
This commit is contained in:
Andrey Antukh 2022-04-20 09:20:46 +02:00 committed by GitHub
commit 506f63317a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 1 deletions

View file

@ -41,6 +41,7 @@
- Add the ability to disable standard, password login [Taiga #2999](https://tree.taiga.io/project/penpot/us/2999) - Add the ability to disable standard, password login [Taiga #2999](https://tree.taiga.io/project/penpot/us/2999)
- Don't stop SVG import when an image cannot be imported [#1531](https://github.com/penpot/penpot/issues/1531) - Don't stop SVG import when an image cannot be imported [#1531](https://github.com/penpot/penpot/issues/1531)
- Fix paste shapes while editing text [Taiga #2396](https://tree.taiga.io/project/penpot/issue/2396) - Fix paste shapes while editing text [Taiga #2396](https://tree.taiga.io/project/penpot/issue/2396)
- Show Penpot color in Safari tab bar [#1803](https://github.com/penpot/penpot/issues/1803)
### :bug: Bugs fixed ### :bug: Bugs fixed

View file

@ -14,6 +14,7 @@
(def gray-20 "#B1B2B5") (def gray-20 "#B1B2B5")
(def gray-30 "#7B7D85") (def gray-30 "#7B7D85")
(def gray-40 "#64666A") (def gray-40 "#64666A")
(def gray-50 "#303236")
(def info "#59B9E2") (def info "#59B9E2")
(def test "#fabada") (def test "#fabada")
(def white "#FFFFFF") (def white "#FFFFFF")

View file

@ -15,6 +15,7 @@
<meta name="twitter:image" content="https://penpot.app/images/workspace-ui.jpg"> <meta name="twitter:image" content="https://penpot.app/images/workspace-ui.jpg">
<meta name="twitter:site" content="@penpotapp"> <meta name="twitter:site" content="@penpotapp">
<meta name="twitter:creator" content="@penpotapp"> <meta name="twitter:creator" content="@penpotapp">
<meta name="theme-color" content="#FFFFFF" media="(prefers-color-scheme: light)">
<link id="theme" href="css/main-{{& th}}.css?ts={{& ts}}" rel="stylesheet" type="text/css" /> <link id="theme" href="css/main-{{& th}}.css?ts={{& ts}}" rel="stylesheet" type="text/css" />
<link rel="icon" href="images/favicon.png" /> <link rel="icon" href="images/favicon.png" />

View file

@ -6,6 +6,7 @@
(ns app.main.ui.dashboard (ns app.main.ui.dashboard
(:require (:require
[app.common.colors :as clr]
[app.common.spec :as us] [app.common.spec :as us]
[app.main.data.dashboard :as dd] [app.main.data.dashboard :as dd]
[app.main.data.dashboard.shortcuts :as sc] [app.main.data.dashboard.shortcuts :as sc]
@ -22,6 +23,7 @@
[app.main.ui.dashboard.sidebar :refer [sidebar]] [app.main.ui.dashboard.sidebar :refer [sidebar]]
[app.main.ui.dashboard.team :refer [team-settings-page team-members-page team-invitations-page]] [app.main.ui.dashboard.team :refer [team-settings-page team-members-page team-invitations-page]]
[app.main.ui.hooks :as hooks] [app.main.ui.hooks :as hooks]
[app.util.dom :as dom]
[app.util.keyboard :as kbd] [app.util.keyboard :as kbd]
[goog.events :as events] [goog.events :as events]
[rumext.alpha :as mf]) [rumext.alpha :as mf])
@ -103,6 +105,7 @@
(mf/use-effect (mf/use-effect
(fn [] (fn []
(dom/set-html-theme-color clr/white "light")
(let [events [(events/listen goog/global EventType.KEYDOWN (let [events [(events/listen goog/global EventType.KEYDOWN
(fn [event] (fn [event]
(when (kbd/enter? event) (when (kbd/enter? event)

View file

@ -6,6 +6,7 @@
(ns app.main.ui.viewer (ns app.main.ui.viewer
(:require (:require
[app.common.colors :as clr]
[app.common.data :as d] [app.common.data :as d]
[app.common.exceptions :as ex] [app.common.exceptions :as ex]
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
@ -142,6 +143,7 @@
(mf/use-effect (mf/use-effect
(fn [] (fn []
(dom/set-html-theme-color clr/gray-50 "dark")
(let [key1 (events/listen js/window "click" on-click)] (let [key1 (events/listen js/window "click" on-click)]
(fn [] (fn []
(events/unlistenByKey key1))))) (events/unlistenByKey key1)))))

View file

@ -6,6 +6,7 @@
(ns app.main.ui.workspace (ns app.main.ui.workspace
(:require (:require
[app.common.colors :as clr]
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.main.data.messages :as msg] [app.main.data.messages :as msg]
[app.main.data.workspace :as dw] [app.main.data.workspace :as dw]
@ -130,8 +131,9 @@
(st/emit! ::dwp/force-persist (st/emit! ::dwp/force-persist
(dw/finalize-file project-id file-id)))) (dw/finalize-file project-id file-id))))
;; Close any non-modal dialog that may be still open ;; Set html theme color and close any non-modal dialog that may be still open
(mf/with-effect (mf/with-effect
(dom/set-html-theme-color clr/gray-50 "dark")
(st/emit! msg/hide)) (st/emit! msg/hide))
;; Set properly the page title ;; Set properly the page title

View file

@ -43,6 +43,12 @@
[^string title] [^string title]
(set! (.-title globals/document) title)) (set! (.-title globals/document) title))
(defn set-html-theme-color
[^string color scheme]
(let [meta-node (.querySelector js/document "meta[name='theme-color']")]
(.setAttribute meta-node "content" color)
(.setAttribute meta-node "media" (str/format "(prefers-color-scheme: %s)" scheme))))
(defn set-page-style! (defn set-page-style!
[styles] [styles]
(let [node (first (get-elements-by-tag globals/document "head")) (let [node (first (get-elements-by-tag globals/document "head"))