mirror of
https://github.com/romancm/gamebrary
synced 2025-03-01 13:17:08 +00:00
Move game description to its own component and clamp extra long text
This commit is contained in:
parent
2855955172
commit
02ddb5cb83
2 changed files with 77 additions and 8 deletions
73
src/components/GameDetail/GameDescription.vue
Normal file
73
src/components/GameDetail/GameDescription.vue
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
|
||||||
|
<template lang="html">
|
||||||
|
<div class="game-description" @click="expand">
|
||||||
|
<p :class="{ collapsed }">
|
||||||
|
{{ game.summary }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<a class="read-more" v-if="collapsed">Read more</a>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { mapState } from 'vuex';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
expanded: false,
|
||||||
|
characterLimit: 500,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
...mapState(['game']),
|
||||||
|
|
||||||
|
collapsed() {
|
||||||
|
return !this.expanded && this.game.summary && this.game.summary.length > this.characterLimit;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
expand() {
|
||||||
|
if (this.collapsed) {
|
||||||
|
this.expanded = true
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" rel="stylesheet/scss" scoped>
|
||||||
|
@import "~styles/styles";
|
||||||
|
|
||||||
|
.game-description {
|
||||||
|
margin-bottom: $gp;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
line-height: 1.4rem;
|
||||||
|
font-size: 16px;
|
||||||
|
letter-spacing: .01em;
|
||||||
|
|
||||||
|
&.collapsed {
|
||||||
|
margin-bottom: $gp / 2;
|
||||||
|
|
||||||
|
@media($small) {
|
||||||
|
overflow : hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 6;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.read-more {
|
||||||
|
display: none;
|
||||||
|
|
||||||
|
@media($small) {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,3 +1,4 @@
|
||||||
|
<!-- TODO: rename to Game.vue -->
|
||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="game-detail">
|
<div class="game-detail">
|
||||||
<header>
|
<header>
|
||||||
|
@ -30,8 +31,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="game" class="details">
|
<div v-if="game" class="details">
|
||||||
|
<game-description />
|
||||||
<p class="game-description" v-html="game.summary" />
|
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button
|
<button
|
||||||
|
@ -93,6 +93,7 @@ import GameNotes from '@/components/GameNotes';
|
||||||
import GameTags from '@/components/GameDetail/GameTags';
|
import GameTags from '@/components/GameDetail/GameTags';
|
||||||
import GameRating from '@/components/GameDetail/GameRating';
|
import GameRating from '@/components/GameDetail/GameRating';
|
||||||
import GameLinks from '@/components/GameDetail/GameLinks';
|
import GameLinks from '@/components/GameDetail/GameLinks';
|
||||||
|
import GameDescription from '@/components/GameDetail/GameDescription';
|
||||||
import GameVideos from '@/components/GameDetail/GameVideos';
|
import GameVideos from '@/components/GameDetail/GameVideos';
|
||||||
import GameDetails from '@/components/GameDetail/GameDetails';
|
import GameDetails from '@/components/GameDetail/GameDetails';
|
||||||
import Platform from '@/components/Platforms/Platform';
|
import Platform from '@/components/Platforms/Platform';
|
||||||
|
@ -105,6 +106,7 @@ export default {
|
||||||
IgdbCredit,
|
IgdbCredit,
|
||||||
GameRating,
|
GameRating,
|
||||||
GameLinks,
|
GameLinks,
|
||||||
|
GameDescription,
|
||||||
Placeholder,
|
Placeholder,
|
||||||
GameScreenshots,
|
GameScreenshots,
|
||||||
GameNotes,
|
GameNotes,
|
||||||
|
@ -231,12 +233,6 @@ aside {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.game-description {
|
|
||||||
line-height: 1.4rem;
|
|
||||||
font-size: 16px;
|
|
||||||
letter-spacing: .01em
|
|
||||||
}
|
|
||||||
|
|
||||||
.actions {
|
.actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
Loading…
Add table
Reference in a new issue