mirror of
https://github.com/penpot/penpot.git
synced 2025-05-20 20:26:14 +02:00
✨ Fixing show color hex or name on hover
This commit is contained in:
parent
a86e3a8636
commit
a4c45942c9
3 changed files with 43 additions and 34 deletions
|
@ -10,26 +10,29 @@
|
|||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(mf/defc color-bullet [{:keys [color on-click]}]
|
||||
(if (uc/multiple? color)
|
||||
[:div.color-bullet.multiple {:on-click #(when on-click (on-click %))}]
|
||||
|
||||
;; No multiple selection
|
||||
(let [color (if (string? color) {:color color :opacity 1} color)]
|
||||
[:div.color-bullet.tooltip.tooltip-right {:class (when (:id color) "is-library-color")
|
||||
:on-click #(when on-click (on-click %))
|
||||
:alt (or (:name color) (:color color))}
|
||||
(when (not (:gradient color))
|
||||
[:div.color-bullet-left {:style {:background (uc/color->background (assoc color :opacity 1))}}])
|
||||
|
||||
[:div.color-bullet-right {:style {:background (uc/color->background color)}}]])))
|
||||
|
||||
(defn gradient-type->string [type]
|
||||
(case type
|
||||
:linear (tr "workspace.gradients.linear")
|
||||
:radial (tr "workspace.gradients.radial")
|
||||
(str "???" type)))
|
||||
|
||||
(mf/defc color-bullet [{:keys [color on-click]}]
|
||||
(if (uc/multiple? color)
|
||||
[:div.color-bullet.multiple {:on-click #(when on-click (on-click %))}]
|
||||
|
||||
;; No multiple selection
|
||||
(let [color (if (string? color) {:color color :opacity 1} color)
|
||||
background (if (:gradient color) (uc/color->background color) "auto")]
|
||||
[:div.color-bullet.tooltip.tooltip-right {:class (if (:id color) "is-library-color" "is-not-library-color")
|
||||
:on-click #(when on-click (on-click %))
|
||||
:alt (or (:name color) (:color color) (gradient-type->string (:type (:gradient color))))
|
||||
:style {:background background}}
|
||||
(when (not(:gradient color))
|
||||
[:*
|
||||
[:div.color-bullet-left {:style {:background (uc/color->background (assoc color :opacity 1))}}]
|
||||
[:div.color-bullet-right {:style {:background (uc/color->background color)}}]]
|
||||
)])))
|
||||
|
||||
(mf/defc color-name [{:keys [color size on-click on-double-click]}]
|
||||
(let [color (if (string? color) {:color color :opacity 1} color)
|
||||
{:keys [name color gradient]} color
|
||||
|
|
|
@ -133,7 +133,8 @@
|
|||
|
||||
handle-change-color
|
||||
(fn [changes]
|
||||
(let [editing-stop (:editing-stop @state)]
|
||||
(let [editing-stop (:editing-stop @state)
|
||||
_ (println "handle-change-color" changes)]
|
||||
(swap! state #(cond-> %
|
||||
true (update :current-color merge changes)
|
||||
editing-stop (update-in [:stops editing-stop] merge changes)))
|
||||
|
@ -158,12 +159,14 @@
|
|||
|
||||
on-select-library-color
|
||||
(fn [color]
|
||||
(let [editing-stop (:editing-stop @state)
|
||||
is-gradient? (some? (:gradient color))]
|
||||
(if (and (some? editing-stop) (not is-gradient?))
|
||||
(handle-change-color (color->components (:color color) (:opacity color)))
|
||||
(do (reset! state (data->state color))
|
||||
(on-change color)))))
|
||||
;; TODO: FIXME
|
||||
(on-change color))
|
||||
;; (let [editing-stop (:editing-stop @state)
|
||||
;; is-gradient? (some? (:gradient color))]
|
||||
;; (if (and (some? editing-stop) (not is-gradient?))
|
||||
;; (handle-change-color (color->components (:color color) (:opacity color)))
|
||||
;; (do (reset! state (data->state color))
|
||||
;; (on-change color)))))
|
||||
|
||||
on-add-library-color
|
||||
(fn [_]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue