owncast/web/components/ui/Content/Content.tsx

127 lines
4.7 KiB
TypeScript
Raw Normal View History

import { useRecoilValue } from 'recoil';
2022-05-18 02:07:56 +03:00
import { Layout, Button, Tabs } from 'antd';
2022-05-22 15:18:16 +03:00
import { NotificationFilled, HeartFilled } from '@ant-design/icons';
2022-05-04 00:17:05 +03:00
import {
chatVisibilityAtom,
clientConfigStateAtom,
chatMessagesAtom,
chatStateAtom,
serverStatusState,
2022-05-04 00:17:05 +03:00
} from '../../stores/ClientConfigStore';
import { ClientConfig } from '../../../interfaces/client-config.model';
import CustomPageContent from '../../CustomPageContent';
import OwncastPlayer from '../../video/OwncastPlayer';
import FollowerCollection from '../../FollowersCollection';
2022-05-04 00:55:13 +03:00
import s from './Content.module.scss';
import Sidebar from '../Sidebar';
import Footer from '../Footer';
import ChatContainer from '../../chat/ChatContainer';
import { ChatMessage } from '../../../interfaces/chat-message.model';
import { ChatState, ChatVisibilityState } from '../../../interfaces/application-state';
import ChatTextField from '../../chat/ChatTextField/ChatTextField';
2022-05-08 02:13:06 +03:00
import ActionButtonRow from '../../action-buttons/ActionButtonRow';
import ActionButton from '../../action-buttons/ActionButton';
import Statusbar from '../Statusbar/Statusbar';
import { ServerStatus } from '../../../interfaces/server-status.model';
2022-05-12 09:31:31 +03:00
import { Follower } from '../../../interfaces/follower';
2022-05-17 07:44:09 +03:00
import SocialLinks from '../SocialLinks/SocialLinks';
import NotifyReminderPopup from '../NotifyReminderPopup/NotifyReminderPopup';
import ServerLogo from '../Logo/Logo';
import CategoryIcon from '../CategoryIcon/CategoryIcon';
const { TabPane } = Tabs;
const { Content } = Layout;
2022-05-08 10:39:58 +03:00
export default function ContentComponent() {
2022-05-08 02:13:06 +03:00
const status = useRecoilValue<ServerStatus>(serverStatusState);
const clientConfig = useRecoilValue<ClientConfig>(clientConfigStateAtom);
const chatVisibility = useRecoilValue<ChatVisibilityState>(chatVisibilityAtom);
const messages = useRecoilValue<ChatMessage[]>(chatMessagesAtom);
const chatState = useRecoilValue<ChatState>(chatStateAtom);
2022-05-17 07:44:09 +03:00
const { extraPageContent, version, socialHandles, name, title, tags } = clientConfig;
2022-05-12 09:31:31 +03:00
const { online, viewerCount, lastConnectTime, lastDisconnectTime } = status;
2022-05-04 00:17:05 +03:00
const followers: Follower[] = [];
const total = 0;
const chatVisible =
chatState === ChatState.Available && chatVisibility === ChatVisibilityState.Visible;
2022-05-08 02:13:06 +03:00
// This is example content. It should be removed.
const externalActions = [
{
url: 'https://owncast.online/docs',
title: 'Example button',
description: 'Example button description',
icon: 'https://owncast.online/images/logo.svg',
color: '#5232c8',
2022-05-10 01:34:02 +03:00
openExternally: false,
2022-05-08 02:13:06 +03:00
},
];
const externalActionButtons = externalActions.map(action => (
<ActionButton key={action.url} action={action} />
));
return (
<Content className={`${s.root}`}>
<div className={`${s.leftCol}`}>
2022-05-11 01:36:09 +03:00
<OwncastPlayer source="/hls/stream.m3u8" online={online} />
2022-05-08 02:13:06 +03:00
<Statusbar
online={online}
lastConnectTime={lastConnectTime}
lastDisconnectTime={lastDisconnectTime}
viewerCount={viewerCount}
2022-05-06 01:01:23 +03:00
/>
2022-05-18 02:07:56 +03:00
<div className={s.buttonsLogoTitleSection}>
<ActionButtonRow>
{externalActionButtons}
2022-05-22 15:18:16 +03:00
<Button icon={<HeartFilled />}>Follow</Button>
2022-05-18 02:07:56 +03:00
<NotifyReminderPopup
visible
notificationClicked={() => {}}
notificationClosed={() => {}}
>
2022-05-22 15:18:16 +03:00
<Button icon={<NotificationFilled />}>Notify</Button>
2022-05-18 02:07:56 +03:00
</NotifyReminderPopup>
</ActionButtonRow>
<div className={`${s.lowerRow}`}>
<div className={s.logoTitleSection}>
<ServerLogo src="/logo" />
<div className={s.titleSection}>
<div className={s.title}>{name}</div>
<div className={s.subtitle}>
{title}
<CategoryIcon tags={tags} />
</div>
2022-05-18 02:07:56 +03:00
<div>{tags.length > 0 && tags.map(tag => <span key={tag}>#{tag}&nbsp;</span>)}</div>
</div>
</div>
</div>
2022-05-17 07:44:09 +03:00
<Tabs defaultActiveKey="1">
<TabPane tab="About" key="1" className={`${s.pageContentSection}`}>
2022-05-17 07:44:09 +03:00
<SocialLinks links={socialHandles} />
2022-05-04 00:55:13 +03:00
<CustomPageContent content={extraPageContent} />
</TabPane>
<TabPane tab="Followers" key="2" className={`${s.pageContentSection}`}>
2022-05-04 00:17:05 +03:00
<FollowerCollection total={total} followers={followers} />
2022-05-04 00:55:13 +03:00
</TabPane>
</Tabs>
{chatVisibility && (
<div className={`${s.mobileChat}`}>
<ChatContainer messages={messages} state={chatState} />
<ChatTextField />
</div>
)}
2022-05-12 09:31:31 +03:00
<Footer version={version} />
2022-05-04 00:55:13 +03:00
</div>
</div>
{chatVisible && <Sidebar />}
</Content>
);
}