mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 14:12:36 -05:00
Add basic toggle switch
This commit is contained in:
parent
d23c5cbbbe
commit
cc7de14539
1 changed files with 22 additions and 6 deletions
|
@ -8,6 +8,8 @@
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.ui.components.radio-buttons :refer [radio-button radio-buttons]]
|
||||||
|
[cuerdas.core :as str]
|
||||||
[app.main.data.tokens :as wdt]
|
[app.main.data.tokens :as wdt]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -15,6 +17,7 @@
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
|
|
||||||
(def ^:private close-icon
|
(def ^:private close-icon
|
||||||
(i/icon-xref :close (stl/css :close-icon)))
|
(i/icon-xref :close (stl/css :close-icon)))
|
||||||
|
|
||||||
|
@ -22,6 +25,22 @@
|
||||||
[{:keys []}]
|
[{:keys []}]
|
||||||
"Empty")
|
"Empty")
|
||||||
|
|
||||||
|
|
||||||
|
(mf/defc switch
|
||||||
|
[{:keys [selected? name on-change]}]
|
||||||
|
(let [selected (if selected? :on :off)]
|
||||||
|
[:& radio-buttons {:selected selected
|
||||||
|
:on-change on-change
|
||||||
|
:name name}
|
||||||
|
[:& radio-button {:id :on
|
||||||
|
:value :on
|
||||||
|
:icon i/tick
|
||||||
|
:label ""}]
|
||||||
|
[:& radio-button {:id :off
|
||||||
|
:value :off
|
||||||
|
:icon i/close
|
||||||
|
:label ""}]]))
|
||||||
|
|
||||||
(mf/defc themes-overview
|
(mf/defc themes-overview
|
||||||
[{:keys []}]
|
[{:keys []}]
|
||||||
(let [active-theme-ids (mf/deref refs/workspace-active-theme-ids)
|
(let [active-theme-ids (mf/deref refs/workspace-active-theme-ids)
|
||||||
|
@ -37,12 +56,9 @@
|
||||||
[:div.spaced
|
[:div.spaced
|
||||||
name
|
name
|
||||||
[:div.spaced
|
[:div.spaced
|
||||||
[:button
|
[:& switch {:name (str "Theme" name)
|
||||||
{:on-click (fn [e]
|
:on-change #(st/emit! (wdt/toggle-token-theme id))
|
||||||
(dom/prevent-default e)
|
:selected? (get active-theme-ids id)}]
|
||||||
(dom/stop-propagation e)
|
|
||||||
(st/emit! (wdt/toggle-token-theme id)))}
|
|
||||||
(if (get active-theme-ids id) "✅" "❎")]
|
|
||||||
[:button {:on-click (fn [e]
|
[:button {:on-click (fn [e]
|
||||||
(dom/prevent-default e)
|
(dom/prevent-default e)
|
||||||
(dom/stop-propagation e)
|
(dom/stop-propagation e)
|
||||||
|
|
Loading…
Add table
Reference in a new issue