use isotope layout in boards

This commit is contained in:
Gamebrary 2021-04-06 17:02:09 -07:00
parent 6da87733b4
commit 34a4b83d60
3 changed files with 50 additions and 45 deletions

View file

@ -28,6 +28,7 @@
"lodash.orderby": "^4.6.0", "lodash.orderby": "^4.6.0",
"lodash.sortby": "^4.7.0", "lodash.sortby": "^4.7.0",
"node-sass": "^4.8.3", "node-sass": "^4.8.3",
"packery": "^2.1.2",
"portal-vue": "^2.1.7", "portal-vue": "^2.1.7",
"raven-js": "^3.27.0", "raven-js": "^3.27.0",
"sass-loader": "^7.0.1", "sass-loader": "^7.0.1",

View file

@ -1,7 +1,8 @@
<template lang="html"> <template lang="html">
<div <div
class="mini-board p-1 rounded" class="mini-board p-1 rounded cursor-pointer"
:style="miniBoardStyles" :style="miniBoardStyles"
@click="$emit('view-board', board.id)"
> >
<small :class="{ 'has-background' : miniBoardStyles }"> <small :class="{ 'has-background' : miniBoardStyles }">
<i <i
@ -17,24 +18,23 @@
</template> </template>
</small> </small>
<slot />
<div class="lists rounded overflow-hidden"> <div class="lists rounded overflow-hidden">
<div <div
v-for="list in board.lists" v-for="list in board.lists"
:key="list.name" :key="list.name"
class="rounded overflow-hidden list" class="rounded overflow-hidden list"
> >
<div v-if="list.games.length" :title="list.name"> <template v-if="list.games.length">
<div <div
v-for="game in list.games" v-for="(game, index) in list.games"
:key="game" :key="game"
class="bg-light border-bottom" :class="['bg-light border-bottom ', { 'rounded-bottom': index === list.games.length - 1 }]"
> >
<i <i class="fas fa-square fa-fw text-muted" style="margin-left: 1px;" aria-hidden />
class="fas fa-ellipsis-h text-secondary ml-1"
aria-hidden
/>
</div>
</div> </div>
</template>
<div <div
v-else v-else
@ -73,13 +73,16 @@ export default {
</script> </script>
<style lang="scss" rel="stylesheet/scss" scoped> <style lang="scss" rel="stylesheet/scss" scoped>
$boardHeight: 180px; $boardHeight: 216px;
$boardWidth: 374.5px;
.mini-board { .mini-board {
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: cover; background-size: cover;
background-color: #ccc; background-color: #ccc;
height: $boardHeight; height: $boardHeight;
width: $boardWidth;
max-width: 100%;
.has-background { .has-background {
text-shadow: 1px 1px black; text-shadow: 1px 1px black;

View file

@ -1,18 +1,7 @@
<template lang="html"> <template lang="html">
<div class="mx-2 mb-2" v-if="user"> <div class="mx-2 mb-2" v-if="user">
<!-- TODO: add isotope layout -->
<!-- TODO: allow reorganizing and save --> <!-- TODO: allow reorganizing and save -->
<!-- TODO: show public boards --> <!-- TODO: show public boards -->
<div v-if="showPlaceholder" class="boards">
<b-card
v-for="n in 3"
:key="n"
no-body
class="mb-3 p-1 mt-3"
>
<b-skeleton-img />
</b-card>
</div>
<empty-state <empty-state
v-if="!loading && sortedBoards.length === 0" v-if="!loading && sortedBoards.length === 0"
@ -36,40 +25,49 @@
</b-button> </b-button>
</portal> </portal>
<div class="boards"> <div class="packery-grid">
<div v-if="showPlaceholder">
Loading
</div>
<!-- <div v-if="">
<b-card <b-card
v-for="n in 3"
:key="n"
no-body
class="mb-3 p-1 mt-3"
>
<b-skeleton-img />
</b-card>
</div> -->
<mini-board
v-for="board in sortedBoards" v-for="board in sortedBoards"
:key="board.id" :key="board.id"
no-body
:bg-variant="darkTheme ? 'dark' : null"
:text-variant="darkTheme ? 'white' : null"
class="overflow-hidden clickable position-relative"
@click="viewBoard(board.id)"
>
<mini-board
:board="board" :board="board"
:background-image="getWallpaperUrl(board.backgroundUrl)" :background-image="getWallpaperUrl(board.backgroundUrl)"
/> class="p-relative"
@view-board="viewBoard(board.id)"
>
<b-button <b-button
class="position-absolute edit-board-button" class="position-absolute edit-board-button"
:variant="darkTheme ? 'info' : 'light'" :variant="darkTheme ? 'info' : 'outline-light'"
size="sm" size="sm"
@click.stop="editBoard(board)" @click.stop="editBoard(board)"
> >
<i class="fas fa-edit fa-fw" aria-hidden /> <i class="fas fa-pencil-alt fa-fw" aria-hidden />
</b-button> </b-button>
</b-card> </mini-board>
</div>
<edit-board-modal /> <edit-board-modal />
</div> </div>
</div>
</template> </template>
<script> <script>
import MiniBoard from '@/components/Board/MiniBoard'; import MiniBoard from '@/components/Board/MiniBoard';
import EditBoardModal from '@/components/Board/EditBoardModal'; import EditBoardModal from '@/components/Board/EditBoardModal';
import EmptyState from '@/components/EmptyState'; import EmptyState from '@/components/EmptyState';
import Packery from 'packery';
import { mapState, mapGetters } from 'vuex'; import { mapState, mapGetters } from 'vuex';
export default { export default {
@ -82,6 +80,7 @@ export default {
data() { data() {
return { return {
loading: false, loading: false,
packery: null,
}; };
}, },
@ -104,6 +103,7 @@ export default {
methods: { methods: {
load() { load() {
this.renderGrid();
this.loadPlatforms(); this.loadPlatforms();
}, },
@ -155,6 +155,13 @@ export default {
}); });
this.loading = false; this.loading = false;
this.renderGrid();
},
renderGrid() {
this.packery = this.showPlaceholder && this.user
? null
: new Packery('.packery-grid', { itemSelector: '.mini-board', gutter: 8 });
}, },
viewBoard(id) { viewBoard(id) {
@ -179,14 +186,8 @@ export default {
</script> </script>
<style lang="scss" rel="stylesheet/scss" scoped> <style lang="scss" rel="stylesheet/scss" scoped>
.boards {
display: grid;
grid-gap: 1rem;
grid-template-columns: repeat(auto-fit, 320px);
}
.edit-board-button { .edit-board-button {
right: .5rem; right: .5rem;
bottom: .5rem; top: .5rem;
} }
</style> </style>