misskey/src/web/app/common/views/components/messaging-room.message.vue

239 lines
4.5 KiB
Vue
Raw Normal View History

2018-02-12 22:38:53 -08:00
<template>
2018-02-20 08:39:51 -08:00
<div class="message" :data-is-me="isMe">
2018-02-18 07:18:01 -08:00
<a class="avatar-anchor" :href="`/${message.user.username}`" :title="message.user.username" target="_blank">
<img class="avatar" :src="`${message.user.avatar_url}?thumbnail&size=80`" alt=""/>
2018-02-12 22:38:53 -08:00
</a>
<div class="content-container">
<div class="balloon">
2018-02-22 01:06:32 -08:00
<p class="read" v-if="isMe && message.is_read">%i18n:common.tags.mk-messaging-message.is-read%</p>
<button class="delete-button" v-if="isMe" title="%i18n:common.delete%">
2018-02-18 07:18:01 -08:00
<img src="/assets/desktop/messaging/delete.png" alt="Delete"/>
</button>
2018-02-12 22:38:53 -08:00
<div class="content" v-if="!message.is_deleted">
2018-02-18 07:18:01 -08:00
<mk-post-html class="text" v-if="message.ast" :ast="message.ast" :i="os.i"/>
2018-02-12 22:38:53 -08:00
<mk-url-preview v-for="url in urls" :url="url" :key="url"/>
2018-02-18 07:18:01 -08:00
<div class="image" v-if="message.file">
<img :src="message.file.url" alt="image" :title="message.file.name"/>
</div>
2018-02-12 22:38:53 -08:00
</div>
<div class="content" v-if="message.is_deleted">
<p class="is-deleted">%i18n:common.tags.mk-messaging-message.deleted%</p>
</div>
</div>
<footer>
2018-02-18 07:18:01 -08:00
<mk-time :time="message.created_at"/>
<template v-if="message.is_edited">%fa:pencil-alt%</template>
2018-02-12 22:38:53 -08:00
</footer>
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
props: ['message'],
computed: {
isMe(): boolean {
2018-02-17 19:35:18 -08:00
return this.message.user_id == (this as any).os.i.id;
2018-02-12 22:38:53 -08:00
},
urls(): string[] {
if (this.message.ast) {
return this.message.ast
.filter(t => (t.type == 'url' || t.type == 'link') && !t.silent)
.map(t => t.url);
} else {
return null;
}
}
}
});
</script>
<style lang="stylus" scoped>
2018-02-20 08:39:51 -08:00
.message
2018-02-12 22:38:53 -08:00
$me-balloon-color = #23A7B6
padding 10px 12px 10px 12px
background-color transparent
&:after
content ""
display block
clear both
> .avatar-anchor
display block
> .avatar
display block
min-width 54px
min-height 54px
max-width 54px
max-height 54px
margin 0
border-radius 8px
transition all 0.1s ease
> .content-container
display block
margin 0 12px
padding 0
max-width calc(100% - 78px)
> .balloon
display block
float inherit
margin 0
padding 0
max-width 100%
min-height 38px
border-radius 16px
&:before
content ""
pointer-events none
display block
position absolute
top 12px
&:hover
> .delete-button
display block
> .delete-button
display none
position absolute
z-index 1
top -4px
right -4px
margin 0
padding 0
cursor pointer
outline none
border none
border-radius 0
box-shadow none
background transparent
> img
vertical-align bottom
width 16px
height 16px
cursor pointer
> .read
user-select none
display block
position absolute
z-index 1
bottom -4px
left -12px
margin 0
color rgba(0, 0, 0, 0.5)
font-size 11px
> .content
> .is-deleted
display block
margin 0
padding 0
overflow hidden
overflow-wrap break-word
font-size 1em
color rgba(0, 0, 0, 0.5)
2018-02-18 07:18:01 -08:00
> .text
2018-02-12 22:38:53 -08:00
display block
margin 0
padding 8px 16px
overflow hidden
overflow-wrap break-word
font-size 1em
color rgba(0, 0, 0, 0.8)
&, *
user-select text
cursor auto
& + .file
&.image
> img
border-radius 0 0 16px 16px
> .file
&.image
> img
display block
max-width 100%
max-height 512px
border-radius 16px
> footer
display block
clear both
margin 0
padding 2px
font-size 10px
color rgba(0, 0, 0, 0.4)
> [data-fa]
margin-left 4px
2018-02-20 08:39:51 -08:00
&:not([data-is-me])
2018-02-12 22:38:53 -08:00
> .avatar-anchor
float left
> .content-container
float left
> .balloon
background #eee
&:before
left -14px
border-top solid 8px transparent
border-right solid 8px #eee
border-bottom solid 8px transparent
border-left solid 8px transparent
> footer
text-align left
2018-02-20 08:39:51 -08:00
&[data-is-me]
2018-02-12 22:38:53 -08:00
> .avatar-anchor
float right
> .content-container
float right
> .balloon
background $me-balloon-color
&:before
right -14px
left auto
border-top solid 8px transparent
border-right solid 8px transparent
border-bottom solid 8px transparent
border-left solid 8px $me-balloon-color
> .content
> p.is-deleted
color rgba(255, 255, 255, 0.5)
2018-02-22 12:43:19 -08:00
> .text >>>
2018-02-12 22:38:53 -08:00
&, *
color #fff !important
> footer
text-align right
2018-02-20 08:39:51 -08:00
&[data-is-deleted]
2018-02-12 22:38:53 -08:00
> .content-container
opacity 0.5
</style>