mirror of
https://github.com/penpot/penpot.git
synced 2025-06-18 07:51:38 +02:00
♻️ Refactor button-link component
This commit is contained in:
parent
1e9c809b84
commit
e60be6f262
2 changed files with 33 additions and 27 deletions
|
@ -188,30 +188,35 @@
|
|||
|
||||
(mf/defc login-buttons
|
||||
[{:keys [params] :as props}]
|
||||
[:div.auth-buttons
|
||||
(when (contains? cf/flags :login-with-google)
|
||||
[:& bl/button-link {:action #(login-with-oidc % :google params)
|
||||
:icon i/brand-google
|
||||
:name (tr "auth.login-with-google-submit")
|
||||
:klass "btn-google-auth"}])
|
||||
(let [login-with-google (mf/use-fn (mf/deps params) #(login-with-oidc % :google params))
|
||||
login-with-github (mf/use-fn (mf/deps params) #(login-with-oidc % :github params))
|
||||
login-with-gitlab (mf/use-fn (mf/deps params) #(login-with-oidc % :gitlab params))
|
||||
login-with-oidc (mf/use-fn (mf/deps params) #(login-with-oidc % :oidc params))]
|
||||
|
||||
(when (contains? cf/flags :login-with-github)
|
||||
[:& bl/button-link {:action #(login-with-oidc % :github params)
|
||||
:icon i/brand-github
|
||||
:name (tr "auth.login-with-github-submit")
|
||||
:klass "btn-github-auth"}])
|
||||
[:div.auth-buttons
|
||||
(when (contains? cf/flags :login-with-google)
|
||||
[:& bl/button-link {:on-click login-with-google
|
||||
:icon i/brand-google
|
||||
:label (tr "auth.login-with-google-submit")
|
||||
:class "btn-google-auth"}])
|
||||
|
||||
(when (contains? cf/flags :login-with-gitlab)
|
||||
[:& bl/button-link {:action #(login-with-oidc % :gitlab params)
|
||||
:icon i/brand-gitlab
|
||||
:name (tr "auth.login-with-gitlab-submit")
|
||||
:klass "btn-gitlab-auth"}])
|
||||
(when (contains? cf/flags :login-with-github)
|
||||
[:& bl/button-link {:on-click login-with-github
|
||||
:icon i/brand-github
|
||||
:label (tr "auth.login-with-github-submit")
|
||||
:class "btn-github-auth"}])
|
||||
|
||||
(when (contains? cf/flags :login-with-oidc)
|
||||
[:& bl/button-link {:action #(login-with-oidc % :oidc params)
|
||||
:icon i/brand-openid
|
||||
:name (tr "auth.login-with-oidc-submit")
|
||||
:klass "btn-github-auth"}])])
|
||||
(when (contains? cf/flags :login-with-gitlab)
|
||||
[:& bl/button-link {:on-click login-with-gitlab
|
||||
:icon i/brand-gitlab
|
||||
:label (tr "auth.login-with-gitlab-submit")
|
||||
:class "btn-gitlab-auth"}])
|
||||
|
||||
(when (contains? cf/flags :login-with-oidc)
|
||||
[:& bl/button-link {:on-click login-with-oidc
|
||||
:icon i/brand-openid
|
||||
:label (tr "auth.login-with-oidc-submit")
|
||||
:class "btn-github-auth"}])]))
|
||||
|
||||
(mf/defc login-button-oidc
|
||||
[{:keys [params] :as props}]
|
||||
|
|
|
@ -11,16 +11,17 @@
|
|||
|
||||
(mf/defc button-link
|
||||
{::mf/wrap-props false}
|
||||
[{:keys [action icon name klass]}]
|
||||
[{:keys [on-click icon label class]}]
|
||||
(let [on-key-down (mf/use-fn
|
||||
(mf/deps action)
|
||||
(mf/deps on-click)
|
||||
(fn [event]
|
||||
(when (kbd/enter? event)
|
||||
(action event))))]
|
||||
(when (fn? on-click)
|
||||
(on-click event)))))]
|
||||
[:a.btn-primary.btn-large.button-link
|
||||
{:class klass
|
||||
{:class class
|
||||
:tab-index "0"
|
||||
:on-click action
|
||||
:on-click on-click
|
||||
:on-key-down on-key-down}
|
||||
[:span.logo icon]
|
||||
name]))
|
||||
label]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue