Skip to content

Commit a5c2471

Browse files
authored
UI improvements (#466)
* remove new job placeholders * show current profile image when editing profile * add Edit Profile button * improve new job validation * update skill list
1 parent a44e2b1 commit a5c2471

File tree

8 files changed

+332
-42
lines changed

8 files changed

+332
-42
lines changed

shared/src/ethlance/shared/constants.cljs

Lines changed: 266 additions & 13 deletions
Large diffs are not rendered by default.

shared/src/ethlance/shared/spec.cljs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[cljs.spec.alpha :as s]
55
[cljs.pprint]
66
[clojure.set :as set]
7+
[clojure.string :as str]
78
[district.validation :refer [length? email? not-neg?]]
89
[ethlance.shared.constants :as constants]
910
[medley.core :refer [map-kv-vals]]))
@@ -73,9 +74,15 @@
7374
(s/def :job/title (s/and string? (comp not empty?)))
7475
(s/def :job/required-skills (comp not empty?))
7576

77+
(s/def ::token-amount not-neg?)
78+
(s/def ::human-amount (s/and string? #(not (clojure.string/blank? %))))
79+
(s/def ::decimals not-neg?)
80+
81+
(s/def :job/token-amount
82+
(s/keys :req-un [::token-amount ::human-amount ::decimals]))
7683

7784
(s/def :page.new-job/create
78-
(s/keys :req [:job/title :job/required-skills]))
85+
(s/keys :req [:job/title :job/required-skills :job/token-amount]))
7986

8087

8188
(s/def :page.sign-up/update-candidate

ui/resources/public/less/page/profile.less

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@
4343
}
4444

4545
> .title {
46+
width: 100%;
4647
grid-area: title;
4748
display: grid;
4849
grid-template-areas:
49-
'profile-image name'
50-
'profile-image detail';
51-
grid-template-columns: 72px auto;
50+
'profile-image name edit-button'
51+
'profile-image detail edit-button';
52+
grid-template-columns: 72px auto max-content;
5253
grid-template-rows: auto auto;
5354

5455
@media #media[tablet-query] {
@@ -74,6 +75,13 @@
7475
padding: 0.5em 1.4em;
7576

7677
}
78+
79+
> .edit-button {
80+
grid-area: edit-button;
81+
align-self: start;
82+
justify-self: end;
83+
padding-top: 0.5em;
84+
}
7785
}
7886

