gamebrary/src/components/Board/PinnedBoards.vue

109 lines
2.6 KiB
Vue
Raw Normal View History

2021-01-25 21:05:35 +00:00
<template lang="html">
<div>
<span
v-for="{ id, name, backgroundColor, wallpaper } in pinnedBoards"
:key="id"
>
<b-avatar
rounded
2021-02-18 23:07:45 +00:00
:class="[ 'mb-1 cursor-pointer pinned-board', { active: board.name === name }]"
2021-01-25 21:05:35 +00:00
:title="name"
@click.native="viewBoard(id)"
:style="`
${backgroundColor ? `background-color: ${backgroundColor};` : null }
${getWallpaperUrl(wallpaper) }
`"
>
<span class="board-initials text-uppercase">{{ getBoardInitials(name) }}</span>
</b-avatar>
2021-01-25 21:05:35 +00:00
</span>
<hr class="mt-1 mb-2">
2021-02-01 23:20:41 +00:00
<b-avatar
v-if="isBoard && !board.pinned"
rounded
2021-02-18 23:07:45 +00:00
class="active pinned-board"
2021-02-01 23:20:41 +00:00
:title="board.name"
:style="`
${board.backgroundColor ? ` background-color: ${board.backgroundColor};` : null }
${getWallpaperUrl(board.wallpaper) }
`"
2021-02-03 23:38:37 +00:00
@click.native="$bvModal.show('edit-board')"
2021-02-01 23:20:41 +00:00
>
<span class="board-initials text-uppercase mr-1">
{{ getBoardInitials(board.name) }}
</span>
</b-avatar>
2021-01-25 21:05:35 +00:00
</div>
</template>
<script>
import { mapGetters, mapState } from 'vuex';
export default {
computed: {
...mapState(['board', 'boards', 'wallpapers']),
...mapGetters(['sortedBoards', 'nightMode']),
isBoard() {
return ['public-board', 'board'].includes(this.$route.name);
},
hasMultipleBoards() {
return this.$route.name === 'board' && this.board.name && this.sortedBoards.length > 1;
},
pinnedBoards() {
return this.boards.filter(({ pinned }) => pinned);
},
},
methods: {
getWallpaperUrl(wallpaper) {
const wallpaperObject = wallpaper && this.wallpapers.length
? this.wallpapers.find(({ fullPath }) => fullPath === wallpaper)
: null;
return wallpaperObject && wallpaperObject.url
? `background-image: url(${wallpaperObject.url});`
: null;
},
viewBoard(id) {
if (this.board.id !== id) {
this.$router.push({ name: 'board', params: { id } });
2021-02-03 23:38:37 +00:00
} else {
this.$bvModal.show('edit-board');
2021-01-25 21:05:35 +00:00
}
},
getBoardInitials(boardName) {
const boardInitials = boardName
? boardName.split(' ').map(n => n[0]).join('')
: '';
return boardInitials.length > 2
? boardInitials.substring(0, 2)
: boardInitials;
},
},
};
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
.pinned-board {
background-size: cover;
2021-02-01 23:20:41 +00:00
2021-02-18 23:07:45 +00:00
&.active {
box-shadow: inset 0 0 0 2px black;
2021-02-01 23:20:41 +00:00
}
2021-01-25 21:05:35 +00:00
}
2021-01-25 23:45:12 +00:00
.board-initials {
color: white;
text-shadow: 1px 1px black;
}
2021-02-01 19:31:15 +00:00
2021-01-25 21:05:35 +00:00
</style>