cookbook view refactored, minor ui fixes
This commit is contained in:
@ -1,53 +1,43 @@
|
||||
<template>
|
||||
<div v-bind:style="{ backgroundImage: 'url(' + book_background + ')' }"
|
||||
style="background-repeat: no-repeat; background-size: cover; padding-top: 76%;position: relative;"
|
||||
class="pb-2 w-100">
|
||||
<div id="book_carousel" class="carousel slide" data-interval="0"
|
||||
style=" position: absolute;top: 0;left: 0;bottom: 0;right: 0;">
|
||||
<div class="row m-0 pl-4 pr-4 pt-5 w-100" style="height: 15vh">
|
||||
<a class="mb-3 col-6 pull-left" href="#book_carousel" role="button" data-slide="prev">
|
||||
</a>
|
||||
<a class="mb-3 col-6 text-right" href="#book_carousel" role="button" data-slide="next">
|
||||
</a>
|
||||
<div v-bind:class="{ bounceright: bounce_right, bounceleft: bounce_left }">
|
||||
<div class="row">
|
||||
<div class="col col-md-12 text-center pt-2 pb-4">
|
||||
<b-pagination pills
|
||||
v-model="current_page"
|
||||
:total-rows="page_count_pagination"
|
||||
:per-page="per_page_count"
|
||||
@change="pageChange"
|
||||
first-text="📖"
|
||||
align="fill">
|
||||
|
||||
</b-pagination>
|
||||
</div>
|
||||
<div class="row m-0 w-100 pt-2">
|
||||
<div class="carousel-item w-100 active">
|
||||
<div class="row m-0 w-100">
|
||||
<div class="col-6">
|
||||
<b-card no-body v-hover class="ml-5 mr-5">
|
||||
<b-card-header class="p-4">
|
||||
<h5>{{ book.name }} <span class="pull-right">{{ book.icon }}</span></h5>
|
||||
</b-card-header>
|
||||
<b-card-body class="p-4">
|
||||
<b-card-text style="text-overflow: ellipsis;">
|
||||
{{ book.description }}
|
||||
</b-card-text>
|
||||
</b-card-body>
|
||||
</b-card>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<b-card no-body v-hover class="ml-5 mr-5">
|
||||
<b-card-header class="p-4">
|
||||
<h5>{{ $t('TableOfContents') }}</h5>
|
||||
</b-card-header>
|
||||
<b-card-body class="p-4">
|
||||
<ol>
|
||||
<li v-for="recipe in recipes" v-bind:key="recipe.name">
|
||||
{{ recipe.recipe_content.name }}
|
||||
</li>
|
||||
</ol>
|
||||
</b-card-body>
|
||||
</b-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="carousel-item w-100" v-for="(i, index) in Math.ceil(recipes.length / 2)" v-bind:key="index">
|
||||
<div class="row m-0 w-100">
|
||||
<div class="col-6" v-for="recipe in recipes.slice((i - 1) * 2, i * 2)" v-bind:key="recipe.id">
|
||||
<recipe-card :recipe="recipe.recipe_content" class="ml-5 mr-5"></recipe-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" v-touch:swipe.left="swipeLeft" v-touch:swipe.right="swipeRight">
|
||||
<div class="col-md-1" @click="swipeRight" style="cursor: pointer;">
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<transition name="flip" mode="out-in">
|
||||
<cookbook-edit-card :book="book" v-if="current_page === 1"
|
||||
v-on:editing="cookbook_editing = $event"></cookbook-edit-card>
|
||||
</transition>
|
||||
<transition name="flip" mode="out-in">
|
||||
<recipe-card :recipe="display_recipes[0].recipe_content"
|
||||
v-if="current_page > 1" :key="display_recipes[0]"></recipe-card>
|
||||
</transition>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<transition name="flip" mode="out-in">
|
||||
<cookbook-toc :recipes="recipes" v-if="current_page === 1"
|
||||
v-on:switchRecipe="switchRecipe($event)"></cookbook-toc>
|
||||
</transition>
|
||||
<transition name="flip">
|
||||
<recipe-card :recipe="display_recipes[1].recipe_content"
|
||||
v-if="current_page > 1 && display_recipes.length === 2" :key="display_recipes[1]"></recipe-card>
|
||||
</transition>
|
||||
</div>
|
||||
<div class="col-md-1" @click="swipeLeft" style="cursor: pointer;">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -56,18 +46,67 @@
|
||||
<script>
|
||||
|
||||
import RecipeCard from "./RecipeCard";
|
||||
import CookbookEditCard from "./CookbookEditCard";
|
||||
import CookbookToc from "./CookbookToc";
|
||||
import Vue2TouchEvents from "vue2-touch-events"
|
||||
import Vue from "vue";
|
||||
|
||||
Vue.use(Vue2TouchEvents)
|
||||
|
||||
export default {
|
||||
name: "CookbookSlider.vue",
|
||||
components: {RecipeCard},
|
||||
components: {CookbookToc, CookbookEditCard, RecipeCard},
|
||||
props: {
|
||||
recipes: Array,
|
||||
book: Object
|
||||
},
|
||||
computed: {
|
||||
page_count_pagination: function () {
|
||||
return this.recipes.length + 2
|
||||
},
|
||||
page_count: function () {
|
||||
return Math.ceil(this.page_count_pagination / this.per_page_count)
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
cookbooks: [],
|
||||
book_background: window.IMAGE_BOOK
|
||||
display_recipes: [],
|
||||
current_page: 1,
|
||||
per_page_count: 2,
|
||||
bounce_left: false,
|
||||
bounce_right: false,
|
||||
cookbook_editing: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
pageChange: function (page) {
|
||||
this.current_page = page
|
||||
this.display_recipes = this.recipes.slice(((this.current_page - 1) - 1) * 2, (this.current_page - 1) * 2)
|
||||
},
|
||||
swipeLeft: function () {
|
||||
if (this.cookbook_editing) {
|
||||
return
|
||||
}
|
||||
if (this.current_page < this.page_count) {
|
||||
this.pageChange(this.current_page + 1)
|
||||
} else {
|
||||
this.bounce_left = true
|
||||
setTimeout(() => this.bounce_left = false, 500);
|
||||
}
|
||||
},
|
||||
swipeRight: function () {
|
||||
if (this.cookbook_editing) {
|
||||
return
|
||||
}
|
||||
if (this.current_page > 1) {
|
||||
this.pageChange(this.current_page - 1)
|
||||
} else {
|
||||
this.bounce_right = true
|
||||
setTimeout(() => this.bounce_right = false, 500);
|
||||
}
|
||||
},
|
||||
switchRecipe: function (index) {
|
||||
this.pageChange(Math.ceil((index + 1) / this.per_page_count) + 1)
|
||||
}
|
||||
},
|
||||
directives: {
|
||||
@ -86,5 +125,96 @@ export default {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.flip-enter-active {
|
||||
-webkit-animation-name: bounceUp;
|
||||
animation-name: bounceUp;
|
||||
-webkit-animation-duration: .5s;
|
||||
animation-duration: .5s;
|
||||
-webkit-animation-fill-mode: both;
|
||||
animation-fill-mode: both;
|
||||
-webkit-animation-timing-function: linear;
|
||||
animation-timing-function: linear;
|
||||
animation-iteration-count: infinite;
|
||||
-webkit-animation-iteration-count: infinite;
|
||||
}
|
||||
|
||||
.bounceleft {
|
||||
-webkit-animation-name: bounceLeft;
|
||||
animation-name: bounceLeft;
|
||||
-webkit-animation-duration: .5s;
|
||||
animation-duration: .5s;
|
||||
-webkit-animation-fill-mode: both;
|
||||
animation-fill-mode: both;
|
||||
-webkit-animation-timing-function: linear;
|
||||
animation-timing-function: linear;
|
||||
animation-iteration-count: 1;
|
||||
-webkit-animation-iteration-count: 1;
|
||||
}
|
||||
|
||||
.bounceright {
|
||||
-webkit-animation-name: bounceRight;
|
||||
animation-name: bounceRight;
|
||||
-webkit-animation-duration: .5s;
|
||||
animation-duration: .5s;
|
||||
-webkit-animation-fill-mode: both;
|
||||
animation-fill-mode: both;
|
||||
-webkit-animation-timing-function: linear;
|
||||
animation-timing-function: linear;
|
||||
animation-iteration-count: 1;
|
||||
-webkit-animation-iteration-count: 1;
|
||||
}
|
||||
|
||||
@-webkit-keyframes bounceUp {
|
||||
0%, 100% {
|
||||
-webkit-transform: translateY(0);
|
||||
}
|
||||
50% {
|
||||
-webkit-transform: translateY(-7px);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bounceUp {
|
||||
0%, 100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-7px);
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes bounceLeft {
|
||||
0%, 100% {
|
||||
-webkit-transform: translateY(0);
|
||||
}
|
||||
50% {
|
||||
-webkit-transform: translateX(-10px);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bounceLeft {
|
||||
0%, 100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
50% {
|
||||
transform: translateX(-10px);
|
||||
}
|
||||
}
|
||||
|
||||
@-webkit-keyframes bounceRight {
|
||||
0%, 100% {
|
||||
-webkit-transform: translateY(0);
|
||||
}
|
||||
50% {
|
||||
-webkit-transform: translateX(10px);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bounceRight {
|
||||
0%, 100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
50% {
|
||||
transform: translateX(10px);
|
||||
}
|
||||
}
|
||||
</style>
|
Reference in New Issue
Block a user