Extract star/unstar button

This commit is contained in:
Oliver Davies 2018-12-26 13:37:23 +00:00
parent 838bb6b136
commit 7e1e2c0bd3
2 changed files with 18 additions and 8 deletions

View file

@ -17,10 +17,7 @@
</div>
<div class="flex-none w-1/6 text-right">
<button type="button" @click="starred = !starred" class="focus:outline-none" :class="[starred ? 'text-orange hover:text-orange-light focus:text-orange-light' : 'text-grey focus:text-orange hover:text-orange']">
<span class="visuallyhidden">{{ !starred ? 'Star' : 'Unstar' }} {{ application.name }}</span>
<svg class="h-6 w-6 fill-current" role="presentation"><use :xlink:href="`/img/icons.symbol.svg#state__${starred ? 'starred' : 'unstarred'}`"></use></svg>
</button>
<star-toggle :application="application"></star-toggle>
</div>
</div>
</div>
@ -41,10 +38,7 @@
</div>
<div class="px-2">
<button type="button" @click="starred = !starred" class="focus:outline-none" :class="[starred ? 'text-orange hover:text-orange-light focus:text-orange-light' : 'text-grey focus:text-orange hover:text-orange']">
<span class="visuallyhidden">{{ !starred ? 'Star' : 'Unstar' }} {{ application.name }}</span>
<svg class="h-6 w-6 fill-current" role="presentation"><use :xlink:href="`/img/icons.symbol.svg#state__${starred ? 'starred' : 'unstarred'}`"></use></svg>
</button>
<star-toggle :application="application"></star-toggle>
</div>
</div>
</div>
@ -54,10 +48,12 @@
<script>
import ApplicationTags from '@/components/Application/ApplicationTags'
import StarToggle from '@/components/Application/StarToggle'
export default {
components: {
ApplicationTags,
StarToggle,
},
props: {

View file

@ -0,0 +1,14 @@
<template>
<button type="button" @click="starred = !starred" class="focus:outline-none" :class="[starred ? 'text-orange hover:text-orange-light focus:text-orange-light' : 'text-grey focus:text-orange hover:text-orange']">
<span class="visuallyhidden">{{ !starred ? 'Star' : 'Unstar' }} {{ application.name }}</span>
<svg class="h-6 w-6 fill-current" role="presentation"><use :xlink:href="`/img/icons.symbol.svg#state__${starred ? 'starred' : 'unstarred'}`"></use></svg>
</button>
</template>
<script>
export default {
props: {
application: Object,
},
}
</script>