Files
Cody BrittainandGitHub bcd29944b7 Prettier update (#21722)
No player-facing changes.

Ports several PRs from tgstation, including:

https://github.com/tgstation/tgstation/pull/66862
https://github.com/tgstation/tgstation/pull/80189
https://github.com/tgstation/tgstation/pull/90317
https://github.com/tgstation/tgstation/pull/91379

In addition, removes IntelliCode from the recommended extensions. This
is deprecated, and we prefer not to force the replacement onto
contributors. Contributors may individually choose to use this instead.
2026-01-28 07:16:34 +00:00

71 lines
1.8 KiB
JavaScript

/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { useDispatch, useSelector } from 'common/redux';
import { Box, Tabs, Flex, Button } from 'tgui/components';
import { changeChatPage, addChatPage } from './actions';
import { selectChatPages, selectCurrentChatPage } from './selectors';
import { openChatSettings } from '../settings/actions';
const UnreadCountWidget = ({ value }) => (
<Box
style={{
'font-size': '0.7em',
'border-radius': '0.25em',
width: '1.7em',
'line-height': '1.55em',
'background-color': 'crimson',
color: '#fff',
}}
>
{Math.min(value, 99)}
</Box>
);
export const ChatTabs = (props, context) => {
const pages = useSelector(context, selectChatPages);
const currentPage = useSelector(context, selectCurrentChatPage);
const dispatch = useDispatch(context);
return (
<Flex align="center">
<Flex.Item>
<Tabs textAlign="center">
{pages.map((page) => (
<Tabs.Tab
key={page.id}
selected={page === currentPage}
rightSlot={
page.unreadCount > 0 && (
<UnreadCountWidget value={page.unreadCount} />
)
}
onClick={() =>
dispatch(
changeChatPage({
pageId: page.id,
}),
)
}
>
{page.name}
</Tabs.Tab>
))}
</Tabs>
</Flex.Item>
<Flex.Item ml={1}>
<Button
color="transparent"
icon="plus"
onClick={() => {
dispatch(addChatPage());
dispatch(openChatSettings());
}}
/>
</Flex.Item>
</Flex>
);
};