mirror of
https://github.com/penpot/penpot.git
synced 2025-02-10 09:08:31 -05:00
Remove usage of deprecated functions from lentes library.
This commit is contained in:
parent
73b901954a
commit
f80ac704a7
32 changed files with 62 additions and 68 deletions
|
@ -80,11 +80,11 @@
|
|||
(defn focus-form-data
|
||||
[type]
|
||||
(-> (l/in [:forms type])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(defn focus-form-errors
|
||||
[type]
|
||||
(-> (l/in [:errors type])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
(def auth-l
|
||||
(-> (l/key :auth)
|
||||
(l/focus-atom state)))
|
||||
(l/derive state)))
|
||||
|
||||
(defn initial-state
|
||||
[]
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
(def route-l
|
||||
(-> (l/key :route)
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
;; --- Error Handling
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
|
||||
(def form-data
|
||||
(-> (l/in [:forms :recovery])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def form-errors
|
||||
(-> (l/in [:errors :recovery])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def set-value!
|
||||
(partial udf/assign-field-value :recovery))
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
|
||||
(def form-data
|
||||
(-> (l/in [:forms :recovery-request])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def form-errors
|
||||
(-> (l/in [:errors :recovery-request])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def set-value!
|
||||
(partial udf/assign-field-value :recovery-request))
|
||||
|
|
|
@ -27,11 +27,11 @@
|
|||
|
||||
(def form-data
|
||||
(-> (l/in [:forms :register])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def form-errors
|
||||
(-> (l/in [:errors :register])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def set-value!
|
||||
(partial udf/assign-field-value :register))
|
||||
|
|
|
@ -33,17 +33,17 @@
|
|||
|
||||
(def ^:private dashboard-l
|
||||
(-> (l/key :dashboard)
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def ^:private collections-by-id-l
|
||||
(-> (comp (l/key :colors-by-id)
|
||||
(ul/merge library/+color-collections-by-id+))
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(defn- focus-collection
|
||||
[collid]
|
||||
(-> (l/key collid)
|
||||
(l/focus-atom collections-by-id-l)))
|
||||
(l/derive collections-by-id-l)))
|
||||
|
||||
;; --- Page Title
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
(def header-l
|
||||
(as-> (l/in [:dashboard]) $
|
||||
(l/focus-atom $ s/state)))
|
||||
(l/derive $ s/state)))
|
||||
|
||||
(defn- header-link
|
||||
[section content]
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
(def dashboard-l
|
||||
(as-> (l/in [:dashboard]) $
|
||||
(l/focus-atom $ st/state)))
|
||||
(l/derive $ st/state)))
|
||||
|
||||
;; --- Page Title
|
||||
|
||||
|
|
|
@ -54,24 +54,24 @@
|
|||
|
||||
(def ^:private dashboard-l
|
||||
(-> (l/key :dashboard)
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def ^:private collections-by-id-l
|
||||
(-> (l/key :images-by-id)
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def ^:private images-ordering-l
|
||||
(-> (l/in [:dashboard :images-order])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def ^:private images-filtering-l
|
||||
(-> (l/in [:dashboard :images-filter])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(defn- focus-collection
|
||||
[collid]
|
||||
(-> (l/key collid)
|
||||
(l/focus-atom collections-by-id-l)))
|
||||
(l/derive collections-by-id-l)))
|
||||
|
||||
;; --- Page Title
|
||||
|
||||
|
|
|
@ -64,15 +64,15 @@
|
|||
|
||||
(def projects-by-id-l
|
||||
(as-> (l/key :projects-by-id) $
|
||||
(l/focus-atom $ s/state)))
|
||||
(l/derive $ s/state)))
|
||||
|
||||
(def project-ordering-l
|
||||
(as-> (l/in [:dashboard :project-order]) $
|
||||
(l/focus-atom $ s/state)))
|
||||
(l/derive $ s/state)))
|
||||
|
||||
(def project-filtering-l
|
||||
(as-> (l/in [:dashboard :project-filter]) $
|
||||
(l/focus-atom $ s/state)))
|
||||
(l/derive $ s/state)))
|
||||
|
||||
;; --- Sort Widget
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
(def ^:const ^:private lightbox-l
|
||||
(-> (l/key :lightbox)
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
;; --- Lightbox (Component)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
(def ^:const ^:private message-l
|
||||
(-> (l/key :message)
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
;; --- Notification Component
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
(def ^:private section-l
|
||||
(-> (l/in [:route :id])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(defn- header-link
|
||||
[section content]
|
||||
|
|
|
@ -28,11 +28,11 @@
|
|||
|
||||
(def formdata
|
||||
(-> (l/in [:forms :profile/password])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def formerrors
|
||||
(-> (l/in [:errors :profile/password])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def assign-field-value
|
||||
(partial udf/assign-field-value :profile/password))
|
||||
|
|
|
@ -28,18 +28,18 @@
|
|||
|
||||
(def formdata
|
||||
(-> (l/in [:forms :profile/main])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def formerrors
|
||||
(-> (l/in [:errors :profile/main])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def assign-field-value
|
||||
(partial udf/assign-field-value :profile/main))
|
||||
|
||||
(def ^:private profile-l
|
||||
(-> (l/key :profile)
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
;; --- Profile Form
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
(defn- focus-shape
|
||||
[id]
|
||||
(-> (l/in [:shapes-by-id id])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(defn- shape-render
|
||||
[own id]
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
|
||||
(def ^:const selected-shapes-l
|
||||
(-> (l/in [:workspace :selected])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def ^:const drawing-state-l
|
||||
(-> (l/in [:workspace :drawing])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
;; --- Events
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
(def profile-l
|
||||
(as-> (l/key :profile) $
|
||||
(l/focus-atom $ s/state)))
|
||||
(l/derive $ s/state)))
|
||||
|
||||
(defn user-render
|
||||
[own]
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
[uxbox.main.data.workspace :as dw]
|
||||
[uxbox.main.data.shapes :as uds]
|
||||
[uxbox.common.geom.point :as gpt]
|
||||
[uxbox.util.lens :as ul]
|
||||
[goog.events :as events])
|
||||
(:import goog.events.EventType))
|
||||
|
||||
|
@ -22,49 +21,49 @@
|
|||
|
||||
(def ^:const workspace-l
|
||||
(as-> (l/in [:workspace]) $
|
||||
(l/focus-atom $ st/state)))
|
||||
(l/derive $ st/state)))
|
||||
|
||||
(def ^:const project-l
|
||||
(letfn [(getter [state]
|
||||
(let [project (get-in state [:workspace :project])]
|
||||
(get-in state [:projects-by-id project])))]
|
||||
(as-> (l/getter getter) $
|
||||
(l/focus-atom $ st/state))))
|
||||
(as-> (l/lens getter) $
|
||||
(l/derive $ st/state))))
|
||||
|
||||
(def ^:const page-l
|
||||
(letfn [(getter [state]
|
||||
(let [page (get-in state [:workspace :page])]
|
||||
(get-in state [:pages-by-id page])))]
|
||||
(as-> (ul/getter getter) $
|
||||
(l/focus-atom $ st/state))))
|
||||
(as-> (l/lens getter) $
|
||||
(l/derive $ st/state))))
|
||||
|
||||
(def ^:const selected-shapes-l
|
||||
(as-> (l/in [:selected]) $
|
||||
(l/focus-atom $ workspace-l)))
|
||||
(l/derive $ workspace-l)))
|
||||
|
||||
(def ^:const toolboxes-l
|
||||
(as-> (l/in [:toolboxes]) $
|
||||
(l/focus-atom $ workspace-l)))
|
||||
(l/derive $ workspace-l)))
|
||||
|
||||
(def ^:const flags-l
|
||||
(as-> (l/in [:flags]) $
|
||||
(l/focus-atom $ workspace-l)))
|
||||
(l/derive $ workspace-l)))
|
||||
|
||||
(def ^:const shapes-by-id-l
|
||||
(as-> (l/key :shapes-by-id) $
|
||||
(l/focus-atom $ st/state)))
|
||||
(l/derive $ st/state)))
|
||||
|
||||
(def ^:const zoom-l
|
||||
(-> (l/in [:workspace :zoom])
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
(def ^:const alignment-l
|
||||
(letfn [(getter [flags]
|
||||
(and (contains? flags :grid/indexed)
|
||||
(contains? flags :grid/alignment)
|
||||
(contains? flags :grid)))]
|
||||
(-> (l/getter getter)
|
||||
(l/focus-atom flags-l))))
|
||||
(-> (l/lens getter)
|
||||
(l/derive flags-l))))
|
||||
|
||||
;; --- Scroll Stream
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
(def ^:const ^:private clipboard-l
|
||||
(-> (l/key :clipboard)
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
;; --- Clipboard Dialog Component
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
(def ^:private collections-by-id-l
|
||||
(-> (comp (l/in [:colors-by-id])
|
||||
(ul/merge library/+color-collections-by-id+))
|
||||
(l/focus-atom st/state)))
|
||||
(l/derive st/state)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Component
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
(defn- focus-shape
|
||||
[id]
|
||||
(as-> (l/in [:shapes-by-id id]) $
|
||||
(l/focus-atom $ st/state)))
|
||||
(l/derive $ st/state)))
|
||||
|
||||
(defn- colorpicker-render
|
||||
[own {:keys [x y shape attr] :as opts}]
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
(letfn [(getter [state]
|
||||
(let [selected (get-in state [:workspace :selected])]
|
||||
(mapv #(get-in state [:shapes-by-id %]) selected)))]
|
||||
(-> (l/getter getter)
|
||||
(l/focus-atom st/state))))
|
||||
(-> (l/lens getter)
|
||||
(l/derive st/state))))
|
||||
|
||||
;; --- Selection Handlers (Component)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
rerender the whole toolbox on each workspace
|
||||
change."
|
||||
(as-> (l/in [:workspace :drawing]) $
|
||||
(l/focus-atom $ st/state)))
|
||||
(l/derive $ st/state)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Draw Tools
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
(def ^:const history-l
|
||||
(as-> (l/in [:workspace :history]) $
|
||||
(l/focus-atom $ st/state)))
|
||||
(l/derive $ st/state)))
|
||||
|
||||
;; --- History Item (Component)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
rerender the whole toolbox on each workspace
|
||||
change."
|
||||
(as-> (l/in [:workspace :drawing]) $
|
||||
(l/focus-atom $ st/state)))
|
||||
(l/derive $ st/state)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Icons
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
(defn- focus-page
|
||||
[pageid]
|
||||
(as-> (l/in [:pages-by-id pageid]) $
|
||||
(l/focus-atom $ st/state)))
|
||||
(l/derive $ st/state)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Components
|
||||
|
|
|
@ -106,8 +106,8 @@
|
|||
(let [selected (get-in state [:workspace :selected])]
|
||||
(when (= 1 (count selected))
|
||||
(get-in state [:shapes-by-id (first selected)]))))]
|
||||
(as-> (l/getter getter) $
|
||||
(l/focus-atom $ st/state))))
|
||||
(-> (l/lens getter)
|
||||
(l/derive st/state))))
|
||||
|
||||
(defn options-toolbox-render
|
||||
[own]
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
[uxbox.main.ui.icons :as i]
|
||||
[uxbox.common.ui.mixins :as mx]
|
||||
[uxbox.main.ui.lightbox :as lbx]
|
||||
[uxbox.util.lens :as ul]
|
||||
[uxbox.util.data :refer (read-string parse-int)]
|
||||
[uxbox.util.dom :as dom]))
|
||||
|
||||
|
@ -35,8 +34,8 @@
|
|||
(letfn [(getter [state]
|
||||
(let [project (get-in state [:workspace :project])]
|
||||
(stpr/project-pages state project)))]
|
||||
(as-> (ul/getter getter) $
|
||||
(l/focus-atom $ st/state))))
|
||||
(as-> (l/lens getter) $
|
||||
(l/derive $ st/state))))
|
||||
|
||||
;; --- Component
|
||||
|
||||
|
|
|
@ -6,13 +6,9 @@
|
|||
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
||||
|
||||
(ns uxbox.util.lens
|
||||
(:refer-clojure :exclude [derive merge])
|
||||
(:refer-clojure :exclude [merge])
|
||||
(:require [lentes.core :as l]))
|
||||
|
||||
(defn getter
|
||||
[f]
|
||||
(l/lens f #(throw (ex-info "Not implemented" {}))))
|
||||
|
||||
(defn merge
|
||||
[data]
|
||||
(l/lens
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
(def auth-l
|
||||
(-> (l/key :auth)
|
||||
(l/focus-atom state)))
|
||||
(l/derive state)))
|
||||
|
||||
(defn initial-state
|
||||
[]
|
||||
|
|
Loading…
Add table
Reference in a new issue