<template>
  <div class="app-container">
    <transition name="el-zoom-in-center">
      <post-list v-if="options.showList" @showCard="showCard"></post-list>
    </transition>
    <transition name="el-zoom-in-top">
      <post-add v-if="options.showAdd" @showCard="showCard"></post-add>
    </transition>
    <transition name="el-zoom-in-top">
      <post-edit v-if="options.showEdit" :id="options.id" @showCard="showCard"></post-edit>
    </transition>
    <transition name="el-zoom-in-bottom">
      <post-detail v-if="options.showDetail" :id="options.id" @showCard="showCard"></post-detail>
    </transition>
  </div>
</template>

<script>
import PostList from './PostList'
import PostAdd from './PostAdd'
import PostEdit from './PostEdit'
import PostDetail from './PostDetail'

export default {
  name: 'Post',
  components: { PostList, PostAdd, PostEdit, PostDetail },
  data () {
    return {
      options: {
        id: undefined,
        showList: true,
        showAdd: false,
        showEdit: false,
        showDetail: false
      }
    }
  },
  methods: {
    showCard (data) {
      Object.assign(this.options, data);
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
