From 4289becccc8663985736094e9fa2360d44733f0c Mon Sep 17 00:00:00 2001 From: negue Date: Wed, 10 Apr 2019 22:09:04 +0200 Subject: [PATCH] Performance: My Challenges (#11065) * use the same paging for "myChallenges" only loads 10 per call * challenges: show loading above the load-more button (instead at the top) * purple loading message and flat load-more button * remove comment * show loadMore button only when the request has 10 entries * challenge card ui --- website/client/assets/scss/categories.scss | 17 +- website/client/assets/svg/official.svg | 6 + .../components/challenges/challengeItem.vue | 186 ++++++++++++++---- .../components/challenges/findChallenges.vue | 27 ++- .../components/challenges/myChallenges.vue | 74 ++++++- website/client/components/userLink.vue | 4 - website/client/mixins/challengeUtilities.js | 41 ---- .../server/controllers/api-v3/challenges.js | 2 +- 8 files changed, 253 insertions(+), 104 deletions(-) create mode 100644 website/client/assets/svg/official.svg diff --git a/website/client/assets/scss/categories.scss b/website/client/assets/scss/categories.scss index 3108537157..5403a5e868 100644 --- a/website/client/assets/scss/categories.scss +++ b/website/client/assets/scss/categories.scss @@ -13,14 +13,19 @@ min-width: 100px; border-radius: 100px; background-color: $gray-600; - padding: .5em; + padding: 4px 12px; display: inline-block; - margin: .25em; - font-size: 12px; - font-weight: 500; - line-height: 1.33; + margin-right: 4px; + margin-top: 8px; text-align: center; - color: $gray-300; + + font-size: 12px; + font-weight: normal; + font-style: normal; + font-stretch: normal; + line-height: 1.33; + letter-spacing: normal; + color: $gray-100; } .category-label-purple { diff --git a/website/client/assets/svg/official.svg b/website/client/assets/svg/official.svg new file mode 100644 index 0000000000..11dc5e1741 --- /dev/null +++ b/website/client/assets/svg/official.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/website/client/components/challenges/challengeItem.vue b/website/client/components/challenges/challengeItem.vue index 17b9428893..98f1e49d19 100644 --- a/website/client/components/challenges/challengeItem.vue +++ b/website/client/components/challenges/challengeItem.vue @@ -4,28 +4,26 @@ .number span.svg-icon(v-html="icons.gemIcon") span.value {{challenge.prize}} - .label {{ $t('challengePrize') }} + .label {{ $t('prize') }} .challenge-header router-link( :to="{ name: 'challenge', params: { challengeId: challenge._id } }" ) h3.challenge-title(v-markdown='challenge.name') - .owner(v-if="fullLayout") - .owner-item - strong {{ $t('createdBy') }}: - user-link.mx-1(:user="challenge.leader") - .owner-item(v-if="challenge.group && !isTavern(challenge.group)") - strong {{ $t(challenge.group.type) }}: - group-link.mx-1(:group="challenge.group") - .meta - .meta-item + .meta-info + .member-count .svg-icon.user-icon(v-html="icons.memberIcon") - span.mx-1 {{challenge.memberCount}} - // @TODO: add end date - .meta-item - .svg-icon(v-html="icons.calendarIcon") - strong.mx-1 {{ $t('endDate')}}: - span {{challenge.endDate}} + span.count-label {{challenge.memberCount}} + .divider + .official(v-if="isOfficial") + .svg-icon.user-icon(v-html="icons.officialIcon") + .owner(v-if="fullLayout") + .owner-item + strong {{ $t('createdBy') }}: + user-link.mx-1(:user="challenge.leader") + .owner-item(v-if="challenge.group && !isTavern(challenge.group)") + strong {{ $t(challenge.group.type) }}: + group-link.mx-1(:group="challenge.group") category-tags.challenge-categories( :categories="challenge.categories", :owner="isOwner", @@ -42,16 +40,23 @@ @@ -84,36 +89,90 @@ font-size: .9em; } + .official { + margin-right: 8px; + } + .challenge-prize { text-align: center; color: $gems-color; display: inline-block; float: right; - padding: 1em 1.5em; + padding: 18px 24px; margin-left: 1em; - background: #eefaf6; + background: #24cc8f19; border-bottom-left-radius: 4px; + width: 107px; + height: 80px; .svg-icon { - width: 32px; + width: 24px; + height: 24px; + object-fit: contain; + } + + .value { + margin-left: 8px; + font-size: 20px; + font-weight: bold; + font-style: normal; + font-stretch: normal; + line-height: 1.4; + letter-spacing: normal; + color: #1ca372; + } + + .label { + margin-top: 4px; + font-size: 12px; + font-weight: bold; + font-style: normal; + font-stretch: normal; + line-height: 1.33; + letter-spacing: normal; + text-align: center; + color: #1ca372; } } - .challenge-header, - .well-wrapper { - padding: 1em 1.5em; + .divider { + width: 1px; + height: 16px; + background-color: $gray-600; + margin-right: 12px; + margin-left: 12px; } .challenge-header { - padding-bottom: .5em; + padding: 16px 20px; } - .owner { - margin: 1em 0 .5em; + .well-wrapper { + padding: 16px 20px 20px; } - .meta, .owner { - display: flex; + .challenge-header { + padding-bottom: 0; + } + + .meta-info { + height: 24px; + margin-bottom: 8px; + } + + .count-label { + font-size: 14px; + font-weight: normal; + font-style: normal; + font-stretch: normal; + line-height: 1.71; + letter-spacing: normal; + color: $gray-50; + margin-left: 4px; + } + + .meta-info, .owner, .member-count { + display: inline-flex; align-items: center; flex-wrap: wrap; } @@ -134,7 +193,7 @@ .challenge-categories { clear: right; display: flex; - padding: 0 1.5em 1em; + padding: 0 20px 16px; flex-wrap: wrap; } @@ -159,9 +218,16 @@ } .challenge-description { - color: $gray-200; - margin: 0 1.5em; + margin: 0 20px 0; word-break: break-word; + + font-size: 14px; + font-weight: normal; + font-style: normal; + font-stretch: normal; + line-height: 1.71; + letter-spacing: normal; + color: $gray-50; } .well { @@ -170,22 +236,65 @@ justify-content: space-evenly; background-color: $gray-700; text-align: center; - padding: 1em; + padding: 16px; border-radius: .25em; > div { - color: $gray-200; + .value { + font-size: 20px; + font-weight: bold; + font-style: normal; + font-stretch: normal; + line-height: 1.4; + letter-spacing: normal; + color: $gray-50; + } + + .label { + font-size: 12px; + font-weight: bold; + font-style: normal; + font-stretch: normal; + line-height: 1.33; + letter-spacing: normal; + text-align: center; + color: $gray-100; + } .svg-icon { - color: $gray-300; + object-fit: contain; + color: $gray-100; } } > div.muted { - color: $gray-400; + .value { + opacity: 0.5; + font-size: 20px; + font-weight: bold; + font-style: normal; + font-stretch: normal; + line-height: 1.4; + letter-spacing: normal; + color: $gray-50; + } + + .label { + opacity: 0.5; + font-size: 12px; + font-weight: bold; + font-style: normal; + font-stretch: normal; + line-height: 1.33; + letter-spacing: normal; + text-align: center; + color: $gray-100; + } .svg-icon { - color: $gray-500; + object-fit: contain; + opacity: 0.5; + color: $gray-100; } } } @@ -208,6 +317,7 @@ import todoIcon from 'assets/svg/todo.svg'; import dailyIcon from 'assets/svg/daily.svg'; import rewardIcon from 'assets/svg/reward.svg'; + import officialIcon from 'assets/svg/official.svg'; export default { props: { @@ -232,6 +342,7 @@ gemIcon, memberIcon, calendarIcon, + officialIcon, }), }; }, @@ -243,6 +354,9 @@ isMember () { return this.user.challenges.indexOf(this.challenge._id) !== -1; }, + isOfficial () { + return this.challenge.official || this.challenge.categories.map(category => category.slug).includes('habitica_official'); + }, tasksData () { return [ { diff --git a/website/client/components/challenges/findChallenges.vue b/website/client/components/challenges/findChallenges.vue index 5b455aa5f4..bbd53e046e 100644 --- a/website/client/components/challenges/findChallenges.vue +++ b/website/client/components/challenges/findChallenges.vue @@ -6,7 +6,6 @@ .row.header-row .col-md-8.text-left h1(v-once) {{$t('findChallenges')}} - h2(v-if='loading') {{ $t('loading') }} .col-md-4 // @TODO: implement sorting span.dropdown-label {{ $t('sortBy') }} b-dropdown(:text="$t('sort')", right=true) @@ -24,8 +23,11 @@ challenge-item(:challenge='challenge') .row - .col-12.text-center(v-if='!loading && filteredChallenges.length > 0') - button.btn.btn-secondary(@click='loadMore()') {{ $t('loadMore') }} + h2.col-12.loading(v-if='loading') {{ $t('loading') }} + + .row + .col-12.text-center(v-if='showLoadMore && !loading && filteredChallenges.length > 0') + button.btn.btn-flat.btn-show-more(@click='loadMore()') {{ $t('loadMore') }} diff --git a/website/client/components/userLink.vue b/website/client/components/userLink.vue index a0fbc576d2..82fdb90f0c 100644 --- a/website/client/components/userLink.vue +++ b/website/client/components/userLink.vue @@ -11,10 +11,6 @@