瀏覽代碼

feat: support disabled button state

Konstantinos Kaloutas 3 年之前
父節點
當前提交
cce937b9d7
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      src/main/frontend/ui.cljs

+ 4 - 2
src/main/frontend/ui.cljs

@@ -950,17 +950,19 @@
               (f (merge {:size 18} (r/map-keys->camel-case opts)))])))))))
 
 (defn button
-  [text & {:keys [background href class intent on-click small? large? title icon icon-props]
+  [text & {:keys [background href class intent on-click small? large? title icon icon-props disabled?]
            :or   {small? false large? false}
            :as   option}]
   (let [klass (when-not intent ".bg-indigo-600.hover:bg-indigo-700.focus:border-indigo-700.active:bg-indigo-700.text-center")
         klass (if background (string/replace klass "indigo" background) klass)
         klass (if small? (str klass ".px-2.py-1") klass)
-        klass (if large? (str klass ".text-base") klass)]
+        klass (if large? (str klass ".text-base") klass)
+        klass (if disabled? (str klass "disabled:opacity-75") klass)]
     [:button.ui__button
      (merge
       {:type  "button"
        :title title
+       :disabled disabled?
        :class (str (util/hiccup->class klass) " " class)}
       (dissoc option :background :class :small? :large?)
       (when href