Skip to content

Commit

Permalink
feat(/): add 'top anime' section
Browse files Browse the repository at this point in the history
  • Loading branch information
Jabster28 committed Jul 18, 2020
1 parent 5c3d2e2 commit cf652f4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 22 deletions.
23 changes: 17 additions & 6 deletions src/components/AnimeCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,18 @@
>
<q-img :src="anime.image_url">
<div class="absolute-bottom">
<div class="text-h6">{{ anime.title }}</div>
<div class="text-h6">{{ truncateString(anime.title, trunc) }}</div>
<div class="text-subtitle2">
{{ anime.type }}, {{ Math.round(anime.score) }} stars ({{
anime.rated
}})
{{ anime.type }}, {{ Math.round(anime.score) }} stars
{{ anime.rated ? `(${anime.rated})` : '' }}
</div>
</div>
</q-img>
</q-card>
</transition>
</template>

<script>
<script lang="ts">
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
export default {
Expand All @@ -32,11 +31,23 @@ export default {
anime: {
type: Object,
required: true
},
trunc: {
type: Number,
default: 45
}
},
methods: {
goto(e) {
goto(e: string) {
// @ts-ignore
this.$router.push(e);
},
truncateString(str: string, num: number) {
if (str.length > num) {
return str.slice(0, num) + '...';
} else {
return str;
}
}
}
};
Expand Down
40 changes: 24 additions & 16 deletions src/pages/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,43 @@
<h1>mirai</h1>
<p disabled>the best MAL client out there.</p>
</div>
<div class="row items-center justify-evenly">
<div class="col-6">
<h6>
MyAnimeList is a great website - it has virtually every anime known to
man, you can use it to remember which animes you've watched and when,
it even shows you some recommendations. It's all that a weeb could ask
for!
</h6>
<h6>
But let's be honest here - the user interface is pretty old. Sure, it
works, and it's fairly quick, but "quick" isn't enough for me, and it
shouldn't be for you, either. Head to
<router-link to="/faq">the FAQ</router-link> for more info.
</h6>
</div>
<div v-if="top" class="col-10">
<h2>Top anime for {{ top.season_name }}, {{ top.season_year }}</h2>
<q-scroll-area horizontal class="q-ma-md" style="height: 400px;">
<div class="row no-wrap">
<AnimeCard
trunc="30"
v-for="anime in top.anime.slice(0, 40)"
:key="anime.mal_id"
:anime="anime"
/>
</div>
</q-scroll-area>
</div>
</q-page>
</template>

<script lang="ts">
import Vue from 'vue';
import AnimeCard from 'components/AnimeCard.vue';
import axios from 'axios';
export default Vue.extend({
components: { AnimeCard },
name: 'PageIndex',
mounted() {
document.title = 'Mirai';
axios
.get('https://api.jikan.moe/v3/season')
.then(data => {
this.top = data.data;
})
.catch(e => console.log(e));
},
data() {
return {};
return {
top: null
};
}
});
</script>

1 comment on commit cf652f4

@vercel
Copy link

@vercel vercel bot commented on cf652f4 Jul 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.