Skip to content

Commit c19b9e4

Browse files
Smonambeacom
authored andcommitted
QA: Implement Avatar builder Frontend (Fixes gitcoinco#813) (gitcoinco#967)
* add avatar builder view and create basic components * improve layout responsiveness, add color picker, add completed bullet * further improve responsive layout * Add section navigation * Begin adding assets * Finish filling in options for body and background * Add face preview * add preview for all face sections * Create all preview layers and order properly * add short hairstyles and hair color picker * add long hairstyles in black * Add remaining hair colors * Add one color of clothing * Get accessory preview (mostly) working * Fix avatar layer positioning Ported all existing options to new organization except accessories * Add Facial Hair * split avatar builder js into its own file * split avatar builder css into separate file * move layers logic to js * display notification when avatar complete * add skin and hair color pickers * add fantasy hair colors * fix style errors * fix plaid clothing asset * Add some clothing color options and refactor color picker * Add 4242F4 clothing option * Add 43B9F9 clothing option * add final clothing color F48914 * add button styling * add placeholder submit action * fix facial hair positioning * fix bug where facial hair preview color would not update * UX and styling tweaks * add selected style for color picker * remove selected style for old option in all but accessories section * make selected state work correctly for accessories * add checkmark to selected style * add option hover style * implement removal of optional layers * add removeable styles * standardize some styles * move avatar builder to onboarding flow and restore functionality * move avatar builder to onboarding flow also restored functionality and fixed non-layout styles * add avatar model * add renamed avatar builder template * add avatar migrations and view to set avatar * move css static file references to css * optimize images * create process for rendering and serving a single avatar config * Switch to background-image instead of img src for correct positioning optimized svgs lose their size attributes * tweak beard positioning and add config POST to save btn * use data attributes as a more cross-browser way to set paths * switch to rem units for relevant css rules * merge migration' * save avatar * Fix migrations and rename avatar template for onboard usage * Add BE for template and asset based avatar generation and S3 asset saving * Add avatars prefix to upload path * Add custom avatar rendering to profile page * Add avatar lookup and render before performing standard avatar rendering logic * Fix * Changes image path on change of color * Fixes the buttons in the FTUX flow and avatar page * Show visual indication for saving and saved * onboard: minor changes after feedback - updated content on github.html - move icons on GitHub page - green check mark to come after GitHub unlocked ( and metamask ) - reduction spacing between buttons & increase size - font lighter - link contributing guide - remove contributor tips - remove border-radius on wizard edged - remove capitalize aka camelcase - increased min-height of avatar-builder - added margin-top to avatar section to align it with builder - updated height of avatar-preview - updated default background color in avatar * Dont show button when logged in or metamask locked * Adjust save avatar response to json and modify update avatar handling * Update avatar save to record useraction * Makes the swatches and the avatar area into proper grid * Update media storage handling to use local FS for local * Redirect to login in onboard and link on index page * Save avatar and load it on reload * Add two new colors to skin * Reorder color palette for skin * Whoops * Fix frontend issues in avatar page - Rename text in success alert - Remove the text "Your avatar is complete" which appear when the avatar is saved - Hide alert when you move to next page - Move Save button above previous and next - When all the items in a category (like accessories ) are unchecked -> the left sidebar should reflect status as unchecked (should become a square instead of tick) - Reduce spacing between heading "Pick your xxx" and the avatar builder * Adjust avatar on github step * onboard: fixes - hide video is user is logged in to metamask - remove line breaks between first two para - updated text in Metamask - rename suggest skills -> suggest skills that apply - reduce the bullet size of tips section - link the Get Started here on the footer to the funder form * Reduce spacing between heading 'Pick your xxx' and the avatar builder * Re-enable analytics for non-prod envs... * removed csrf from avatar.html * when skills autopopulates -> change to plus icon to tick on highlighted skills * Move existing avatar logic to the avatar app * added UI for avatar in settings/account * Add png field to store GH avatars on Avatar and temp file handling * Fixes avatar reload for non compulsory items * Adds check for ids in localstorage * Add onboard url to welcomebot * Remove 3F2A18 and add EEE3C1 skintones * Change quickstart link copy * Do this later button changestep * Adjust pallete to palette * hide do later button on save, show on error * Typos and disable login redirect to accommodate the ftux github login step * Fixes some more things suggested by Alisa - Removes shadow from buttons - Make buttons look same throughout FTUX - 3 buttons as shown in the screenshot by alisa for avatar - Do this later works - Do this later button disabled on saving * Updates for account settings for avatar editing * Adjust use_github_avatar on svg av save * Fix taking to the next step after saving * Minor avatar handling adjustments * yapf * Consolidate migrations
1 parent 5381f5c commit c19b9e4

472 files changed

Lines changed: 2057 additions & 255 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ app/assets/other/wp.pdf
1212
app/assets/tmp/*
1313
app/assets/other/avatars/
1414
app/gcoin/
15+
app/media/
1516
.idea/
1617
venv/
1718
.coverage
@@ -37,4 +38,4 @@ webpack-stats.json
3738

3839
*.prof
3940

40-
.pytest_cache/
41+
.pytest_cache/

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fix-stylelint: ## Run stylelint --fix against the project directory. Requires no
2626
@npm run stylelint:fix
2727

2828
fix-yapf: ## Run yapf against any included or newly introduced Python code.
29-
@docker-compose exec web yapf -i -r -e "app/**/migrations/*.py" -p app/dataviz/ app/app/ app/enssubdomain/
29+
@docker-compose exec web yapf -i -r -e "app/**/migrations/*.py" -p app/dataviz/ app/app/ app/enssubdomain/ app/avatar/
3030

3131
fix: fix-eslint fix-stylelint fix-isort fix-yapf ## Attempt to run all fixes against the project directory.
3232

app/app/settings.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
'django_extensions',
7171
'easy_thumbnails',
7272
'app',
73+
'avatar',
7374
'retail',
7475
'rest_framework',
7576
'bootstrap3',
@@ -232,9 +233,6 @@
232233

233234
GEOIP_PATH = env('GEOIP_PATH', default='/usr/share/GeoIP/')
234235

235-
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
236-
THUMBNAIL_DEFAULT_STORAGE = DEFAULT_FILE_STORAGE
237-
238236
# Static files (CSS, JavaScript, Images)
239237
# https://docs.djangoproject.com/en/1.11/howto/static-files/
240238
STATICFILES_STORAGE = env('STATICFILES_STORAGE', default='app.static_storage.SilentFileStorage')
@@ -467,6 +465,14 @@
467465
S3_REPORT_BUCKET = env('S3_REPORT_BUCKET', default='') # TODO
468466
S3_REPORT_PREFIX = env('S3_REPORT_PREFIX', default='') # TODO
469467

468+
# Handle local file storage
469+
if ENV == 'local' and not AWS_STORAGE_BUCKET_NAME:
470+
MEDIA_URL = '/media/'
471+
MEDIA_ROOT = root('media')
472+
else:
473+
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
474+
THUMBNAIL_DEFAULT_STORAGE = DEFAULT_FILE_STORAGE
475+
470476
INSTALLED_APPS += env.list('DEBUG_APPS', default=[])
471477

472478
# Faucet App config

app/app/urls.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
'''
1818
from django.conf import settings
1919
from django.conf.urls import include, url
20+
from django.conf.urls.static import static
2021
from django.contrib import admin
2122
from django.contrib.auth import views as auth_views
2223
from django.contrib.sitemaps.views import sitemap
2324
from django.urls import path, re_path
2425
from django.views.i18n import JavaScriptCatalog
2526

27+
import avatar.views
2628
import credits.views
2729
import dashboard.embed
2830
import dashboard.helpers
@@ -80,6 +82,9 @@
8082
path('issue/increase', dashboard.views.increase_bounty, name='increase_bounty'),
8183
path('issue/cancel', dashboard.views.cancel_bounty, name='kill_bounty'),
8284

85+
# Avatars
86+
path('avatar/', include('avatar.urls', namespace='avatar')),
87+
8388
# Interests
8489
path('actions/bounty/<int:bounty_id>/interest/new/', dashboard.views.new_interest, name='express-interest'),
8590
path('actions/bounty/<int:bounty_id>/interest/remove/', dashboard.views.remove_interest, name='remove-interest'),
@@ -145,8 +150,8 @@
145150

146151
# images
147152
re_path(r'^funding/embed/?', dashboard.embed.embed, name='embed'),
148-
re_path(r'^funding/avatar/?', dashboard.embed.avatar, name='avatar'),
149-
re_path(r'^static/avatar/(.*)/(.*)?', dashboard.embed.avatar, name='org_avatar'),
153+
re_path(r'^funding/avatar/?', avatar.views.handle_avatar, name='avatar'),
154+
re_path(r'^static/avatar/(.*)/(.*)?', avatar.views.handle_avatar, name='org_avatar'),
150155
re_path(r'^static/viz/graph/(.*)?$', dataviz.d3_views.viz_graph, name='viz_graph'),
151156
re_path(r'^static/viz/sscatterplot/(.*)?$', dataviz.d3_views.viz_scatterplot_stripped, name='viz_sscatterplot'),
152157

@@ -352,6 +357,9 @@
352357
if settings.ENABLE_SILK:
353358
urlpatterns += [url(r'^silk/', include('silk.urls', namespace='silk'))]
354359

360+
if settings.ENV == 'local' and not settings.AWS_STORAGE_BUCKET_NAME:
361+
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
362+
355363
handler403 = 'retail.views.handler403'
356364
handler404 = 'retail.views.handler404'
357365
handler500 = 'retail.views.handler500'
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
#avatar-builder {
2+
display: flex;
3+
flex-flow: row wrap;
4+
align-items: flex-start;
5+
}
6+
7+
#avatar-builder__sections {
8+
text-align: left;
9+
list-style-type: square;
10+
list-style-position: inside;
11+
padding-left: 0;
12+
flex-shrink: 0;
13+
display: flex;
14+
flex-wrap: wrap;
15+
flex-basis: 100%;
16+
justify-content: center;
17+
margin-top: 2rem;
18+
}
19+
20+
#avatar-builder__sections li {
21+
width: 10rem;
22+
padding: 5px;
23+
color: #15003e;
24+
text-decoration: none;
25+
}
26+
27+
#avatar-builder__sections li.open {
28+
text-decoration: underline;
29+
}
30+
31+
#avatar-builder__sections li.complete {
32+
list-style-image: url('/static/v2/images/check-dark.svg');
33+
}
34+
35+
#avatar-builder__editor {
36+
flex-grow: 0;
37+
}
38+
39+
#section-title {
40+
flex-basis: 100%;
41+
text-align: center;
42+
margin-bottom: 0.5rem;
43+
}
44+
45+
.section-title__content {
46+
display: none;
47+
}
48+
49+
.section-title__content.open {
50+
display: unset;
51+
}
52+
53+
#avatar-preview {
54+
width: 250px;
55+
height: 256px;
56+
background-color: #D8D8D8;
57+
flex-shrink: 0;
58+
position: relative;
59+
}
60+
61+
.preview-section {
62+
width: 100%;
63+
height: 100%;
64+
background-size: contain;
65+
background-position: center;
66+
background-repeat: no-repeat;
67+
position: absolute;
68+
top: 0;
69+
left: 0;
70+
}
71+
72+
.options-section {
73+
height: min-content;
74+
overflow: scroll;
75+
display: none !important;
76+
justify-content: center;
77+
}
78+
79+
.options-section.open {
80+
display: flex !important;
81+
}
82+
83+
button.avatar-option {
84+
border: none;
85+
width: 80px;
86+
height: 80px;
87+
background-color: #D8E7FF;
88+
margin: 0 0 8px 8px;
89+
cursor: pointer;
90+
padding: 0;
91+
position: relative;
92+
background-size: contain;
93+
background-position: center;
94+
background-repeat: no-repeat;
95+
}
96+
97+
.avatar-option div, #avatar-preview div {
98+
width: 100%;
99+
height: 100%;
100+
position: absolute;
101+
top: 0;
102+
left: 0;
103+
background-size: contain;
104+
background-position: center;
105+
background-repeat: no-repeat;
106+
}
107+
108+
.avatar-option::after {
109+
position: absolute;
110+
bottom: -8px;
111+
right: -8px;
112+
color: white;
113+
width: 25px;
114+
height: 25px;
115+
border-radius: 50%;
116+
font-size: 1.2rem;
117+
line-height: 1.2rem;
118+
}
119+
120+
.avatar-option:hover {
121+
border: 2px solid #00BB61;
122+
}
123+
124+
.avatar-option:hover::before {
125+
position: absolute;
126+
content: '';
127+
left: 0;
128+
top: 0;
129+
height: 100%;
130+
width: 100%;
131+
background-color: #00BB61;
132+
opacity: .2;
133+
z-index: 10;
134+
}
135+
136+
.avatar-option:hover::after {
137+
content: '+';
138+
background-color: #00BB61;
139+
z-index: 11;
140+
}
141+
142+
.avatar-option.selected:hover::before {
143+
display: none;
144+
}
145+
146+
.avatar-option.selected::after {
147+
content: url('/static/v2/images/check.svg');
148+
background-color: #150069;
149+
}
150+
151+
.optional .avatar-option.selected:hover {
152+
border-color: #FFA400 !important;
153+
}
154+
155+
.optional .avatar-option.selected:hover::before {
156+
display: unset;
157+
background-color: #FFA400;
158+
}
159+
160+
.optional .avatar-option.selected:hover::after {
161+
background-color: #FFA400;
162+
content: '-';
163+
}
164+
165+
.color-option {
166+
width: 100%;
167+
height: 100%;
168+
}
169+
170+
#avatar-builder__actions {
171+
text-align: right;
172+
margin-top: 2rem;
173+
width: 100%;
174+
}
175+
176+
#color-picker {
177+
text-align: center;
178+
display: flex;
179+
line-height: 1;
180+
}
181+
182+
.options-Background__option {
183+
height: 28px;
184+
border: 1px solid #C4C4C4;
185+
cursor: pointer;
186+
flex-grow: 1;
187+
}
188+
189+
.selected, .avatar-option:active, .options-Background__option:active {
190+
border: 2px solid #150069 !important;
191+
}
192+
193+
@media (min-width: 500px) {
194+
195+
#avatar-builder {
196+
flex-wrap: nowrap !important;
197+
}
198+
199+
#avatar-builder__sections {
200+
display: block;
201+
flex-basis: 170px;
202+
}
203+
}
204+
205+
@media (min-width: 845px) {
206+
207+
#avatar-area {
208+
flex-wrap: nowrap !important;
209+
justify-content: flex-start !important;
210+
max-width: 525px;
211+
}
212+
213+
#section-title {
214+
text-align: left;
215+
}
216+
217+
.options-section {
218+
overflow: auto;
219+
max-height: 264px;
220+
justify-content: flex-start;
221+
}
222+
223+
#color-picker {
224+
text-align: left;
225+
}
226+
}

app/assets/v2/css/dashboard.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ body {
4848
}
4949

5050
#onboard-dashboard .tips .fa-circle {
51-
font-size: 0.35rem;
51+
font-size: 5.7px;
5252
margin-right: 0.4rem;
5353
top: -2px;
5454
position: relative;

app/assets/v2/css/forms/button.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
background-color: rgba(79, 79, 79, 0.26);
2222
box-shadow: none;
2323
color: rgba(0, 0, 0, 0.26);
24+
border-color: rgba(0,0,0, 0.3);
2425
}
2526

2627
.button--primary {
@@ -39,7 +40,7 @@
3940
background-color: #fff;
4041
border: 1px solid #0D0764;
4142
color: #0D0764;
42-
padding: 8px 18px;
43+
padding: 9px 18px;
4344
}
4445

4546
.button--primary-o:hover {

0 commit comments

Comments
 (0)