Skip to content

Instantly share code, notes, and snippets.

@xphong
Created November 11, 2017 19:35
Show Gist options
  • Save xphong/ae62ab776a486eabf901c74b90299a88 to your computer and use it in GitHub Desktop.
Save xphong/ae62ab776a486eabf901c74b90299a88 to your computer and use it in GitHub Desktop.
Marvel API + Vuepack (Vue + Vuex) Blog Post CharactersList Code
<template>
<div v-if="!!characters.length" class="ui characters-list cards">
<div v-for="character in characters" :key="character.name" class="ui card fadeIn-animation">
<div class="image">
<img :src="character.image" />
</div>
<div class="content">
<div class="header">{{character.name}}</div>
<div class="description">
{{character.description}}
</div>
</div>
<div class="extra content">
<span class="right floated">
<a target="_blank" :href="character.url">
<button class="ui icon purple tiny button">
More Info
</button>
</a>
</span>
</div>
</div>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
computed: mapGetters([
'characters'
])
}
</script>
<style>
.characters-list.cards {
margin-top: 2em;
justify-content: center;
}
.characters-list.cards .image {
position: relative;
width: 100%;
height: 246px;
overflow: hidden;
}
.characters-list.cards .image img {
position: absolute;
left: 50%;
top: 50%;
height: 100%;
width: auto;
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
}
.ui.card, .ui.cards > .card {
width: 364px;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment