-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎛️ refactor: Add keyboard command toggles & only trigger for the 1st …
…character (#3566) * refactor: Improve handling of key up events in useHandleKeyUp hook to only trigger for first char and fix linter issues * refactor: Update Beta component styling with theme twcss variables * refactor: theming for Settings, add toggle enable/disable keyboard commands
- Loading branch information
1 parent
270c6d2
commit 01a8899
Showing
12 changed files
with
224 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
client/src/components/Nav/SettingsTabs/Commands/AtCommandSwitch.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useRecoilState } from 'recoil'; | ||
import { Switch } from '~/components/ui'; | ||
import { useLocalize } from '~/hooks'; | ||
import store from '~/store'; | ||
|
||
export default function AtCommandSwitch() { | ||
const [atCommand, setAtCommand] = useRecoilState<boolean>(store.atCommand); | ||
const localize = useLocalize(); | ||
|
||
const handleCheckedChange = (value: boolean) => { | ||
setAtCommand(value); | ||
}; | ||
|
||
return ( | ||
<div className="flex items-center justify-between"> | ||
<div>{localize('com_nav_at_command_description')}</div> | ||
<Switch | ||
id="atCommand" | ||
checked={atCommand} | ||
onCheckedChange={handleCheckedChange} | ||
className="ml-4 mt-2" | ||
data-testid="atCommand" | ||
/> | ||
</div> | ||
); | ||
} |
30 changes: 30 additions & 0 deletions
30
client/src/components/Nav/SettingsTabs/Commands/Commands.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { memo } from 'react'; | ||
import * as Tabs from '@radix-ui/react-tabs'; | ||
import { SettingsTabValues } from 'librechat-data-provider'; | ||
import SlashCommandSwitch from './SlashCommandSwitch'; | ||
import PlusCommandSwitch from './PlusCommandSwitch'; | ||
import AtCommandSwitch from './AtCommandSwitch'; | ||
|
||
function Commands() { | ||
return ( | ||
<Tabs.Content | ||
value={SettingsTabValues.COMMANDS} | ||
role="tabpanel" | ||
className="w-full md:min-h-[271px]" | ||
> | ||
<div className="flex flex-col gap-3 text-sm text-text-primary"> | ||
<div className="border-b border-border-medium pb-3 last-of-type:border-b-0"> | ||
<AtCommandSwitch /> | ||
</div> | ||
<div className="border-b border-border-medium pb-3 last-of-type:border-b-0"> | ||
<PlusCommandSwitch /> | ||
</div> | ||
<div className="border-b border-border-medium pb-3 last-of-type:border-b-0"> | ||
<SlashCommandSwitch /> | ||
</div> | ||
</div> | ||
</Tabs.Content> | ||
); | ||
} | ||
|
||
export default memo(Commands); |
26 changes: 26 additions & 0 deletions
26
client/src/components/Nav/SettingsTabs/Commands/PlusCommandSwitch.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useRecoilState } from 'recoil'; | ||
import { Switch } from '~/components/ui'; | ||
import { useLocalize } from '~/hooks'; | ||
import store from '~/store'; | ||
|
||
export default function PlusCommandSwitch() { | ||
const [plusCommand, setPlusCommand] = useRecoilState<boolean>(store.plusCommand); | ||
const localize = useLocalize(); | ||
|
||
const handleCheckedChange = (value: boolean) => { | ||
setPlusCommand(value); | ||
}; | ||
|
||
return ( | ||
<div className="flex items-center justify-between"> | ||
<div>{localize('com_nav_plus_command_description')}</div> | ||
<Switch | ||
id="plusCommand" | ||
checked={plusCommand} | ||
onCheckedChange={handleCheckedChange} | ||
className="ml-4 mt-2" | ||
data-testid="plusCommand" | ||
/> | ||
</div> | ||
); | ||
} |
26 changes: 26 additions & 0 deletions
26
client/src/components/Nav/SettingsTabs/Commands/SlashCommandSwitch.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useRecoilState } from 'recoil'; | ||
import { Switch } from '~/components/ui'; | ||
import { useLocalize } from '~/hooks'; | ||
import store from '~/store'; | ||
|
||
export default function SlashCommandSwitch() { | ||
const [slashCommand, setSlashCommand] = useRecoilState<boolean>(store.slashCommand); | ||
const localize = useLocalize(); | ||
|
||
const handleCheckedChange = (value: boolean) => { | ||
setSlashCommand(value); | ||
}; | ||
|
||
return ( | ||
<div className="flex items-center justify-between"> | ||
<div>{localize('com_nav_slash_command_description')}</div> | ||
<Switch | ||
id="slashCommand" | ||
checked={slashCommand} | ||
onCheckedChange={handleCheckedChange} | ||
className="ml-4 mt-2" | ||
data-testid="slashCommand" | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.