From e39d07c37fd4330187e72cd08821f9001dbf1669 Mon Sep 17 00:00:00 2001 From: Teemu Patja Date: Fri, 3 Nov 2017 09:50:15 +0200 Subject: [PATCH] Improve flash message styling & invalid address error message * more readable flash message popup * close flash message popup by clicking outside * show input in "invalid address" error message --- src/clj/commiteth/routes/services.clj | 6 ++++-- src/cljs/commiteth/core.cljs | 1 + src/cljs/commiteth/handlers.cljs | 8 +++++--- src/less/style.less | 10 +++++++++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/clj/commiteth/routes/services.clj b/src/clj/commiteth/routes/services.clj index f9f9bbc..5789df1 100644 --- a/src/clj/commiteth/routes/services.clj +++ b/src/clj/commiteth/routes/services.clj @@ -235,8 +235,10 @@ :body-params [user-id :- Long, address :- String] :summary "Update user address" (if-not (eth/valid-address? address) - {:status 400 - :body "Invalid Ethereum address"} + (do + (log/debug "POST /address: invalid input" address) + {:status 400 + :body (str "Invalid Ethereum address '" address "'")}) (let [result (users/update-user-address user-id address)] diff --git a/src/cljs/commiteth/core.cljs b/src/cljs/commiteth/core.cljs index 3a12f68..cabdc01 100644 --- a/src/cljs/commiteth/core.cljs +++ b/src/cljs/commiteth/core.cljs @@ -285,4 +285,5 @@ (load-interceptors!) (hook-browser-navigation!) (load-data true) + (.addEventListener js/window "click" #(rf/dispatch [:clear-flash-message])) (on-js-load)) diff --git a/src/cljs/commiteth/handlers.cljs b/src/cljs/commiteth/handlers.cljs index cffac1e..48eccf8 100644 --- a/src/cljs/commiteth/handlers.cljs +++ b/src/cljs/commiteth/handlers.cljs @@ -324,9 +324,11 @@ (dispatch [:set-flash-message :success "Address saved"])) - :on-error #(dispatch [:set-flash-message - :error - (:response %)]) + :on-error #(do + (println %) + (dispatch [:set-flash-message + :error + (:response %)])) :finally #(dispatch [:clear-updating-address]) :params {:user-id user-id :address address}}})) diff --git a/src/less/style.less b/src/less/style.less index d6887d8..5b7e159 100644 --- a/src/less/style.less +++ b/src/less/style.less @@ -607,11 +607,14 @@ &.error { background-color: #e96868; } + display: flex; + flex-direction: column; color: #fff; border-radius: 8px; z-index: 100; - padding: 1.4em 1em 1.4em; + padding: 40px 60px 40px; + height: auto; i { position: absolute; margin: 0; @@ -619,6 +622,11 @@ top: 1.5em; cursor: pointer; } + p { + font-family: "PostGrotesk-Book"; + font-weight: 500; + font-size: 15px; + } }