pinafore/routes/_components/status/StatusSpoiler.html

51 lines
1.3 KiB
HTML

<div class="status-spoiler {{isStatusInNotification ? 'status-in-notification' : ''}}">
{{status.spoiler_text}}
</div>
<div class="status-spoiler-button">
<button type="button" on:click="onClickSpoilerButton()">
{{spoilerShown ? 'Show less' : 'Show more'}}
</button>
</div>
<style>
.status-spoiler {
grid-area: spoiler;
word-wrap: break-word;
overflow: hidden;
white-space: pre-wrap;
font-size: 1.1em;
margin: 5px;
}
.status-spoiler-button {
grid-area: spoiler-button;
margin: 5px;
}
.status-spoiler-button button {
padding: 5px 10px;
font-size: 1.1em;
}
.status-spoiler.status-in-notification {
color: var(--very-deemphasized-text-color);
}
</style>
<script>
import { store } from '../../_store/store'
export default {
store: () => store,
computed: {
spoilerShown: ($spoilersShown, contextualStatusId) => !!$spoilersShown[contextualStatusId]
},
methods: {
onClickSpoilerButton() {
let contextualStatusId = this.get('contextualStatusId')
let $spoilersShown = this.store.get('spoilersShown')
$spoilersShown[contextualStatusId] = !$spoilersShown[contextualStatusId]
this.store.set({'spoilersShown': $spoilersShown})
this.fire('recalculateHeight')
}
}
}
</script>