gamja/components/buffer-header.js

47 lines
1.1 KiB
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;
2020-06-26 06:08:14 -04:00
if (props.buffer.serverInfo) {
var serverInfo = props.buffer.serverInfo;
description = `Connected to ${serverInfo.name}`;
} else if (props.buffer.topic) {
description = props.buffer.topic;
} else if (props.buffer.who) {
var who = props.buffer.who;
2020-06-26 06:45:27 -04:00
var statusClass = "here";
var statusText = "User is online";
if (who.away) {
statusClass = "gone";
statusText = "User is away";
}
var status = html`<span class="status status-${statusClass}" title=${statusText}>●</span>`;
description = html`${status} ${who.realname} (${who.username}@${who.hostname})`;
}
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:08:14 -04:00
<span class="description">${description}</span>
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>
`;
}