fix: react key warnings

This commit is contained in:
Tienson Qin
2024-12-30 09:37:17 +08:00
parent 659d64c3ae
commit dd294992a7
2 changed files with 20 additions and 16 deletions

View File

@@ -1,8 +1,8 @@
(ns logseq.shui.shortcut.v1
(:require [clojure.string :as string]
[goog.userAgent]
[logseq.shui.base.core :as shui.base]
[rum.core :as rum]
[goog.userAgent]))
[rum.core :as rum]))
(def mac? goog.userAgent/MAC)
(defn print-shortcut-key [key]
@@ -57,15 +57,15 @@
interactive? (true? interactive?)]
(shui.base/button {:variant (if interactive? :default :text)
:class (str "bg-gray-03 text-gray-10 px-1.5 py-0 leading-4 h-5 rounded font-normal "
(if interactive?
"hover:bg-gray-04 active:bg-gray-03 hover:text-gray-12"
"bg-transparent cursor-default active:bg-gray-03 hover:text-gray-11 opacity-80"))
(if interactive?
"hover:bg-gray-04 active:bg-gray-03 hover:text-gray-12"
"bg-transparent cursor-default active:bg-gray-03 hover:text-gray-11 opacity-80"))
:size size}
(for [[index tile] (map-indexed vector tiles)]
[:<>
(when (< 0 index)
[:span.ui__button__tile-separator])
[:span.ui__button__tile tile]]))))
(for [[index tile] (map-indexed vector tiles)]
[:<>
(when (< 0 index)
[:span.ui__button__tile-separator])
[:span.ui__button__tile tile]]))))
(rum/defc root
[shortcut & {:keys [size theme interactive?]
@@ -80,8 +80,10 @@
(for [[index binding] (map-indexed vector shortcuts)]
[:<>
(when (< 0 index)
[:div.text-gray-11.text-sm "|"])
[:div.text-gray-11.text-sm {:key "sep"} "|"])
(if (coll? (first binding)) ; + included
(for [ks binding]
(part ks size opts))
(for [[idx ks] (map-indexed vector binding)]
(rum/with-key
(part ks size opts)
(str "part-" idx)))
(part binding size opts))]))))