Files
habitica/website/client/components/avatar.vue
Matteo Pagliazzi 0af1203832 Client Redesign: Inventory pages, secondary menu, misc css and design items (#8631)
* add colors palette

* add secondary menu component and style it

* add box shadow to secondary menu

* misc css, fixes for secondary menu

* client: add equipment page with grouping, css: add some styles

* add typography

* more equipment

* stable: fix linting

* equipment: add styles (lots of general styles too)

* remove duplicate google fonts loading

* add dropdowns

* design: white search input background, remove gray from items

* start adding drawer and selected indicator

* wip equipment

* fix equipment

* equipment: correctly bind new properties on items.gear.equipped

* equipment: fix vue binding. version 2

* equipment: fix vue binding. version 3

* back to first fix for equip op, fix for sourcemaps, send http request when an item is equipped, load bootstrap-vue components where needed

* checkboxes and radio buttons

* correctly renders selected items in first postion during the first render

* add search

* general changes, constants part of app state, add popovers

* add toggle switch, rename css

* correct offset

* upgrade deps

* upgrade deps

* drawer and lot of other work

* update equipping mechanism

* finish equipment

* fix compilation and upgrade deps

* use v-show in place of v-if to fix ui issues

* v-show -> v-if

* fix linting in test/client

* fix es6 compilation in test/client

* fix babel compilation for tests

* fix groupsUtilities mixin tests

* client: buttons

* client: buttons: fix colors

* client: finish buttons and dropdowns

* upgrade bootstrap-vue, finish buttons and dropdowns

* fix tasks page layout

* misc fixes for buttons

* add textareas

* fix app menu

* add inputs

* fixes for toggleSwitch

* typography

* checkboxes and radio buttons

* add checkbox icon

* fix equip.js

* extract strings to newClient.json

* add Popover above 'Use Costume' / 'Auto Equip' slider - disable item select if costume-mode and 'useCostume' isn't active

* show "you have disabled your costume" error above the drawer items

* check errorMessage for null

* hide star if costume not enabled

* fix errorMessage (!errorMessage seems not to work for string)

* show minimize / expand icon - always centered by css

* drawer test

* drawer: fix centering on large screens

* fix show more button

* add margin when two dropdowns are next to each other

* adjust the page padding based on the drawer, misc fixes

* drawer fixes
2017-05-16 21:09:55 +02:00

126 lines
3.6 KiB
Vue

<template lang="pug">
.avatar(:style="{width, height, paddingTop}", :class="backgroundClass")
.character-sprites
template(v-if="!avatarOnly" v-once)
// Mount
span(v-if="user.items.currentMount", :class="'Mount_Body_' + user.items.currentMount")
// Buffs that cause visual changes to avatar: Snowman, Ghost, Flower, etc
template(v-for="(klass, item) in visualBuffs")
span(v-if="user.stats.buffs[item]", :class="klass")
// Show flower ALL THE TIME!!!
// See https://github.com/HabitRPG/habitrpg/issues/7133
span(:class="'hair_flower_' + user.preferences.hair.flower")
// Show avatar only if not currently affected by visual buff
template(v-if!="!user.stats.buffs.snowball && !user.stats.buffs.spookySparkles && !user.stats.buffs.shinySeed && !user.stats.buffs.seafoam")
span(:class="'chair_' + user.preferences.chair")
span(:class="user.items.gear[costumeClass].back")
span(:class="skinClass")
span(:class="user.preferences.size + '_shirt_' + user.preferences.shirt")
span(:class="user.preferences.size + '_' + user.items.gear[costumeClass].armor")
span(:class="user.items.gear[costumeClass].back_collar")
span(:class="user.items.gear[costumeClass].body")
span.head_0
template(v-for="type in ['base', 'bangs', 'mustache', 'beard']")
span(:class="'hair_' + type + '_' + user.preferences.hair[type] + '_' + user.preferences.hair.color")
span(:class="user.items.gear[costumeClass].eyewear")
span(:class="user.items.gear[costumeClass].head")
span(:class="user.items.gear[costumeClass].headAccessory")
span(:class="'hair_flower_' + user.preferences.hair.flower")
span(:class="user.items.gear[costumeClass].shield")
span(:class="user.items.gear[costumeClass].weapon")
// Resting
span.zzz(v-if="user.preferences.sleep")
template(v-if="!avatarOnly" v-once)
// Mount Head
span(v-if="user.items.currentMount", :class="'Mount_Head_' + user.items.currentMount")
// Pet
span.current-pet(v-if="user.items.currentPet", :class="'Pet-' + user.items.currentPet")
</template>
<style scoped>
.avatar {
width: 140px;
height: 147px;
image-rendering: pixelated;
}
.character-sprites {
margin: 0 auto;
width: 90px;
height: 90px;
}
.character-sprites span {
position: absolute;
}
.current-pet {
bottom: 21px;
left: 20px;
}
</style>
<script>
export default {
props: {
user: {
type: Object,
required: true,
},
avatarOnly: {
type: Boolean,
default: false,
},
width: {
type: Number,
default: 140,
},
height: {
type: Number,
default: 147,
},
},
computed: {
paddingTop () {
let val = '28px';
if (!this.avatarOnly) {
if (this.user.items.currentPet) val = '24.5px';
if (this.user.items.currentMount) val = '0px';
}
return val;
},
backgroundClass () {
let background = this.user.preferences.background;
if (background && !this.avatarOnly) {
return `background_${this.user.preferences.background}`;
}
return '';
},
visualBuffs () {
return {
snowball: 'snowman',
spookySparkles: 'ghost',
shinySeed: `avatar_floral_${this.user.stats.class}`,
seafoam: 'seafoam_star',
};
},
skinClass () {
let baseClass = `skin_${this.user.preferences.skin}`;
return `${baseClass}${this.user.preferences.sleep ? '_sleep' : ''}`;
},
costumeClass () {
return this.user.preferences.costume ? 'costume' : 'equipped';
},
},
};
</script>