Back

empty? (clj)

(source)

function

(empty? s)
Checks if a string is empty.

Examples

penpot/penpot
(ns app.main.ui.dashboard.files
  (:require-macros [app.main.style :as stl])
  (:require
   [app.main.data.dashboard :as dd]
   [app.main.data.events :as ev]
   [app.main.refs :as refs]
   [app.main.store :as st]
   [app.main.ui.dashboard.grid :refer [grid]]
   [app.main.ui.dashboard.inline-edition :refer [inline-edition]]
   [app.main.ui.dashboard.pin-button :refer [pin-button*]]
   [app.main.ui.dashboard.project-menu :refer [project-menu]]
   [app.main.ui.hooks :as hooks]
   [app.main.ui.icons :as i]
   [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]
   [rumext.v2 :as mf]))

       (if (:edition @local)
         [:& inline-edition
          {:content (:name project)
           :on-end (fn [name]
                     (let [name (str/trim name)]
                       (when-not (str/empty? name)
                         (st/emit! (-> (dd/rename-project (assoc project :name name))
                                       (with-meta {::ev/origin "project"}))))
                       (swap! local assoc :edition false)))}]
         [:div {:class (stl/css :dashboard-title)}
          [:h1 {:on-double-click on-edit
                :data-test "project-title"
                :id (:id project)}
           (:name project)]]))
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]))

        show-components?   (and (or (= filters-section "all")
                                    (= filters-section "components"))
                                (or (pos? (count components))
                                    (str/empty? filters-term)))
        show-graphics?     (and (or (= filters-section "all")
                                    (= filters-section "graphics"))
                                (or (pos? (count media))
                                    (and (str/empty? filters-term)
                                         (not components-v2))))
        show-colors?       (and (or (= filters-section "all")
                                    (= filters-section "colors"))
                                (or (> (count colors) 0)
                                    (str/empty? filters-term)))
        show-typography?   (and (or (= filters-section "all")
                                    (= filters-section "typographies"))
                                (or (pos? (count typographies))
                                    (str/empty? filters-term)))

        has-term?                (not ^boolean (str/empty? filters-term))
        force-open-components?   (when ^boolean has-term? (> 60 (count components)))
        force-open-colors?       (when ^boolean has-term? (> 60 (count colors)))
        force-open-graphics?     (when ^boolean has-term? (> 60 (count media)))
        force-open-typographies? (when ^boolean has-term? (> 60 (count typographies)))
penpot/penpot
(ns app.main.ui.workspace.sidebar.options.menus.stroke
  (:require-macros [app.main.style :as stl])
  (:require
   [app.common.colors :as clr]
   [app.common.data :as d]
   [app.common.data.macros :as dm]
   [app.main.data.workspace.colors :as dc]
   [app.main.store :as st]
   [app.main.ui.components.title-bar :refer [title-bar]]
   [app.main.ui.hooks :as h]
   [app.main.ui.icons :as i]
   [app.main.ui.workspace.sidebar.options.rows.stroke-row :refer [stroke-row]]
   [app.util.dom :as dom]
   [app.util.i18n :as i18n :refer [tr]]
   [cuerdas.core :as str]
   [rumext.v2 :as mf]))

        on-stroke-alignment-change
        (fn [index value]
          (when-not (str/empty? value)
            (st/emit! (dc/change-stroke ids {:stroke-alignment value} index))))

        on-stroke-width-change
        (fn [index value]
          (when-not (str/empty? value)
            (st/emit! (dc/change-stroke ids {:stroke-width value} index))))
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]))

        on-drop
        (mf/use-fn
         (mf/deps dragging* prefix selected-paths selected-full)
         (fn [event]
           (cmm/on-drop-asset-group event dragging* prefix selected-paths selected-full dwl/rename-media)))]
    [:div {:class (stl/css :graphics-group)
           :on-drag-enter on-drag-enter
           :on-drag-leave on-drag-leave
           :on-drag-over dom/prevent-default
           :on-drop on-drop}
     [:& grp/asset-group-title
      {:file-id file-id
       :section :graphics
       :path prefix
       :group-open? group-open?
       :on-rename on-rename-group
       :on-ungroup on-ungroup}]
     (when group-open?
       [:*
        (let [objects (get groups "" [])]
          [:div {:class-name (stl/css-case
                              :asset-grid listing-thumbs?
                              :asset-enum (not listing-thumbs?)
                              :drop-space (and
                                           (empty? objects)
                                           (some? groups)
                                           (not dragging?)))
                 :on-drag-enter on-drag-enter
                 :on-drag-leave on-drag-leave
                 :on-drag-over dom/prevent-default
                 :on-drop on-drop}

           (when (and (empty? objects)
                      (some? groups))
             [:div {:class (stl/css :drop-space)}])

           (for [object objects]
             [:& graphics-item
              {:key (dm/str "object-" (:id object))
               :file-id file-id
               :object object
               :renaming renaming
               :listing-thumbs? listing-thumbs?
               :selected-objects selected-objects
               :on-asset-click on-asset-click
               :on-context-menu on-context-menu
               :on-drag-start on-drag-start
               :do-rename do-rename
               :cancel-rename cancel-rename
               :selected-full selected-full
               :selected-paths selected-paths}])])
        (for [[path-item content] groups]
          (when-not (empty? path-item)
            [:& graphics-group {:file-id file-id
                                :key path-item
                                :prefix (cfh/merge-path-item prefix path-item)
                                :groups content
                                :open-groups open-groups
                                :force-open? force-open?
                                :renaming renaming
                                :listing-thumbs? listing-thumbs?
                                :selected-objects selected-objects
                                :on-asset-click on-asset-click
                                :on-drag-start on-drag-start
                                :do-rename do-rename
                                :cancel-rename cancel-rename
                                :on-rename-group on-rename-group
                                :on-ungroup on-ungroup
                                :on-context-menu on-context-menu
                                :selected-full selected-full
                                :selected-paths selected-paths}]))])]))
penpot/penpot
(ns app.main.ui.workspace.sidebar.options.menus.constraints
  (:require-macros [app.main.style :as stl])
  (:require
   [app.common.data :as d]
   [app.common.geom.rect :as grc]
   [app.common.geom.shapes :as gsh]
   [app.common.uuid :as uuid]
   [app.main.data.workspace.changes :as dch]
   [app.main.refs :as refs]
   [app.main.store :as st]
   [app.main.ui.components.select :refer [select]]
   [app.main.ui.components.title-bar :refer [title-bar]]
   [app.main.ui.icons :as i]
   [app.util.dom :as dom]
   [app.util.i18n :as i18n :refer [tr]]
   [cuerdas.core :as str]
   [rumext.v2 :as mf]))

        on-constraint-h-select-changed
        (mf/use-fn
         (mf/deps ids)
         (fn [value]
           (when-not (str/empty? value)
             (st/emit! (dch/update-shapes
                        ids
                        #(assoc % :constraints-h (keyword value)))))))

        on-constraint-v-select-changed
        (mf/use-fn
         (mf/deps ids)
         (fn [value]
           (when-not (str/empty? value)
             (st/emit! (dch/update-shapes
                        ids
                        #(assoc % :constraints-v (keyword value)))))))