0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 00:40:30 -05:00

Merge branch 'main' into develop

This commit is contained in:
Andrés Moya 2021-11-02 11:09:11 +01:00
commit bce0e9194c
3 changed files with 38 additions and 14 deletions

View file

@ -207,6 +207,9 @@
border-color: $color-gray-40;
}
&.error {
border-color: $color-danger;
}
}
.input-select {

View file

@ -199,8 +199,20 @@
change-url
(fn [event]
(let [value (-> event dom/get-target dom/get-value)]
(update-interaction index #(cti/set-url % value))))
(let [target (dom/get-target event)
value (dom/get-value target)
has-prefix? (or (str/starts-with? value "http://")
(str/starts-with? value "https://"))
value (if has-prefix?
value
(str "http://" value))]
(when-not has-prefix?
(dom/set-value! target value))
(if (dom/valid? target)
(do
(dom/remove-class! target "error")
(update-interaction index #(cti/set-url % value)))
(dom/add-class! target "error"))))
change-overlay-pos-type
(fn [event]
@ -287,7 +299,9 @@
(when (cti/has-url interaction)
[:div.interactions-element
[:span.element-set-subtitle.wide (tr "workspace.options.interaction-url")]
[:input.input-text {:default-value (str (:url interaction))
[:input.input-text {:type "url"
:placeholder "http://example.com"
:default-value (str (:url interaction))
:on-blur change-url}]])
(when (cti/has-overlay-opts interaction)

View file

@ -28,17 +28,6 @@
[e]
(.-target e))
(defn classnames
[& params]
(assert (even? (count params)))
(str/join " " (reduce (fn [acc [k v]]
(if (true? (boolean v))
(conj acc (name k))
acc))
[]
(partition 2 params))))
;; --- New methods
(defn set-html-title
@ -294,10 +283,28 @@
(defn get-root []
(query globals/document "#app"))
(defn classnames
[& params]
(assert (even? (count params)))
(str/join " " (reduce (fn [acc [k v]]
(if (true? (boolean v))
(conj acc (name k))
acc))
[]
(partition 2 params))))
(defn ^boolean class? [node class-name]
(let [class-list (.-classList ^js node)]
(.contains ^js class-list class-name)))
(defn add-class! [node class-name]
(let [class-list (.-classList ^js node)]
(.add ^js class-list class-name)))
(defn remove-class! [node class-name]
(let [class-list (.-classList ^js node)]
(.remove ^js class-list class-name)))
(defn child? [node1 node2]
(.contains ^js node2 ^js node1))