Compare commits

...

2 Commits

Author SHA1 Message Date
Kevin
75bb55a6a3 🎨 Simplify search.vue & minor changes 2019-11-15 18:27:34 +01:00
Kevin
5388f2fe44 🎨 Simplify toggling between views 2019-11-15 17:56:44 +01:00
4 changed files with 47 additions and 23 deletions

13
components/CardsView.vue Normal file
View File

@@ -0,0 +1,13 @@
<template lang="pug">
.cards
Card(v-for='resource in resources' :resource='resource' :key='resource.title' :createCopyUrl="createCopyUrl" :isActive='activeCard === resource.cleanTitle')
</template>
<script>
import Card from './Card'
export default {
components: { Card },
props: ['resources', 'createCopyUrl', 'activeCard'],
}
</script>

13
components/TableView.vue Normal file
View File

@@ -0,0 +1,13 @@
<template lang="pug">
table
TableRow(v-for='resource in resources' :resource='resource' :key='resource.title' :createCopyUrl="createCopyUrl" :isActive='activeCard === resource.cleanTitle')
</template>
<script>
import TableRow from '../components/TableRow'
export default {
components: { TableRow },
props: ['resources', 'createCopyUrl', 'activeCard'],
}
</script>

View File

@@ -3,21 +3,21 @@
transition(name="fade-title" @after-enter="afterEnter")
h1(v-if="showTitle") {{ category.title }}
transition(name="fade-card")
.cards(v-if="areCardsVisible && showCards")
template(v-for='resource in category.resources' )
Card(:resource='resource' :key='resource.title' :createCopyUrl="createCopyUrl" :isActive='activeCard === resource.cleanTitle')
transition(name="fade-card")
table(v-if="!areCardsVisible && showCards")
template(v-for='resource in category.resources' )
TableRow(:resource='resource' :key='resource.title' :createCopyUrl="createCopyUrl" :isActive='activeCard === resource.cleanTitle')
div(v-if="showCards")
component(
:is="areCardsVisible ? 'CardsView' : 'TableView'"
:resources="category.resources"
:createCopyUrl="createCopyUrl"
:activeCard='activeCard'
)
</template>
<script>
import Card from '../components/Card'
import TableRow from '../components/TableRow'
import CardsView from '../components/CardsView'
import TableView from '../components/TableView'
export default {
components: { Card, TableRow },
components: { CardsView, TableView },
data() {
return {
categoryRouteTitle: this.$route.params.category,

View File

@@ -3,26 +3,24 @@
transition(name="fade-title" @after-enter="afterEnter")
h1(v-if="showTitle") Search
transition(name="fade-card")
.cards(v-if="areCardsVisible && showCards")
template(v-if="resources.length")
template(v-for='resource in resources' )
Card(:resource='resource' :key='resource.title' :createCopyUrl="createCopyUrl" :isActive='activeCard === resource.cleanTitle')
p(v-else) No results
transition(name="fade-card")
table(v-if="!areCardsVisible && showCards")
template(v-if="resources.length")
template(v-for='resource in resources' )
TableRow(:resource='resource' :key='resource.title' :createCopyUrl="createCopyUrl" :isActive='activeCard === resource.cleanTitle')
div(showCards)
component(
v-if="resources.length"
:is="areCardsVisible ? 'CardsView' : 'TableView'"
:createCopyUrl="createCopyUrl"
:activeCard="activeCard"
:resources="resources"
)
p(v-else) No results
</template>
<script>
import Card from '../components/Card'
import TableRow from '../components/TableRow'
import CardsView from '../components/CardsView'
import TableView from '../components/TableView'
import * as R from 'ramda'
export default {
components: { Card, TableRow },
components: { CardsView, TableView },
data() {
return {
activeCard: '',