Duplicate a palette from the palette bar
Making a variant meant 16 colour pickers from black: the only button was "+", which seeds an untitled palette from the built-in defaults. The copy is selected on creation, so the next colour edit lands on it rather than on the palette it came from. `pal/palettes` is the source, so the implicit default — a project that has never had a palette asset of its own — duplicates like any other. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
2460dce0a5
commit
09b74de162
2 changed files with 20 additions and 0 deletions
|
|
@ -703,6 +703,24 @@
|
|||
(-> (edit/edit db #(assoc-in % [:palettes id] p))
|
||||
(assoc-in [:ui :palette] id)))))
|
||||
|
||||
(rf/reg-event-db
|
||||
::duplicate-palette
|
||||
;; A copy of an existing palette, selected so the next colour edit lands on the
|
||||
;; copy rather than the original. The point is a variant: start from a palette
|
||||
;; that works and change two tones, instead of 16 colour pickers from black.
|
||||
;; `pal/palettes` is the source so the implicit default - a project that has
|
||||
;; never had a palette asset of its own - can be duplicated like any other.
|
||||
(fn [db [_ id]]
|
||||
(let [clip (:clip (store/entry (:clip/current db)))
|
||||
p (get (pal/palettes clip) id)]
|
||||
(if-not p
|
||||
db
|
||||
(let [new-id (random-uuid)]
|
||||
(-> (edit/edit db #(assoc-in % [:palettes new-id]
|
||||
(assoc p :id new-id
|
||||
:name (str (:name p) " copy"))))
|
||||
(assoc-in [:ui :palette] new-id)))))))
|
||||
|
||||
(rf/reg-event-db
|
||||
::palette-name
|
||||
(fn [db [_ id value]]
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@
|
|||
(for [[id p] (sort-by (comp str :name val) (pal/palettes clip))]
|
||||
^{:key (str id)} [:option {:value (str id)} (:name p)])]
|
||||
[:button {:title "new 16-slot palette" :on-click #(rf/dispatch [::project/new-palette])} "+"]
|
||||
[:button {:title (str "duplicate " (:name palette) " — a copy you can retone")
|
||||
:on-click #(rf/dispatch [::project/duplicate-palette pid])} "⧉"]
|
||||
[:div.swatches (doall (map-indexed #(swatch pid %1 %2 tone placements) (:slots palette)))]
|
||||
[:span.dim (str tone)]
|
||||
(when (> (count selections) 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue