Add application display switcher

This commit is contained in:
Oliver Davies 2018-12-24 08:46:33 +00:00
parent 0a28f22748
commit bdfba4fb78
3 changed files with 77 additions and 5 deletions

View file

@ -1,8 +1,8 @@
<template>
<div>
<div class="mb-6 bg-white p-4 border border-grey rounded">
<div v-if="display == 'grid'" class="bg-white p-4 border-grey rounded border">
<div class="flex flex-col h-full justify-between">
<div class="flex justify-between mb-12">
<div class="flex mb-12" :class="[display == 'grid' ? 'justify-between' : '']">
<div>
<div>
<router-link :to="{name: 'environments', params: {id: id}}" class="text-blue-dark no-underline hover:underline focus:underline"><h2 class="mb-1">{{ application.name }}</h2></router-link>
@ -22,6 +22,28 @@
<application-tags :type="application.type" :level="application.level"></application-tags>
</div>
</div>
<div v-if="display == 'list'" class="bg-white p-3 border-grey border-b">
<div class="flex flex-row-reverse items-center justify-between">
<div class="flex flex-1 justify-between">
<div class="flex-1">
<router-link :to="{name: 'environments', params: {id: id}}" class="text-blue-dark no-underline hover:underline focus:underline"><h2 class="text-base font-normal mb-1">{{ application.name }}</h2></router-link>
</div>
<application-tags :type="application.type" :level="application.level" class="w-1/5"></application-tags>
<div class="w-2/5">
<a href="#0" class="text-blue-dark no-underline hover:underline focus:underline">{{ application.environments['prod'].url }}</a>
</div>
</div>
<div class="mr-3">
<button type="button" @click="starred = !starred" class="focus:outline-none">
<svg class="h-6 w-6 text-orange fill-current" role="presentation"><use :xlink:href="`/img/icons.symbol.svg#state__${starred ? 'starred' : 'unstarred'}`"></use></svg>
</button>
</div>
</div>
</div>
</div>
</template>
@ -35,6 +57,7 @@ export default {
props: {
application: Object,
display: String,
id: Number,
},

View file

@ -0,0 +1,36 @@
<template>
<div>
<div class="bg-grey-lightest rounded overflow-hidden">
<button type="button" class="p-2 focus:outline-none" :class="[mode == 'grid' ? 'bg-blue-light text-white' : 'text-grey-darkest']" @click="changeMode('grid')">
<svg class="h-5 w-5 fill-current"role="presentation"><use xlink:href="/img/icons.symbol.svg#actions__grid"></use></svg>
<span class="hidden">Grid</span>
</button>
<button type="button" class="p-2 focus:outline-none" :class="[mode == 'list' ? 'bg-blue-light text-white' : 'text-grey-darkest']" @click="changeMode('list')">
<svg class="h-5 w-5 fill-current" role="presentation"><use xlink:href="/img/icons.symbol.svg#actions__list"></use></svg>
<span class="hidden">List</span>
</button>
</div>
</div>
</template>
<script>
export default {
props: {
mode: String,
},
// data() {
// return {
// mode: 'grid'
// }
// },
methods: {
changeMode(mode) {
this.mode = mode
this.$emit('display-changed', mode)
}
}
}
</script>

View file

@ -27,8 +27,10 @@
<h1 class="text-4xl font-hairline mb-2">Applications</h1>
</div>
<div class="lg:flex lg:flex-row-reverse flex-1 justify-between _bg-blue items-baseline">
<div class="w-full lg:w-1/2 xl:w-1/4">
<application-switcher class="flex-1 flex justify-end mr-3" :mode="display" @display-changed="handleDisplay"></application-switcher>
<div class="lg:flex lg:flex-row-reverse justify-between items-baseline">
<div class="w-full">
<form action="#">
<input type="text" placeholder="Filter applications" class="w-full py-2 px-3 border border-grey-darker rounded">
</form>
@ -43,7 +45,9 @@
:id="application.id"
:application="application"
:key="application.id"
class="px-3 w-full lg:w-1/3"
:display="display"
class="px-3 w-full"
:class="[display == 'grid' ? 'lg:w-1/3 mb-6 rounded' : '']"
></application-card>
</div>
</div>
@ -78,17 +82,26 @@
<script>
import ApplicationCard from '@/components/ApplicationCard'
import ApplicationSwitcher from '@/components/ApplicationSwitcher'
import data from '@/data.json'
export default {
components: {
ApplicationCard,
ApplicationSwitcher,
},
data() {
return {
applications: data.applications,
display: 'grid',
}
},
methods: {
handleDisplay(mode) {
this.display = mode
}
}
}
</script>