mirror of
https://github.com/He4eT/elseifplayer.git
synced 2026-05-05 01:17:22 +00:00
Use inline tags for messages
This commit is contained in:
parent
fce8be2af0
commit
23714c7e7f
2 changed files with 14 additions and 21 deletions
|
|
@ -25,23 +25,18 @@ const parseInbox = (inbox, currentWindow) => {
|
||||||
const { clear, text: inboxMessagesRaw } =
|
const { clear, text: inboxMessagesRaw } =
|
||||||
currentInbox
|
currentInbox
|
||||||
|
|
||||||
const incoming = trimImputPrompt(
|
const eol = { style: 'endOfLine' }
|
||||||
|
|
||||||
|
const incoming =
|
||||||
inboxMessagesRaw
|
inboxMessagesRaw
|
||||||
/* Normalize. */
|
/* Normalize. */
|
||||||
.map(({ content }) =>
|
.map(({ content }) =>
|
||||||
content || [{ style: 'emptyLine' }])
|
content
|
||||||
|
? [...trimImputPrompt(content), eol]
|
||||||
|
: [eol])
|
||||||
/* Flatten. */
|
/* Flatten. */
|
||||||
.reduce((acc, x) =>
|
.reduce((acc, x) =>
|
||||||
acc.concat(x), [])
|
acc.concat(x), [])
|
||||||
/* Collapse empty lines. */
|
|
||||||
.reduce((acc, x, i, xs) => {
|
|
||||||
if (x.style !== 'emptyLine') return [...acc, x]
|
|
||||||
|
|
||||||
const prev = xs[i - 1] || {}
|
|
||||||
return prev.style === 'emptyLine'
|
|
||||||
? acc
|
|
||||||
: [...acc, x]
|
|
||||||
}, []))
|
|
||||||
|
|
||||||
return { clear, incoming }
|
return { clear, incoming }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,14 @@
|
||||||
import { h } from 'preact'
|
import { h } from 'preact'
|
||||||
|
|
||||||
export default function ({ style, text }) {
|
export default function ({ style, text }) {
|
||||||
const defaultContent = (<span>{text}</span>)
|
const defaultContent = (
|
||||||
|
<span class={['message', style].join(' ')}>
|
||||||
|
{text}
|
||||||
|
</span>)
|
||||||
|
|
||||||
const content = ({
|
return ({
|
||||||
emptyLine: (<br />),
|
input: (<span class='message input'>> {text}</span>),
|
||||||
subheader: (<strong>{text}</strong>)
|
subheader: (<strong>{text}</strong>),
|
||||||
|
endOfLine: (<br />)
|
||||||
})[style] || defaultContent
|
})[style] || defaultContent
|
||||||
|
|
||||||
return (
|
|
||||||
<div class={['message', style].join(' ')}>
|
|
||||||
{content}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue