habitica/website/client/components/guilds/publicGuildItem.vue

145 lines
3.9 KiB
Vue
Raw Normal View History

New client guilds (#8736) * 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 * Start of guild syyles * fix linting in test/client * fix es6 compilation in test/client * fix babel compilation for tests * fix groupsUtilities mixin tests * More designs * Added public guild state * Added my guilds store * client: buttons * client: buttons: fix colors * Added join and leave * Began adding new guild form * Create form updates * Added search to local data * Added filtering * Added initial code for group create * Added more create checks * Added more guild routes * Added styles to guild page * Added more chat styles * Began porting over angular functions * Moved over group service functions * Added paging * Updated sidebar * Updated join/leave and minor text * Added new sidebar functions * Updated paging * Added some form updates * Added more translations and styles * Updated shrinkwrap * Removed features config * Lint cleanup * Added member modal * Added more member actions * Updated nav * Fixed filter toggling * Updated create guild * Added no guild page * Added sort select * Added more styles * Added update guild form * Removed extra css and other minor changes * Many css and syntax fixes * Fixed color and merge conflic * Removed paging from my guilds * Removed extra strings * Many requests updates * Small style fixes
2017-06-02 20:55:02 +00:00
<template lang="pug">
.card
.card-block
.row
.col-md-2
img.icon.shield(src="~assets/guilds/gold-guild-badge.svg")
.member-count {{guild.memberCount}}
.col-md-10
.row
.col-md-8
router-link(:to="{ name: 'guild', params: { guildId: guild._id } }")
h3 {{ guild.name }}
p {{ guild.description }}
.col-md-2.cta-container
button.btn.btn-danger(v-if='isMember && displayLeave' @click='leave()', v-once) {{ $t('leave') }}
button.btn.btn-success(v-if='!isMember' @click='join()', v-once) {{ $t('join') }}
div.item-with-icon(v-if='displayGemBank')
img(src="~assets/guilds/green-gem.svg")
span.count {{ guild.balance }}
div.guild-bank(v-if='displayGemBank', v-once) {{$t('guildBank')}}
.row
.col-md-12
.category-label(v-for="category in guild.categories")
| {{category}}
span.recommend-text Suggested because youre new to Habitica.
</template>
<style lang="scss" scoped>
@import '~client/assets/scss/colors.scss';
.card {
height: 260px;
border-radius: 4px;
background-color: $white;
box-shadow: 0 2px 2px 0 rgba($black, 0.15), 0 1px 4px 0 rgba($black, 0.1);
margin-bottom: 1rem;
.category-label {
min-width: 100px;
border-radius: 100px;
background-color: $gray-600;
padding: .5em;
display: inline-block;
margin-right: .5em;
font-size: 12px;
font-weight: 500;
line-height: 1.33;
text-align: center;
color: $gray-300;
}
.recommend-text {
font-size: 12px;
font-style: italic;
line-height: 2;
color: $gray-300;
}
.cta-container {
margin: 0 auto;
margin-top: 4em;
}
.shield {
width: 70px;
height: 76px;
margin: auto;
margin: 4em auto;
display: block;
background-size: cover;
width: 100%;
height: 100px;
}
.item-with-icon {
img {
height: 37px;
}
.count {
font-size: 20px;
height: 37px;
width: 37px;
margin-left: .2em;
}
}
.guild-bank {
font-size: 12px;
line-height: 1.33;
color: $gray-300;
}
.member-count {
position: relative;
top: -3.6em;
left: -.1em;
font-size: 28px;
font-weight: bold;
font-family: 'Roboto Condensed';
line-height: 1.2;
text-align: center;
color: #b36213;
}
}
</style>
<script>
import { mapState } from 'client/libs/store';
import groupUtilities from 'client/mixins/groupsUtilities';
import findIndex from 'lodash/findIndex';
export default {
mixins: [groupUtilities],
props: ['guild', 'displayLeave', 'displayGemBank'],
computed: {
...mapState({user: 'user.data'}),
isMember () {
return this.isMemberOfGroup(this.user, this.guild);
},
},
methods: {
async join () {
// @TODO: This needs to be in the notifications where users will now accept invites
if (this.guild.cancelledPlan && !confirm(window.env.t('aboutToJoinCancelledGroupPlan'))) {
return;
}
await this.$store.dispatch('guilds:join', {guildId: this.guild._id, type: 'myGuilds'});
},
async leave () {
// @TODO: ask about challenges when we add challenges
await this.$store.dispatch('guilds:leave', {guildId: this.guild._id, type: 'myGuilds'});
},
async reject (invitationToReject) {
// @TODO: This needs to be in the notifications where users will now accept invites
let index = findIndex(this.user.invitations.guilds, function findInviteIndex (invite) {
return invite.id === invitationToReject.id;
});
this.user.invitations.guilds = this.user.invitations.guilds.splice(0, index);
await this.$store.dispatch('guilds:rejectInvite', {guildId: invitationToReject.id});
},
},
};
</script>