mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
WIP(shop): backgrounds appear
This commit is contained in:
@@ -2,6 +2,17 @@
|
|||||||
<div class="row market">
|
<div class="row market">
|
||||||
<div class="standard-sidebar">
|
<div class="standard-sidebar">
|
||||||
<filter-sidebar>
|
<filter-sidebar>
|
||||||
|
<div
|
||||||
|
slot="search"
|
||||||
|
class="form-group"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
v-model="searchText"
|
||||||
|
class="form-control input-search"
|
||||||
|
type="text"
|
||||||
|
:placeholder="$t('search')"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
<filter-group>
|
<filter-group>
|
||||||
<checkbox
|
<checkbox
|
||||||
v-for="category in unfilteredCategories"
|
v-for="category in unfilteredCategories"
|
||||||
@@ -38,12 +49,26 @@
|
|||||||
<h2 class="mb-3">
|
<h2 class="mb-3">
|
||||||
{{ category.text }}
|
{{ category.text }}
|
||||||
</h2>
|
</h2>
|
||||||
<div
|
<item-rows
|
||||||
v-for="item in category.items"
|
:items="customizationsItems({category, searchBy: searchTextThrottled})"
|
||||||
:key="item.key"
|
:type="category.identifier"
|
||||||
|
:item-width="94"
|
||||||
|
:item-margin="24"
|
||||||
|
:max-items-per-row="8"
|
||||||
>
|
>
|
||||||
{{ item.text }}
|
<template
|
||||||
</div>
|
slot="item"
|
||||||
|
slot-scope="ctx"
|
||||||
|
>
|
||||||
|
<shop-item
|
||||||
|
:item="ctx.item"
|
||||||
|
:key="ctx.item.key"
|
||||||
|
:price="ctx.item.value"
|
||||||
|
:price-type="ctx.item.currency"
|
||||||
|
:empty-item="false"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</item-rows>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -68,20 +93,27 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import shops from '@/../../common/script/libs/shops';
|
import shops from '@/../../common/script/libs/shops';
|
||||||
|
import throttle from 'lodash/throttle';
|
||||||
import { mapState } from '@/libs/store';
|
import { mapState } from '@/libs/store';
|
||||||
|
|
||||||
import Checkbox from '@/components/ui/checkbox';
|
import Checkbox from '@/components/ui/checkbox';
|
||||||
import FilterSidebar from '@/components/ui/filterSidebar';
|
|
||||||
import FilterGroup from '@/components/ui/filterGroup';
|
import FilterGroup from '@/components/ui/filterGroup';
|
||||||
|
import FilterSidebar from '@/components/ui/filterSidebar';
|
||||||
|
import ItemRows from '@/components/ui/itemRows';
|
||||||
|
import ShopItem from '../shopItem';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
Checkbox,
|
Checkbox,
|
||||||
FilterGroup,
|
FilterGroup,
|
||||||
FilterSidebar,
|
FilterSidebar,
|
||||||
|
ItemRows,
|
||||||
|
ShopItem,
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
searchText: null,
|
||||||
|
searchTextThrottled: null,
|
||||||
viewOptions: {},
|
viewOptions: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -99,7 +131,7 @@ export default {
|
|||||||
if (!currentEvent) {
|
if (!currentEvent) {
|
||||||
return {
|
return {
|
||||||
background: 'url(/static/npc/normal/market_background.png)',
|
background: 'url(/static/npc/normal/market_background.png)',
|
||||||
npc: 'url(/static/npc/normal/market_npc.png)',
|
npc: 'url(/static/npc/normal/market_banner_npc.png)',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@@ -131,11 +163,24 @@ export default {
|
|||||||
|| this.viewOptions[category.identifier].selected);
|
|| this.viewOptions[category.identifier].selected);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
// TODO mixin?
|
||||||
|
searchText: throttle(function throttleSearch () {
|
||||||
|
this.searchTextThrottled = this.searchText.toLowerCase();
|
||||||
|
}, 250),
|
||||||
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.$store.dispatch('common:setTitle', {
|
this.$store.dispatch('common:setTitle', {
|
||||||
subSection: this.$t('customizations'),
|
subSection: this.$t('customizations'),
|
||||||
section: this.$t('shops'),
|
section: this.$t('shops'),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
customizationsItems (options = {}) {
|
||||||
|
const { category, searchBy } = options;
|
||||||
|
return category.items.filter(item => !searchBy
|
||||||
|
|| item.text.toLowerCase().includes(searchBy));
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ export default {
|
|||||||
noItemsLabel: {
|
noItemsLabel: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
maxItemsPerRow: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
@@ -80,6 +83,9 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
itemsPerRow () {
|
itemsPerRow () {
|
||||||
|
if (this.maxItemsPerRow > 0) {
|
||||||
|
return this.maxItemsPerRow;
|
||||||
|
}
|
||||||
return Math.floor(this.currentWidth / (this.itemWidth + this.itemMargin));
|
return Math.floor(this.currentWidth / (this.itemWidth + this.itemMargin));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -559,42 +559,49 @@ shops.getCustomizationsShopCategories = function getCustomizationsShopCategories
|
|||||||
const hairColorsCategory = {
|
const hairColorsCategory = {
|
||||||
identifier: 'hairColors',
|
identifier: 'hairColors',
|
||||||
text: i18n.t('hairColors', language),
|
text: i18n.t('hairColors', language),
|
||||||
|
items: [],
|
||||||
};
|
};
|
||||||
categories.push(hairColorsCategory);
|
categories.push(hairColorsCategory);
|
||||||
|
|
||||||
const hairStylesCategory = {
|
const hairStylesCategory = {
|
||||||
identifier: 'hairStyles',
|
identifier: 'hairStyles',
|
||||||
text: i18n.t('hairStyles', language),
|
text: i18n.t('hairStyles', language),
|
||||||
|
items: [],
|
||||||
};
|
};
|
||||||
categories.push(hairStylesCategory);
|
categories.push(hairStylesCategory);
|
||||||
|
|
||||||
const skinsCategory = {
|
const skinsCategory = {
|
||||||
identifier: 'skins',
|
identifier: 'skins',
|
||||||
text: i18n.t('skins', language),
|
text: i18n.t('skins', language),
|
||||||
|
items: [],
|
||||||
};
|
};
|
||||||
categories.push(skinsCategory);
|
categories.push(skinsCategory);
|
||||||
|
|
||||||
const animalEarsCategory = {
|
const animalEarsCategory = {
|
||||||
identifier: 'animalEars',
|
identifier: 'animalEars',
|
||||||
text: i18n.t('animalEars', language),
|
text: i18n.t('animalEars', language),
|
||||||
|
items: [],
|
||||||
};
|
};
|
||||||
categories.push(animalEarsCategory);
|
categories.push(animalEarsCategory);
|
||||||
|
|
||||||
const animalTailsCategory = {
|
const animalTailsCategory = {
|
||||||
identifier: 'animalTails',
|
identifier: 'animalTails',
|
||||||
text: i18n.t('animalTails', language),
|
text: i18n.t('animalTails', language),
|
||||||
|
items: [],
|
||||||
};
|
};
|
||||||
categories.push(animalTailsCategory);
|
categories.push(animalTailsCategory);
|
||||||
|
|
||||||
const shirtsCategory = {
|
const shirtsCategory = {
|
||||||
identifier: 'shirts',
|
identifier: 'shirts',
|
||||||
text: i18n.t('shirts', language),
|
text: i18n.t('shirts', language),
|
||||||
|
items: [],
|
||||||
};
|
};
|
||||||
categories.push(shirtsCategory);
|
categories.push(shirtsCategory);
|
||||||
|
|
||||||
const facialHairCategory = {
|
const facialHairCategory = {
|
||||||
identifier: 'facialHair',
|
identifier: 'facialHair',
|
||||||
text: i18n.t('facialHairs', language),
|
text: i18n.t('facialHairs', language),
|
||||||
|
items: [],
|
||||||
};
|
};
|
||||||
categories.push(facialHairCategory);
|
categories.push(facialHairCategory);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user