Browse Source

enhance: allow CLI and github action to set color accent

Gabriel Horner 1 year ago
parent
commit
548fa98605

+ 5 - 2
deps/publishing/src/logseq/publishing.cljs

@@ -13,6 +13,7 @@
 configuration is done through logseq/config.edn. There are a few explicit options that
 can be passed:
 * :ui/theme - Theme mode that can either be 'light' or 'dark'.
+* :ui/radix-color - Accent color. See available values in Settings.
 * :html-options - A map of values that are inserted into index.html. Map keys
   can be icon, name, alias, title, description and url
 * :default-notification-fn - Configure how errors are reported when creating the export.
@@ -21,8 +22,10 @@ can be passed:
                                        :or {notification-fn default-notification-fn}
                                        :as options}]
   (let [options' (cond-> options
-                         (:ui/theme options)
-                         (assoc :app-state {:ui/theme (:ui/theme options)}))
+                   (:ui/theme options)
+                   (assoc-in [:app-state :ui/theme] (:ui/theme options))
+                   (:ui/radix-color options)
+                   (assoc-in [:app-state :ui/radix-color] (:ui/radix-color options)))
         {:keys [html asset-filenames]} (publish-html/build-html db options')]
     (publish-export/create-export html static-dir graph-dir output-dir {:asset-filenames asset-filenames
                                                                         :notification-fn notification-fn})))

+ 1 - 1
scripts/src/logseq/tasks/dev/publishing.cljs

@@ -23,4 +23,4 @@
                        static-dir
                        graph-dir
                        output-path
-                       {:repo-config repo-config})))
+                       {:repo-config repo-config :ui/theme "dark" :ui/radix-color :purple})))

+ 1 - 0
src/main/frontend/components/settings.cljs

@@ -325,6 +325,7 @@
                           :let [active? (= color color-accent)]]
                       [:div.flex.items-center {:style {:height 28}}
                        [:div {:class "w-5 h-5 rounded-full flex justify-center items-center transition ease-in duration-100 hover:cursor-pointer hover:opacity-100"
+                              :title color
                               :style {:background-color (colors/variable color :09)
                                       :outline-color (colors/variable color (if active? :07 :06))
                                       :outline-width (if active? "4px" "1px")

+ 3 - 0
src/main/frontend/publishing.cljs

@@ -2,6 +2,7 @@
   "Entry ns for publishing build. Provides frontend for publishing single page
   application"
   (:require [frontend.state :as state]
+            [frontend.colors :as colors]
             [datascript.core :as d]
             [frontend.db :as db]
             [logseq.db.schema :as db-schema]
@@ -94,6 +95,8 @@
   (i18n/start)
   (restore-from-transit-str!)
   (restore-state!)
+  (when-let [radix-color (state/get-color-accent)]
+    (colors/set-radix radix-color))
   (shortcut/refresh!)
   (events/run!)
   ;; actually, there's no persist for publishing