/** * @file * @copyright 2020 Aleksej Komarov * @license MIT */ import { capitalize } from 'common/string'; import { toFixed } from 'common/math'; import { useLocalState } from 'tgui/backend'; import { useDispatch, useSelector } from 'common/redux'; import { Box, Button, ColorBox, Divider, Input, LabeledList, Slider, Section, Stack, Tabs, TextArea, Collapsible, } from 'tgui/components'; import { ChatPageSettings } from '../chat'; import { clearChat, rebuildChat, saveChatToDisk } from '../chat/actions'; import { THEMES } from '../themes'; import { changeSettingsTab, updateSettings, addHighlightSetting, removeHighlightSetting, updateHighlightSetting, } from './actions'; import { SETTINGS_TABS, FONTS, MAX_HIGHLIGHT_SETTINGS } from './constants'; import { selectActiveTab, selectSettings, selectHighlightSettings, selectHighlightSettingById } from './selectors'; import { SettingsStatPanel } from './SettingsStatPanel'; export const SettingsPanel = (props, context) => { const activeTab = useSelector(context, selectActiveTab); const dispatch = useDispatch(context); return (
{SETTINGS_TABS.map((tab) => ( dispatch( changeSettingsTab({ tabId: tab.id, }) ) } > {tab.name} ))}
{activeTab === 'general' && } {activeTab === 'chatPage' && } {activeTab === 'textHighlight' && } {activeTab === 'statPanel' && }
); }; export const SettingsGeneral = (props, context) => { const { theme, fontFamily, fontSize, lineHeight } = useSelector(context, selectSettings); const dispatch = useDispatch(context); const [freeFont, setFreeFont] = useLocalState(context, 'freeFont', false); return (
{THEMES.map((THEME) => (
); }; const TextHighlightSettings = (props, context) => { const highlightSettings = useSelector(context, selectHighlightSettings); const dispatch = useDispatch(context); return (
{highlightSettings.map((id, i) => ( ))} {highlightSettings.length < MAX_HIGHLIGHT_SETTINGS && (
Can freeze the chat for a while.
); }; const TextHighlightSetting = (props, context) => { const { id, ...rest } = props; const highlightSettingById = useSelector(context, selectHighlightSettingById); const dispatch = useDispatch(context); const { highlightColor, highlightText, highlightWholeMessage, matchWord, matchCase } = highlightSettingById[id]; return (