Files
GhomandArchie 291dcf9515 Merge pull request #10575 from Arturlang/TGUIs_Nexties
[TESTMERGE] Properly working TGUI Next
2021-01-04 19:47:54 -03:00

52 lines
1.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { classes, pureComponentHooks } from 'common/react';
import { toTitleCase } from 'common/string';
import { tridentVersion } from '../byond';
import { UI_DISABLED, UI_INTERACTIVE, UI_UPDATE } from '../constants';
import { Icon } from './Icon';
const statusToColor = status => {
switch (status) {
case UI_INTERACTIVE:
return 'good';
case UI_UPDATE:
return 'average';
case UI_DISABLED:
default:
return 'bad';
}
};
export const TitleBar = props => {
const { className, title, status, fancy, onDragStart, onClose } = props;
return (
<div
className={classes([
'TitleBar',
className,
])}>
<Icon
className="TitleBar__statusIcon"
color={statusToColor(status)}
name="eye" />
<div className="TitleBar__title">
{title === title.toLowerCase() ? toTitleCase(title) : title}
</div>
<div
className="TitleBar__dragZone"
onMousedown={e => fancy && onDragStart(e)} />
{!!fancy && (
<div
className="TitleBar__close TitleBar__clickable"
// IE8: Synthetic onClick event doesn't work on IE8.
// IE8: Use a plain character instead of a unicode symbol.
// eslint-disable-next-line react/no-unknown-property
onclick={onClose}>
{tridentVersion <= 4 ? 'x' : '×'}
</div>
)}
</div>
);
};
TitleBar.defaultHooks = pureComponentHooks;