Back

nilv (clj)

(source)

macro

(nilv v)
Mark a expression string safe, if value is nil or undefined, the "" is returned.

Examples

penpot/penpot
(ns app.main.ui.workspace.sidebar.layer-name
  (:require-macros [app.main.style :as stl])
  (:require
   [app.common.data :as d]
   [app.common.data.macros :as dm]
   [app.main.data.workspace :as dw]
   [app.main.store :as st]
   [app.util.debug :as dbg]
   [app.util.dom :as dom]
   [app.util.keyboard :as kbd]
   [cuerdas.core :as str]
   [okulary.core :as l]
   [rumext.v2 :as mf]))

        local-ref        (mf/use-ref)
        ref              (d/nilv external-ref local-ref)

    (if ^boolean edition?
      [:input
       {:class (stl/css :element-name
                        :element-name-input)
        :style {"--depth" depth "--parent-size" parent-size}
        :type "text"
        :ref ref
        :on-blur accept-edit
        :on-key-down on-key-down
        :auto-focus true
        :default-value (d/nilv shape-name "")}]
      [:*
       [:span
        {:class (stl/css-case
                 :element-name true
                 :left-ellipsis has-path?
                 :selected selected?
                 :hidden hidden?
                 :type-comp type-comp
                 :type-frame type-frame)
         :style {"--depth" depth "--parent-size" parent-size}
         :ref ref
         :on-double-click start-edit}
        (d/nilv shape-name "")]
       (when (and (dbg/enabled? :show-touched) ^boolean shape-touched?)
         [:span {:class (stl/css :element-name-touched)} "*"])])))
penpot/penpot
(ns app.main.ui.components.numeric-input
  (:require
   [app.common.data :as d]
   [app.common.schema :as sm]
   [app.main.ui.formats :as fmt]
   [app.main.ui.hooks :as h]
   [app.util.dom :as dom]
   [app.util.globals :as globals]
   [app.util.keyboard :as kbd]
   [app.util.object :as obj]
   [app.util.simple-math :as smt]
   [cljs.core :as c]
   [cuerdas.core :as str]
   [goog.events :as events]
   [rumext.v2 :as mf]))

        title       (unchecked-get props "title")
        default     (unchecked-get props "default")
        nillable?   (unchecked-get props "nillable")
        class       (d/nilv (unchecked-get props "className") "input-text")

        select-on-focus? (d/nilv (unchecked-get props "selectOnFocus") true)
penpot/penpot
(ns app.main.ui.workspace.sidebar.assets.colors
  (:require-macros [app.main.style :as stl])
  (:require
   [app.common.data :as d]
   [app.common.data.macros :as dm]
   [app.common.files.helpers :as cfh]
   [app.main.data.events :as ev]
   [app.main.data.modal :as modal]
   [app.main.data.workspace :as dw]
   [app.main.data.workspace.colors :as dc]
   [app.main.data.workspace.libraries :as dwl]
   [app.main.data.workspace.undo :as dwu]
   [app.main.refs :as refs]
   [app.main.store :as st]
   [app.main.ui.components.color-bullet-new :as cb]
   [app.main.ui.context :as ctx]
   [app.main.ui.icons :as i]
   [app.main.ui.workspace.sidebar.assets.common :as cmm]
   [app.main.ui.workspace.sidebar.assets.groups :as grp]
   [app.util.color :as uc]
   [app.util.dom :as dom]
   [app.util.i18n :as i18n :refer [tr]]
   [app.util.keyboard :as kbd]
   [cuerdas.core :as str]
   [okulary.core :as l]
   [potok.v2.core :as ptk]
   [rumext.v2 :as mf]))

        selected-paths (mf/with-memo [selected-full]
                         (into #{}
                               (comp (map :path) (d/nilv ""))
                               selected-full))
penpot/penpot
(ns app.main.ui.workspace.sidebar.assets.graphics
  (:require-macros [app.main.style :as stl])
  (:require
   [app.common.data :as d]
   [app.common.data.macros :as dm]
   [app.common.files.helpers :as cfh]
   [app.common.media :as cm]
   [app.config :as cf]
   [app.main.data.events :as ev]
   [app.main.data.modal :as modal]
   [app.main.data.workspace :as dw]
   [app.main.data.workspace.libraries :as dwl]
   [app.main.data.workspace.media :as dwm]
   [app.main.data.workspace.undo :as dwu]
   [app.main.store :as st]
   [app.main.ui.components.editable-label :refer [editable-label]]
   [app.main.ui.components.file-uploader :refer [file-uploader]]
   [app.main.ui.context :as ctx]
   [app.main.ui.hooks :as h]
   [app.main.ui.icons :as i]
   [app.main.ui.workspace.sidebar.assets.common :as cmm]
   [app.main.ui.workspace.sidebar.assets.groups :as grp]
   [app.util.dom :as dom]
   [app.util.dom.dnd :as dnd]
   [app.util.i18n :as i18n :refer [tr]]
   [cuerdas.core :as str]
   [okulary.core :as l]
   [potok.v2.core :as ptk]
   [rumext.v2 :as mf]))

        selected-paths
        (mf/with-memo [selected-full]
          (into #{}
                (comp (map :path) (d/nilv ""))
                selected-full))
penpot/penpot
(ns app.main.ui.workspace.sidebar.assets.file-library
  (:require-macros [app.main.style :as stl])
  (:require
   [app.common.data :as d]
   [app.common.data.macros :as dm]
   [app.main.data.workspace :as dw]
   [app.main.data.workspace.libraries :as dwl]
   [app.main.data.workspace.undo :as dwu]
   [app.main.refs :as refs]
   [app.main.store :as st]
   [app.main.ui.components.title-bar :refer [title-bar]]
   [app.main.ui.context :as ctx]
   [app.main.ui.icons :as i]
   [app.main.ui.workspace.libraries :refer [create-file-library-ref]]
   [app.main.ui.workspace.sidebar.assets.colors :refer [colors-section]]
   [app.main.ui.workspace.sidebar.assets.common :as cmm]
   [app.main.ui.workspace.sidebar.assets.components :refer [components-section]]
   [app.main.ui.workspace.sidebar.assets.graphics :refer [graphics-section]]
   [app.main.ui.workspace.sidebar.assets.typographies :refer [typographies-section]]
   [app.util.dom :as dom]
   [app.util.i18n :as i18n :refer [tr]]
   [app.util.keyboard :as kbd]
   [app.util.router :as rt]
   [cuerdas.core :as str]
   [okulary.core :as l]
   [rumext.v2 :as mf]))

        open-status-ref (mf/with-memo [file-id]
                          (-> (l/key file-id)
                              (l/derived lens:open-status)))
        open-status      (mf/deref open-status-ref)
        open?            (d/nilv (:library open-status) default-open?)