mirror of
https://github.com/penpot/penpot.git
synced 2026-04-30 13:49:06 +00:00
🎉 Set default button behaviour as type button instead of submit (#7741)
This commit is contained in:
parent
839bb470df
commit
2233f34a15
@ -15,6 +15,7 @@
|
||||
(def ^:private schema:button
|
||||
[:map
|
||||
[:class {:optional true} :string]
|
||||
[:type {:optional true} [:maybe [:enum "button" "submit" "reset"]]]
|
||||
[:icon {:optional true}
|
||||
[:and :string [:fn #(contains? icon-list %)]]]
|
||||
[:on-ref {:optional true} fn?]
|
||||
@ -24,7 +25,7 @@
|
||||
|
||||
(mf/defc button*
|
||||
{::mf/schema schema:button}
|
||||
[{:keys [variant icon children class on-ref to] :rest props}]
|
||||
[{:keys [variant icon children class on-ref to type] :rest props}]
|
||||
(let [variant (d/nilv variant "primary")
|
||||
element (if to "a" "button")
|
||||
internal-class (stl/css-case :button true
|
||||
@ -35,6 +36,7 @@
|
||||
:button-destructive (= variant "destructive"))
|
||||
props (mf/spread-props props {:class [class internal-class]
|
||||
:href to
|
||||
:type (d/nilv type "button")
|
||||
:ref (fn [node]
|
||||
(when on-ref
|
||||
(on-ref node)))})]
|
||||
|
||||
@ -28,6 +28,7 @@ export default {
|
||||
children: "Lorem ipsum",
|
||||
disabled: false,
|
||||
variant: undefined,
|
||||
type: "button",
|
||||
},
|
||||
parameters: {
|
||||
controls: { exclude: ["children"] },
|
||||
|
||||
@ -48,10 +48,12 @@
|
||||
|
||||
(when cancel-label
|
||||
[:> button* {:variant "secondary"
|
||||
:type "button"
|
||||
:on-click on-cancel}
|
||||
cancel-label])
|
||||
|
||||
(when accept-label
|
||||
[:> button* {:variant (if (= variant "default") "primary" "destructive")
|
||||
:type "button"
|
||||
:on-click on-accept}
|
||||
accept-label])]))
|
||||
|
||||
@ -70,6 +70,7 @@
|
||||
[:img {:class (stl/css :resolved-image) :src (cf/resolve-file-media image)}]]
|
||||
|
||||
[:> button* {:class (stl/css :download-button)
|
||||
:type "button"
|
||||
:variant "secondary"
|
||||
:target "_blank"
|
||||
:download name
|
||||
|
||||
@ -120,6 +120,7 @@
|
||||
:alt (tr "inspect.attributes.image.preview")}]]
|
||||
[:> button* {:variant "secondary"
|
||||
:to color-image-url
|
||||
:type "button"
|
||||
:target "_blank"
|
||||
:download color-image-name}
|
||||
(tr "inspect.attributes.image.download")]])]))
|
||||
|
||||
@ -79,6 +79,7 @@
|
||||
|
||||
[:> button* {:class (stl/css :open-button)
|
||||
:variant "secondary"
|
||||
:type "button"
|
||||
:on-click handle-open-click
|
||||
:title (when-not can-open? (tr "workspace.plugins.error.need-editor"))
|
||||
:disabled (not can-open?)} (tr "workspace.plugins.button-open")]
|
||||
|
||||
@ -1089,6 +1089,7 @@
|
||||
|
||||
(when (and multi all-main? (not any-variant?))
|
||||
[:> button* {:variant "secondary"
|
||||
:type "button"
|
||||
:class (stl/css :component-combine)
|
||||
:on-click on-combine-as-variants}
|
||||
(tr "workspace.shape.menu.combine-as-variants")])
|
||||
|
||||
@ -96,6 +96,7 @@
|
||||
|
||||
[:div {:class (stl/css :button-row)}
|
||||
[:> button* {:variant "primary"
|
||||
:type "button"
|
||||
:class (stl/css :modal-accept-btn)
|
||||
:on-click on-close}
|
||||
(tr "ds.confirm-ok")]]]]))
|
||||
|
||||
@ -100,9 +100,11 @@
|
||||
|
||||
[:div {:class (stl/css :settings-modal-actions)}
|
||||
[:> button* {:on-click modal/hide!
|
||||
:type "button"
|
||||
:variant "secondary"}
|
||||
(tr "labels.cancel")]
|
||||
[:> button* {:on-click on-set-font
|
||||
:type "button"
|
||||
:disabled (not is-valid)
|
||||
:variant "primary"}
|
||||
(tr "labels.save")]]]]]]))
|
||||
|
||||
@ -116,6 +116,7 @@
|
||||
|
||||
[:div {:class (stl/css :import-export-button-wrapper)}
|
||||
[:> button* {:on-click open-menu
|
||||
:type "button"
|
||||
:icon i/import-export
|
||||
:variant "secondary"}
|
||||
(tr "workspace.tokens.tools")]
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
[:div {:class (stl/css :theme-selector-wrapper)}
|
||||
[:& theme-selector]
|
||||
[:> button* {:variant "secondary"
|
||||
:type "button"
|
||||
:class (stl/css :edit-theme-button)
|
||||
:on-click open-modal}
|
||||
(tr "labels.edit")]]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user