7987
> .biography {

ui/resources/public/less/page/sign-up.less

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,14 @@
114114

115115
> .dropzone {
116116
width: 100%;
117+
height: 100%;
117118
position: relative;
119+
cursor: pointer;
120+
121+
> img {
122+
width: 100%;
123+
height: 100%;
124+
}
118125

119126
.file-input-label {
120127
display: flex;

ui/src/ethlance/ui/component/file_drag_input.cljs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,26 @@
4040
(.readAsArrayBuffer ab-reader f))
4141
(when on-file-rejected
4242
(on-file-rejected fprops))))))]
43-
(fn [{:keys [form-data id]
43+
(fn [{:keys [form-data id current-src]
4444
:as opts}]
45-
(let [{:keys [url-data]} (get-in @form-data [id :selected-file])]
46-
[:div.dropzone
47-
{:on-drag-over allow-drop
45+
(let [{:keys [url-data]} (get-in @form-data [id :selected-file])
46+
file-input-id (id-for-path id)]
47+
[:label.dropzone
48+
{:htmlFor file-input-id
49+
:on-drag-over allow-drop
4850
:on-drop #(do
4951
(.preventDefault %)
5052
(handle-files-select (.. % -dataTransfer -files)))
5153
:on-drag-enter allow-drop}
5254

53-
[:img {:src (or url-data empty-img-src)}]
55+
[:img {:src (or url-data current-src empty-img-src)}]
5456

55-
(when (not url-data)
56-
[:label.file-input-label
57-
{:for (id-for-path id)}
57+
(when (not (or url-data current-src))
58+
[:div.file-input-label
5859
[c-icon {:name :ic-upload :color :dark-blue :inline? false}]
5960
[:div (get opts :label "File...")]])
6061

6162
[:input {:type :file
62-
:id (id-for-path id)
63+
:id file-input-id
6364
:on-change (fn [e]
6465
(handle-files-select (-> e .-target .-files)))}]]))))

ui/src/ethlance/ui/page/new_job/events.cljs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,21 @@
2828

2929
(def interceptors [re/trim-v])
3030

31+
(def default-token-amount
32+
{:token-amount 0 :human-amount "0" :decimals 18})
3133

3234
(def state-default
33-
{:job/title "Rauamaak on meie saak"
34-
:job/description "Tee t88d ja n2e vaeva"
35-
:job/category "Admin Support"
35+
{:job/title ""
36+
:job/description ""
37+
:job/category ""
3638
:job/bid-option :hourly-rate
3739
:job/required-experience-level :intermediate
3840
:job/estimated-project-length :day
3941
:job/required-availability :full-time
40-
:job/required-skills (set (repeatedly 2 #(rand-nth constants/skills)))
42+
:job/required-skills #{}
4143
:job/token-type :eth
42-
:job/token-amount 0.69
43-
:job/token-address "0x1111111111111111111111111111111111111111"
44-
:job/token-id 0
44+
:job/token-address ""
45+
:job/token-amount default-token-amount
4546
:job/with-arbiter? false
4647
:job/invited-arbiters #{}
4748
:job/token-decimals 18})
@@ -119,7 +120,7 @@
119120
(fn [] [:dispatch [:page.new-job/decimals-response default-decimals]]))]
120121
{:fx [(decimals-fx-fn)]
121122
:db (-> db
122-
(assoc-in ,,, [state-key :job/token-amount] 1)
123+
(assoc-in ,,, [state-key :job/token-amount] default-token-amount)
123124
(assoc-in ,,, [state-key :job/token-type] token-type))})))
124125

125126

@@ -215,11 +216,12 @@
215216
::send-create-job-tx
216217
(fn [{:keys [db]} _]
217218
(let [employer (get-job-creation-param db :employer)
218-
offered-value (get-job-creation-param db :offered-value)
219+
token-type (get-job-creation-param db :token-type)
220+
offered-value (cond-> (get-job-creation-param db :offered-value)
221+
(#{:eth :erc20} token-type) (assoc-in [:token :tokenId] 0))
219222
ipfs-hash (get-job-creation-param db :ipfs-hash)
220223
arbiters (get-job-creation-param db :arbiters)
221224
tx-opts-base {:from employer}
222-
token-type (get-job-creation-param db :token-type)
223225
tx-opts (if (= token-type :eth)
224226
(assoc tx-opts-base :value (:value offered-value))
225227
tx-opts-base)]

ui/src/ethlance/ui/page/profile.cljs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@
291291
[:div.profile-image
292292
[c-profile-image {:src image-url}]]
293293
[:div.name name]
294+
[:div.edit-button
295+
[c-button (merge {:size :small} (navigation/link-params {:route :route.me/sign-up
296+
:query {:tab :candidate}}))
297+
[c-button-label "Edit Profile"]]]
294298
[:div.detail professional-title]]
295299
[:div.biography biography]
296300
[c-rating-box rating]
@@ -343,6 +347,10 @@
343347
[:div.profile-image
344348
[c-profile-image {:src image-url}]]
345349
[:div.name name]
350+
[:div.edit-button
351+
[c-button (merge {:size :small} (navigation/link-params {:route :route.me/sign-up
352+
:query {:tab :employer}}))
353+
[c-button-label "Edit Profile"]]]
346354
[:div.detail professional-title]]
347355
[:div.biography biography]
348356
[c-rating-box rating]
@@ -456,6 +464,10 @@
456464
[:div.profile-image
457465
[c-profile-image {:src image-url}]]
458466
[:div.name name]
467+
[:div.edit-button
468+
[c-button (merge {:size :small} (navigation/link-params {:route :route.me/sign-up
469+
:query {:tab :arbiter}}))
470+
[c-button-label "Edit Profile"]]]
459471
[:div.detail professional-title]]
460472
[:div.biography biography]
461473
[c-rating-box rating]

ui/src/ethlance/ui/page/sign_up.cljs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
[district.ui.router.subs :as router.subs]
1010
[ethlance.shared.constants :as constants]
1111
[ethlance.shared.spec :refer [validate-keys]]
12-
[ethlance.ui.component.button :refer [c-button c-button-icon-label]]
1312
[ethlance.ui.component.currency-input :refer [c-currency-input]]
1413
[ethlance.ui.component.email-input :refer [c-email-input]]
1514
[ethlance.ui.component.file-drag-input :refer [c-file-drag-input]]
@@ -24,7 +23,7 @@
2423
[ethlance.ui.page.sign-up.events :as sign-up.events]
2524
[ethlance.ui.page.sign-up.subscriptions]
2625
[ethlance.ui.util.component :refer [>evt]]
27-
[ethlance.ui.util.navigation :as navigation-utils]
26+
[ethlance.ui.util.urls :as util.urls]
2827
[re-frame.core :as re]
2928
[reagent.core :as r]
3029
[taoensso.timbre :as log]))
@@ -33,11 +32,12 @@
3332
(defn- c-upload-image
3433
[]
3534
(let [form-data (r/atom {})]
36-
(fn []
35+
(fn [{:keys [:form-values]}]
3736
[:div.upload-image
3837
[c-file-drag-input
3938
{:form-data form-data
4039
:id :file-info
40+
:current-src (-> form-values :user/profile-image util.urls/ipfs-hash->gateway-url)
4141
:label "Upload file"
4242
:file-accept-pred (fn [{:keys [name type size]}]
4343
(log/debug "Veryfing acceptance of file" {:name name :type type :size size})
@@ -132,7 +132,7 @@
132132
[:div.label "Sign Up"]
133133
[:div.first-forms
134134
[:div.form-image
135-
[c-upload-image]]
135+
[c-upload-image {:form-values form-values}]]
136136
[c-user-name-input
137137
{:form-values form-values
138138
:form-validation form-validation}]
@@ -200,7 +200,7 @@
200200
[:div.label "Sign Up"]
201201
[:div.first-forms
202202
[:div.form-image
203-
[c-upload-image]]
203+
[c-upload-image {:form-values form-values}]]
204204
[c-user-name-input
205205
{:form-values form-values
206206
:form-validation form-validation}]
@@ -242,7 +242,7 @@
242242
[:div.label "Sign Up"]
243243
[:div.first-forms
244244
[:div.form-image
245-
[c-upload-image]]
245+
[c-upload-image {:form-values form-values}]]
246246
[c-user-name-input
247247
{:form-values form-values
248248
:form-validation form-validation}]

0 commit comments

Comments
 (0)