mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
🎉 Add newsletter subscription modal
This commit is contained in:
parent
b7e0619e9a
commit
5e7e055539
14 changed files with 270 additions and 19 deletions
|
@ -304,7 +304,7 @@
|
|||
(let [mdata (meta data)
|
||||
on-success (:on-success mdata identity)
|
||||
on-error (:on-error mdata #(rx/throw %))]
|
||||
(->> (rp/mutation :update-profile data)
|
||||
(->> (rp/mutation :update-profile (dissoc data :props))
|
||||
(rx/catch on-error)
|
||||
(rx/mapcat
|
||||
(fn [_]
|
||||
|
@ -392,7 +392,6 @@
|
|||
(->> (rp/mutation :update-profile-props {:props props})
|
||||
(rx/map (constantly (fetch-profile)))))))))
|
||||
|
||||
|
||||
(defn mark-questions-as-answered
|
||||
[]
|
||||
(ptk/reify ::mark-questions-as-answered
|
||||
|
|
|
@ -59,15 +59,15 @@
|
|||
|
||||
klass (str more-classes " "
|
||||
(dom/classnames
|
||||
:focus @focus?
|
||||
:valid (and touched? (not error))
|
||||
:invalid (and touched? error)
|
||||
:disabled disabled
|
||||
:empty (and is-text? (str/empty? value))
|
||||
:with-icon (not (nil? help-icon'))
|
||||
:custom-input is-text?
|
||||
:input-radio is-radio?
|
||||
:input-checkbox is-checkbox?))
|
||||
:focus @focus?
|
||||
:valid (and touched? (not error))
|
||||
:invalid (and touched? error)
|
||||
:disabled disabled
|
||||
:empty (and is-text? (str/empty? value))
|
||||
:with-icon (not (nil? help-icon'))
|
||||
:custom-input is-text?
|
||||
:input-radio is-radio?
|
||||
:input-checkbox is-checkbox?))
|
||||
|
||||
swap-text-password
|
||||
(fn []
|
||||
|
@ -97,6 +97,7 @@
|
|||
:placeholder label
|
||||
:on-change on-change
|
||||
:type @type')
|
||||
(cond-> (and value is-checkbox?) (assoc :default-checked value))
|
||||
(obj/clj->props))]
|
||||
|
||||
[:div
|
||||
|
@ -210,7 +211,7 @@
|
|||
(let [form (or form (mf/use-ctx form-ctx))]
|
||||
[:input.btn-primary.btn-large
|
||||
{:name "submit"
|
||||
:class (when-not (:valid @form) "btn-disabled")
|
||||
:class (when (or (not (:valid @form)) (true? disabled)) "btn-disabled")
|
||||
:disabled (or (not (:valid @form)) (true? disabled))
|
||||
:on-click on-click
|
||||
:value label
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
[app.main.data.modal :as modal]
|
||||
[app.main.data.users :as du]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.onboarding.newsletter]
|
||||
[app.main.ui.onboarding.questions]
|
||||
[app.main.ui.onboarding.team-choice]
|
||||
[app.main.ui.onboarding.templates]
|
||||
|
@ -154,7 +155,7 @@
|
|||
skip
|
||||
(mf/use-callback
|
||||
(st/emitf (modal/hide)
|
||||
(modal/show {:type :onboarding-choice})
|
||||
(modal/show {:type :onboarding-newsletter-modal})
|
||||
(du/mark-onboarding-as-viewed)))]
|
||||
|
||||
(mf/use-layout-effect
|
||||
|
|
47
frontend/src/app/main/ui/onboarding/newsletter.cljs
Normal file
47
frontend/src/app/main/ui/onboarding/newsletter.cljs
Normal file
|
@ -0,0 +1,47 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) UXBOX Labs SL
|
||||
|
||||
(ns app.main.ui.onboarding.newsletter
|
||||
(:require
|
||||
[app.main.data.messages :as dm]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.users :as du]
|
||||
[app.main.store :as st]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(mf/defc onboarding-newsletter-modal
|
||||
{::mf/register modal/components
|
||||
::mf/register-as :onboarding-newsletter-modal}
|
||||
[]
|
||||
(let [message (tr "onboarding.newsletter.acceptance-message")
|
||||
accept
|
||||
(mf/use-callback
|
||||
(fn []
|
||||
(st/emit! (dm/success message)
|
||||
(modal/show {:type :onboarding-choice})
|
||||
(du/update-profile-props {:newsletter-subscribed true}))))
|
||||
|
||||
decline
|
||||
(mf/use-callback
|
||||
(fn []
|
||||
(st/emit! (modal/show {:type :onboarding-choice})
|
||||
(du/update-profile-props {:newsletter-subscribed false}))))]
|
||||
|
||||
[:div.modal-overlay
|
||||
[:div.modal-container.onboarding.newsletter.animated.fadeInUp
|
||||
[:div.modal-top
|
||||
[:h1.newsletter-title {:data-test "onboarding-newsletter-title"} (tr "onboarding.newsletter.title")]
|
||||
[:p (tr "onboarding.newsletter.desc")]]
|
||||
[:div.modal-bottom
|
||||
[:p (tr "onboarding.newsletter.privacy1") [:a {:target "_blank" :href "https://penpot.app/privacy.html"} (tr "onboarding.newsletter.policy")]]
|
||||
[:p (tr "onboarding.newsletter.privacy2")]]
|
||||
[:div.modal-footer
|
||||
[:button.btn-secondary {:on-click decline} (tr "onboarding.newsletter.decline")]
|
||||
[:button.btn-primary {:on-click accept} (tr "onboarding.newsletter.accept")]]
|
||||
[:img.deco.top {:src "images/deco-newsletter.png" :border "0"}]
|
||||
[:img.deco.newsletter-left {:src "images/deco-news-left.png" :border "0"}]
|
||||
[:img.deco.newsletter-right {:src "images/deco-news-right.png" :border "0"}]]]))
|
|
@ -43,13 +43,17 @@
|
|||
[{:keys [locale] :as props}]
|
||||
(let [profile (mf/deref refs/profile)
|
||||
form (fm/use-form :spec ::profile-form
|
||||
:initial profile)]
|
||||
:initial profile)
|
||||
disabled-button (mf/use-state true)
|
||||
activate-btn #(reset! disabled-button false)]
|
||||
|
||||
[:& fm/form {:on-submit on-submit
|
||||
:form form
|
||||
:class "profile-form"}
|
||||
[:div.fields-row
|
||||
[:& fm/input
|
||||
{:type "text"
|
||||
:on-key-down activate-btn
|
||||
:name :fullname
|
||||
:label (t locale "dashboard.your-name")}]]
|
||||
|
||||
|
@ -66,8 +70,19 @@
|
|||
[:a {:on-click #(modal/show! :change-email {})}
|
||||
(t locale "dashboard.change-email")]]]]
|
||||
|
||||
[:div.newsletter-subs
|
||||
[:p.newsletter-title (tr "dashboard.newsletter-title")]
|
||||
[:& fm/input {:name :newsletter-subscribed
|
||||
:class "check-primary"
|
||||
:type "checkbox"
|
||||
:label (tr "dashboard.newsletter-msg")
|
||||
:on-click activate-btn}]
|
||||
[:p.info (tr "onboarding.newsletter.privacy1") [:a {:target "_blank" :href "https://penpot.app/privacy.html"} (tr "onboarding.newsletter.policy")]]
|
||||
[:p.info (tr "onboarding.newsletter.privacy2")]]
|
||||
|
||||
[:& fm/submit-button
|
||||
{:label (t locale "dashboard.update-settings")}]
|
||||
{:label (t locale "dashboard.save-settings")
|
||||
:disabled @disabled-button}]
|
||||
|
||||
[:div.links
|
||||
[:div.link-item
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue