Back

blank? (clj)

(source)

function

(blank? s)
Checks if is a nil, empty string or contains only whitespace.

Examples

penpot/penpot
(ns app.main.ui.workspace.sidebar.options.menus.component
  (:require-macros [app.main.style :as stl])
  (:require
   [app.common.files.helpers :as cfh]
   [app.common.types.component :as ctk]
   [app.common.types.file :as ctf]
   [app.common.uuid :as uuid]
   [app.main.data.modal :as modal]
   [app.main.data.workspace :as dw]
   [app.main.data.workspace.libraries :as dwl]
   [app.main.data.workspace.specialized-panel :as dwsp]
   [app.main.refs :as refs]
   [app.main.store :as st]
   [app.main.ui.components.dropdown :refer [dropdown]]
   [app.main.ui.components.radio-buttons :refer [radio-button radio-buttons]]
   [app.main.ui.components.search-bar :refer [search-bar]]
   [app.main.ui.components.select :refer [select]]
   [app.main.ui.components.title-bar :refer [title-bar]]
   [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.util.dom :as dom]
   [app.util.i18n :as i18n :refer [tr]]
   [cuerdas.core :as str]
   [rumext.v2 :as mf]))

(mf/defc component-annotation
  [{:keys [id shape component] :as props}]
  (let [main-instance?        (:main-instance shape)
        component-id          (:component-id shape)
        annotation            (:annotation component)
        editing?              (mf/use-state false)
        invalid-text?         (mf/use-state (or (nil? annotation) (str/blank? annotation)))
        size                  (mf/use-state (count annotation))
        textarea-ref          (mf/use-ref)

        ;; hack to create an autogrowing textarea
        ;; based on https://css-tricks.com/the-cleanest-trick-for-autogrowing-textareas/
        autogrow              #(let [textarea (mf/ref-val textarea-ref)
                                     text (when textarea (.-value textarea))]
                                 (reset! invalid-text? (str/blank? text))
                                 (when textarea
                                   (reset! size (count text))
                                   (aset (.-dataset (.-parentNode textarea)) "replicatedValue" text)))
        initialize            #(let [textarea (mf/ref-val textarea-ref)]
                                 (when textarea
                                   (aset textarea "value" annotation)
                                   (autogrow)))

        discard               (fn [event]
                                (dom/stop-propagation event)
                                (let [textarea (mf/ref-val textarea-ref)]
                                  (aset textarea "value" annotation)
                                  (reset! editing? false)
                                  (st/emit! (dw/set-annotations-id-for-create nil))
                                  (autogrow)))
        save                  (fn [event]
                                (dom/stop-propagation event)
                                (let [textarea (mf/ref-val textarea-ref)
                                      text (.-value textarea)]
                                  (when-not (str/blank? text)
                                    (reset! editing? false)
                                    (st/emit!
                                     (dw/set-annotations-id-for-create nil)
                                     (dw/update-component-annotation component-id text)))))
        workspace-annotations (mf/deref refs/workspace-annotations)
        annotations-expanded? (:expanded? workspace-annotations)
        creating?             (= id (:id-for-create workspace-annotations))

(mf/defc component-group-item
  [{:keys [item on-enter-group] :as props}]
  (let [group-name (:name item)
        path (cfh/butlast-path group-name)
        on-group-click #(on-enter-group group-name)]
    [:div {:class (stl/css :component-group)
           :key (uuid/next) :on-click on-group-click
           :title group-name}
     [:div
      (when-not (str/blank? path)
        [:span {:class (stl/css :component-group-path)}
         (str "\u00A0/\u00A0" path)])
      [:span {:class (stl/css :component-group-name)}
       (cfh/last-path group-name)]]
     [:span i/arrow-refactor]]))

        filters             (deref filters*)
        is-search?          (not (str/blank? (:term filters)))
        current-library-id    (if (contains? libraries (:file-id filters))
                                (:file-id filters)
                                current-file-id)
47degrees/org
(ns org.config
  #?(:clj
     (:require [cuerdas.core :as str]
               [clojure.spec.alpha :as s])
     :cljs
     (:require [cuerdas.core :as str]
               [cljs.spec.alpha :as s])))

(s/def :org/token-name string?)
(s/def :org/token (s/and string? (complement str/blank?)))
(s/def :org/analytics string?)