<commit_before>(ns ez-form.decorate
  (:require [clojure.string :as str]
            [clojure.zip :as zip]
            [ez-form.common :refer [get-field]]
            [ez-form.zipper :refer [zipper]]))


(def ^:dynamic *materials* {:?wrapper {:class "error"}
                            :?text {:css {:class "text"}
                                    :wrapper :div}
                            :?help {:css {:class "help"}
                                    :wrapper :div}
                            :?error {:css {:class "error"}
                                     :wrapper :div}})

(defn add-decor [decor field]
  (let [-name (name (or (:id field) (:name field)))]
    (keyword (str "?" -name "." (name decor)))))

(defn add-error-decor [field error]
  (if error
    (list (add-decor :error field) error)))

(defn add-help-decor [field]
  (if-let [help (:help field)]
    (list (add-decor :help field) help)))

(defn add-text-decor [field]
  (if-let [text (:text field)]
    (list (add-decor :text field) text)))

(defn get-material
  "Get the material to decorate with for the node"
  [form node base-material]
  (cond
    ;; from static form options
    (contains? (get-in form [:options :decor]) node)
    (get-in form [:options :decor node])

    (contains? (get-in form [:options :decor]) base-material)
    (get-in form [:options :decor base-material])<commit_msg>change error CSS class to error-message<commit_after>(ns ez-form.decorate
  (:require [clojure.string :as str]
            [clojure.zip :as zip]
            [ez-form.common :refer [get-field]]
            [ez-form.zipper :refer [zipper]]))


(def ^:dynamic *materials* {:?wrapper {:class "error"}
                            :?text {:css {:class "text"}
                                    :wrapper :div}
                            :?help {:css {:class "help"}
                                    :wrapper :div}
                            :?error {:css {:class "error-message"}
                                     :wrapper :div}})

(defn add-decor [decor field]
  (let [-name (name (or (:id field) (:name field)))]
    (keyword (str "?" -name "." (name decor)))))

(defn add-error-decor [field error]
  (if error
    (list (add-decor :error field) error)))

(defn add-help-decor [field]
  (if-let [help (:help field)]
    (list (add-decor :help field) help)))

(defn add-text-decor [field]
  (if-let [text (:text field)]
    (list (add-decor :text field) text)))

(defn get-material
  "Get the material to decorate with for the node"
  [form node base-material]
  (cond
    ;; from static form options
    (contains? (get-in form [:options :decor]) node)
    (get-in form [:options :decor node])

    (contains? (get-in form [:options :decor]) base-material)
    (get-in form [:options :decor base-material])
{'fraction_non_alphanumeric': 0.1563845050215208, 'fraction_numerical': 0.0, 'mean_word_length': 2.0381263616557734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5183500', 'n_tokens_mistral': 896, 'n_tokens_neox': 857, 'n_words': 268}