mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
🖱️ feat: Switch Scroll Button setting (#5332)
This commit is contained in:
parent
8a0c7d92bd
commit
1c459ed3af
6 changed files with 46 additions and 2 deletions
|
|
@ -17,6 +17,7 @@ export default function MessagesView({
|
||||||
Header?: ReactNode;
|
Header?: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
const localize = useLocalize();
|
const localize = useLocalize();
|
||||||
|
const scrollButtonPreference = useRecoilValue(store.showScrollButton);
|
||||||
const fontSize = useRecoilValue(store.fontSize);
|
const fontSize = useRecoilValue(store.fontSize);
|
||||||
const { screenshotTargetRef } = useScreenshot();
|
const { screenshotTargetRef } = useScreenshot();
|
||||||
const [currentEditId, setCurrentEditId] = useState<number | string | null>(-1);
|
const [currentEditId, setCurrentEditId] = useState<number | string | null>(-1);
|
||||||
|
|
@ -83,7 +84,10 @@ export default function MessagesView({
|
||||||
unmountOnExit={false}
|
unmountOnExit={false}
|
||||||
// appear
|
// appear
|
||||||
>
|
>
|
||||||
{() => showScrollButton && <ScrollToBottom scrollHandler={handleSmoothToRef} />}
|
{() =>
|
||||||
|
showScrollButton &&
|
||||||
|
scrollButtonPreference && <ScrollToBottom scrollHandler={handleSmoothToRef} />
|
||||||
|
}
|
||||||
</CSSTransition>
|
</CSSTransition>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import { ForkSettings } from './ForkSettings';
|
||||||
import ChatDirection from './ChatDirection';
|
import ChatDirection from './ChatDirection';
|
||||||
import ShowThinking from './ShowThinking';
|
import ShowThinking from './ShowThinking';
|
||||||
import LaTeXParsing from './LaTeXParsing';
|
import LaTeXParsing from './LaTeXParsing';
|
||||||
|
import ScrollButton from './ScrollButton';
|
||||||
import ModularChat from './ModularChat';
|
import ModularChat from './ModularChat';
|
||||||
import SaveDraft from './SaveDraft';
|
import SaveDraft from './SaveDraft';
|
||||||
|
|
||||||
|
|
@ -31,6 +32,9 @@ function Chat() {
|
||||||
<div className="pb-3">
|
<div className="pb-3">
|
||||||
<SaveDraft />
|
<SaveDraft />
|
||||||
</div>
|
</div>
|
||||||
|
<div className="pb-3">
|
||||||
|
<ScrollButton />
|
||||||
|
</div>
|
||||||
<ForkSettings />
|
<ForkSettings />
|
||||||
<div className="pb-3">
|
<div className="pb-3">
|
||||||
<ModularChat />
|
<ModularChat />
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { useRecoilState } from 'recoil';
|
import { useRecoilState } from 'recoil';
|
||||||
import HoverCardSettings from '../HoverCardSettings';
|
|
||||||
import { Switch } from '~/components/ui/Switch';
|
import { Switch } from '~/components/ui/Switch';
|
||||||
import useLocalize from '~/hooks/useLocalize';
|
import useLocalize from '~/hooks/useLocalize';
|
||||||
import store from '~/store';
|
import store from '~/store';
|
||||||
|
|
|
||||||
35
client/src/components/Nav/SettingsTabs/Chat/ScrollButton.tsx
Normal file
35
client/src/components/Nav/SettingsTabs/Chat/ScrollButton.tsx
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
import { useRecoilState } from 'recoil';
|
||||||
|
import { Switch } from '~/components/ui/Switch';
|
||||||
|
import useLocalize from '~/hooks/useLocalize';
|
||||||
|
import store from '~/store';
|
||||||
|
|
||||||
|
export default function ScrollButton({
|
||||||
|
onCheckedChange,
|
||||||
|
}: {
|
||||||
|
onCheckedChange?: (value: boolean) => void;
|
||||||
|
}) {
|
||||||
|
const [showScrollButton, setShowScrollButton] = useRecoilState<boolean>(store.showScrollButton);
|
||||||
|
const localize = useLocalize();
|
||||||
|
|
||||||
|
const handleCheckedChange = (value: boolean) => {
|
||||||
|
setShowScrollButton(value);
|
||||||
|
if (onCheckedChange) {
|
||||||
|
onCheckedChange(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<div>{localize('com_nav_scroll_button')}</div>
|
||||||
|
</div>
|
||||||
|
<Switch
|
||||||
|
id="scrollButton"
|
||||||
|
checked={showScrollButton}
|
||||||
|
onCheckedChange={handleCheckedChange}
|
||||||
|
className="ml-4"
|
||||||
|
data-testid="scrollButton"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -882,6 +882,7 @@ export default {
|
||||||
com_nav_command_settings: 'Command Settings',
|
com_nav_command_settings: 'Command Settings',
|
||||||
com_nav_command_settings_description: 'Customize which commands are available in the chat',
|
com_nav_command_settings_description: 'Customize which commands are available in the chat',
|
||||||
com_nav_no_search_results: 'No search results found',
|
com_nav_no_search_results: 'No search results found',
|
||||||
|
com_nav_scroll_button: 'Scroll to the end button',
|
||||||
com_nav_setting_general: 'General',
|
com_nav_setting_general: 'General',
|
||||||
com_nav_setting_chat: 'Chat',
|
com_nav_setting_chat: 'Chat',
|
||||||
com_nav_setting_beta: 'Beta features',
|
com_nav_setting_beta: 'Beta features',
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ const localStorageAtoms = {
|
||||||
chatDirection: atomWithLocalStorage('chatDirection', 'LTR'),
|
chatDirection: atomWithLocalStorage('chatDirection', 'LTR'),
|
||||||
showCode: atomWithLocalStorage(LocalStorageKeys.SHOW_ANALYSIS_CODE, true),
|
showCode: atomWithLocalStorage(LocalStorageKeys.SHOW_ANALYSIS_CODE, true),
|
||||||
saveDrafts: atomWithLocalStorage('saveDrafts', true),
|
saveDrafts: atomWithLocalStorage('saveDrafts', true),
|
||||||
|
showScrollButton: atomWithLocalStorage('showScrollButton', true),
|
||||||
forkSetting: atomWithLocalStorage('forkSetting', ''),
|
forkSetting: atomWithLocalStorage('forkSetting', ''),
|
||||||
splitAtTarget: atomWithLocalStorage('splitAtTarget', false),
|
splitAtTarget: atomWithLocalStorage('splitAtTarget', false),
|
||||||
rememberDefaultFork: atomWithLocalStorage(LocalStorageKeys.REMEMBER_FORK_OPTION, false),
|
rememberDefaultFork: atomWithLocalStorage(LocalStorageKeys.REMEMBER_FORK_OPTION, false),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue