some changes to chat component (wip)

This commit is contained in:
Craig 2020-01-30 23:59:22 +00:00
parent 0f40e0119c
commit 7f26b8bb7b
3 changed files with 73 additions and 61 deletions

View File

@ -26,5 +26,5 @@ $style-error: #d32f2f;
$menu-height: 40px;
$controls-height: 125px;
$side-width: 300px;
$side-width: 400px;

View File

@ -11,15 +11,14 @@
<span>{{ member(message.id).username }}</span>
<span class="timestamp">{{ timestamp(message.created) }}</span>
</div>
<div class="content-body">
<neko-markdown :source="message.content" />
</div>
<neko-markdown class="content-body" :source="message.content" />
</div>
</li>
<li :key="index" class="event" v-if="message.type === 'event'">
<span
<div
class="content"
v-tooltip="{
content: `${timestamp(message.created)}, ${member(message.id).username} ${message.content}`,
content: timestamp(message.created),
placement: 'left',
offset: 3,
boundariesElement: 'body',
@ -28,7 +27,7 @@
<strong v-if="message.id === id">You</strong>
<strong v-else>{{ member(message.id).username }}</strong>
{{ message.content }}
</span>
</div>
</li>
</template>
</ul>
@ -37,6 +36,7 @@
<div class="accent" />
<div class="text-container">
<textarea ref="chat" placeholder="Send a message" @keydown="onKeyDown" v-model="content" />
<div class="emoji"></div>
</div>
</div>
</div>
@ -84,12 +84,13 @@
li {
flex: 1;
border-top: 1px solid var(--border-color);
padding: 10px 10px 0px 10px;
padding: 10px 5px 0px 10px;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
overflow: hidden;
user-select: contain;
max-width: 100%;
user-select: text;
word-wrap: break-word;
&.message {
.author {
@ -100,7 +101,7 @@
height: 40px;
border-radius: 50%;
background: $style-primary;
margin: 5px 10px 10px 0px;
margin: 0px 10px 10px 0px;
img {
width: 100%;
@ -111,34 +112,41 @@
flex: 1;
display: flex;
flex-direction: column;
line-height: 22px;
box-sizing: border-box;
word-wrap: break-word;
min-width: 0;
.content-head {
cursor: default;
width: 100%;
margin-bottom: 3px;
display: block;
span {
display: inline-block;
color: $text-normal;
font-weight: 500;
float: left;
font-size: 16px;
}
.timestamp {
margin-left: 5px;
color: $text-muted;
float: left;
font-size: 0.8em;
line-height: 1.7em;
}
}
::v-deep .content-body {
display: flex;
color: $text-normal;
line-height: 22px;
font-size: 0.7rem;
font-weight: 500;
margin-left: 0.3rem;
line-height: 12px;
* {
word-wrap: break-word;
max-width: 225px;
&::first-letter {
text-transform: uppercase;
}
}
}
::v-deep .content-body {
color: $text-normal;
line-height: 20px;
word-wrap: break-word;
overflow-wrap: break-word;
a {
color: $text-link;
@ -157,7 +165,8 @@
padding-left: 3px;
}
.spoiler {
span {
&.spoiler {
background: $background-tertiary;
padding: 0 2px;
border-radius: 4px;
@ -166,10 +175,12 @@
span {
opacity: 0;
}
}
&.active {
&.spoiler.active {
background: $background-secondary;
cursor: default;
span {
opacity: 1;
}
@ -189,10 +200,8 @@
white-space: pre-wrap;
}
div {
flex: 1;
pre {
flex: 1;
color: $interactive-normal;
border: 1px solid $background-tertiary;
background: $background-secondary;
@ -209,29 +218,24 @@
}
}
}
}
&.event {
flex: 1;
overflow: hidden;
display: flex;
height: 15px;
color: $text-muted;
cursor: default;
span {
white-space: nowrap;
max-width: 250px;
text-overflow: ellipsis;
overflow: hidden;
height: 15px;
.content {
min-width: 0;
box-sizing: border-box;
word-wrap: break-word;
display: inline-block;
vertical-align: baseline;
line-height: 20px;
strong {
font-weight: 600;
}
i {
float: right;
font-style: italic;
font-size: 10px;
}
@ -263,6 +267,13 @@
border-radius: 5px;
display: flex;
.emoji {
width: 20px;
height: 20px;
// background: #fff;
margin: 3px 3px 0 0;
}
textarea {
flex: 1;
font-family: $text-family;
@ -364,7 +375,8 @@
}
timestamp(time: Date) {
return formatRelative(time, new Date())
const str = formatRelative(time, new Date())
return `${str.charAt(0).toUpperCase()}${str.slice(1)}`
}
onContext(event: MouseEvent, data: any) {

View File

@ -202,10 +202,10 @@ const rules: MarkdownRules = {
match: source => /^[\s\S]+?(?=[^0-9A-Za-z\s\u00c0-\uffff-]|\n\n|\n|\w+:\S|$)/.exec(source),
html(node, output, state) {
if (state.escapeHTML) {
return htmlTag('span', md.sanitizeText(node.content), {}, state)
return md.sanitizeText(node.content)
}
return htmlTag('span', node.content, {}, state)
return node.content
},
},
br: {
@ -234,7 +234,7 @@ const rules: MarkdownRules = {
}
},
html(node, output, state) {
return htmlTag('span', output(node.content, state), { class: 'spoiler' }, state) //htmlTag('span', , { }, state)
return htmlTag('span', htmlTag('span', output(node.content, state), {}, state), { class: 'spoiler' }, state) //htmlTag('span', , { }, state)
},
},
}