2020-06-25 12:30:21 -04:00
|
|
|
import { html, Component } from "/lib/index.js";
|
2020-06-26 06:00:10 -04:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2020-06-26 06:00:10 -04:00
|
|
|
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`
|
2020-06-26 06:00:10 -04:00
|
|
|
${description}
|
2020-06-25 12:30:21 -04:00
|
|
|
<span class="actions">
|
2020-06-26 06:00:10 -04:00
|
|
|
<a href="#" onClick=${handlePartClick}>${closeText}</a>
|
2020-06-25 12:30:21 -04:00
|
|
|
</span>
|
|
|
|
`;
|
|
|
|
}
|