WIP(shops): customization categories skeleton

This commit is contained in:
Sabe Jones
2024-02-15 17:51:14 -06:00
parent 0f9cf48b55
commit 63e7ace693
6 changed files with 154 additions and 7 deletions

View File

@@ -134,6 +134,12 @@
> >
{{ $t('quests') }} {{ $t('quests') }}
</router-link> </router-link>
<router-link
class="topbar-dropdown-item dropdown-item"
:to="{name: 'customizations'}"
>
{{ $t('customizations') }}
</router-link>
<router-link <router-link
class="topbar-dropdown-item dropdown-item" class="topbar-dropdown-item dropdown-item"
:to="{name: 'seasonal'}" :to="{name: 'seasonal'}"

View File

@@ -2,7 +2,15 @@
<div class="row market"> <div class="row market">
<div class="standard-sidebar"> <div class="standard-sidebar">
<filter-sidebar> <filter-sidebar>
<filter-group /> <filter-group>
<checkbox
v-for="category in unfilteredCategories"
:id="`category-${category.identifier}`"
:key="category.identifier"
:checked.sync="viewOptions[category.identifier].selected"
:text="category.text"
/>
</filter-group>
</filter-sidebar> </filter-sidebar>
</div> </div>
<div class="standard-page p-0"> <div class="standard-page p-0">
@@ -16,11 +24,39 @@
> >
</div> </div>
</div> </div>
<div class="p-4">
<h1
v-once
class="mb-4"
>
{{ $t('customizations') }}
</h1>
<div
v-for="category in categories"
:key="category.identifier"
>
<h2 class="mb-3">
{{ category.text }}
</h2>
<div
v-for="item in category.items"
:key="item.key"
>
{{ item.text }}
</div>
</div>
</div>
</div> </div>
</div> </div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '~@/assets/scss/colors.scss';
h1 {
color: $purple-200;
}
.background, .npc { .background, .npc {
height: 216px; height: 216px;
} }
@@ -31,22 +67,33 @@
</style> </style>
<script> <script>
import shops from '@/../../common/script/libs/shops';
import { mapState } from '@/libs/store'; import { mapState } from '@/libs/store';
import Checkbox from '@/components/ui/checkbox';
import FilterSidebar from '@/components/ui/filterSidebar'; import FilterSidebar from '@/components/ui/filterSidebar';
import FilterGroup from '@/components/ui/filterGroup'; import FilterGroup from '@/components/ui/filterGroup';
export default { export default {
components: { components: {
Checkbox,
FilterGroup, FilterGroup,
FilterSidebar, FilterSidebar,
}, },
data () {
return {
viewOptions: {},
};
},
computed: { computed: {
...mapState({ ...mapState({
// content: 'content', // content: 'content',
// user: 'user.data', user: 'user.data',
currentEventList: 'worldState.data.currentEventList', currentEventList: 'worldState.data.currentEventList',
}), }),
anyFilterSelected () {
return Object.values(this.viewOptions).some(g => g.selected);
},
imageURLs () { imageURLs () {
const currentEvent = this.currentEventList.find(event => Boolean(event.season)); const currentEvent = this.currentEventList.find(event => Boolean(event.season));
if (!currentEvent) { if (!currentEvent) {
@@ -60,6 +107,29 @@ export default {
npc: `url(/static/npc/${currentEvent.season}/market_banner_npc.png)`, npc: `url(/static/npc/${currentEvent.season}/market_banner_npc.png)`,
}; };
}, },
shop () {
return shops.getCustomizationsShop(this.user);
},
unfilteredCategories () {
const apiCategories = this.shop.categories;
apiCategories.forEach(category => {
// do not reset the viewOptions if already set once
if (typeof this.viewOptions[category.identifier] === 'undefined') {
this.$set(this.viewOptions, category.identifier, {
selected: false,
});
}
});
return apiCategories;
},
categories () {
const { unfilteredCategories } = this;
return unfilteredCategories.filter(category => !this.anyFilterSelected
|| this.viewOptions[category.identifier].selected);
},
}, },
mounted () { mounted () {
this.$store.dispatch('common:setTitle', { this.$store.dispatch('common:setTitle', {

View File

@@ -1,7 +1,6 @@
<template> <template>
<div class="row timeTravelers"> <div class="row timeTravelers">
<div <div
v-if="!closed"
class="standard-sidebar d-none d-sm-block" class="standard-sidebar d-none d-sm-block"
> >
<filter-sidebar> <filter-sidebar>
@@ -88,7 +87,7 @@
<!-- eslint-disable vue/no-use-v-if-with-v-for --> <!-- eslint-disable vue/no-use-v-if-with-v-for -->
<div <div
v-for="category in categories" v-for="category in categories"
v-if="!anyFilterSelected || (!closed && viewOptions[category.identifier].selected)" v-if="!closed && (!anyFilterSelected || viewOptions[category.identifier].selected)"
:key="category.identifier" :key="category.identifier"
:class="category.identifier" :class="category.identifier"
> >

View File

@@ -187,5 +187,10 @@
"mainHand": "Main-Hand", "mainHand": "Main-Hand",
"offHand": "Off-Hand", "offHand": "Off-Hand",
"statPoints": "Stat Points", "statPoints": "Stat Points",
"pts": "pts" "pts": "pts",
"customizations": "Customizations",
"hairColors": "Hair Colors",
"hairStyles": "Hair Styles",
"skins": "Skins",
"facialHairs": "Facial Hair"
} }

View File

@@ -237,6 +237,5 @@
"submitQuestion": "Submit Question", "submitQuestion": "Submit Question",
"whyReportingPlayer": "Why are you reporting this player?", "whyReportingPlayer": "Why are you reporting this player?",
"whyReportingPlayerPlaceholder": "Reason for report", "whyReportingPlayerPlaceholder": "Reason for report",
"playerReportModalBody": "You should only report a player who violates the <%= firstLinkStart %>Community Guidelines<%= linkEnd %> and/or <%= secondLinkStart %>Terms of Service<%= linkEnd %>. Submitting a false report is a violation of Habiticas Community Guidelines.", "playerReportModalBody": "You should only report a player who violates the <%= firstLinkStart %>Community Guidelines<%= linkEnd %> and/or <%= secondLinkStart %>Terms of Service<%= linkEnd %>. Submitting a false report is a violation of Habiticas Community Guidelines."
"customizations": "Customizations"
} }

View File

@@ -543,4 +543,72 @@ shops.getBackgroundShopSets = function getBackgroundShopSets (language) {
return sets; return sets;
}; };
shops.getCustomizationsShopCategories = function getCustomizationsShopCategories (user, language) {
const categories = [];
const officialPinnedItems = getOfficialPinnedItems();
const backgroundsCategory = {
identifier: 'backgrounds',
text: i18n.t('backgrounds', language),
};
backgroundsCategory.items = values(content.backgroundsFlat)
.filter(bg => !user.purchased.background[bg.key] && (!bg.currency || bg.currency === 'gems'))
.map(bg => getItemInfo(user, 'background', bg, officialPinnedItems, language));
categories.push(backgroundsCategory);
const hairColorsCategory = {
identifier: 'hairColors',
text: i18n.t('hairColors', language),
};
categories.push(hairColorsCategory);
const hairStylesCategory = {
identifier: 'hairStyles',
text: i18n.t('hairStyles', language),
};
categories.push(hairStylesCategory);
const skinsCategory = {
identifier: 'skins',
text: i18n.t('skins', language),
};
categories.push(skinsCategory);
const animalEarsCategory = {
identifier: 'animalEars',
text: i18n.t('animalEars', language),
};
categories.push(animalEarsCategory);
const animalTailsCategory = {
identifier: 'animalTails',
text: i18n.t('animalTails', language),
};
categories.push(animalTailsCategory);
const shirtsCategory = {
identifier: 'shirts',
text: i18n.t('shirts', language),
};
categories.push(shirtsCategory);
const facialHairCategory = {
identifier: 'facialHair',
text: i18n.t('facialHairs', language),
};
categories.push(facialHairCategory);
return categories;
};
shops.getCustomizationsShop = function getCustomizationsShop (user, language) {
return {
identifier: 'customizations',
text: i18n.t('customizations'),
// notes: i18n.t('customizations'),
imageName: 'npc_alex',
categories: shops.getCustomizationsShopCategories(user, language),
};
};
export default shops; export default shops;