gamja-old/components/buffer-header.js

35 lines
832 B
JavaScript
Raw Normal View History

2020-06-25 12:30:21 -04:00
import { html, Component } from "/lib/index.js";
import { BufferType } from "/state.js";
2020-06-25 12:30:21 -04:00
export default function BufferHeader(props) {
function handlePartClick(event) {
event.preventDefault();
props.onClose();
}
var description = null;
if (props.buffer.topic) {
description = html`<span class="description">${props.buffer.topic}</span>`;
} else if (props.buffer.who) {
var who = props.buffer.who;
description = html`<span class="description">${who.realname} (${who.username}@${who.hostname})</span>`;
}
var closeText = "Close";
switch (props.buffer.type) {
case BufferType.SERVER:
closeText = "Disconnect";
break;
case BufferType.CHANNEL:
closeText = "Part";
break;
}
2020-06-25 12:30:21 -04:00
return html`
${description}
2020-06-25 12:30:21 -04:00
<span class="actions">
<a href="#" onClick=${handlePartClick}>${closeText}</a>
2020-06-25 12:30:21 -04:00
</span>
`;
}