Skip to content

Commit

Permalink
improve padding and icon sizes for mobile prompt (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
menghif authored Jun 17, 2024
1 parent 3d2de0f commit fa04130
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 53 deletions.
1 change: 1 addition & 0 deletions src/Chat/ChatHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ function ChatHeader({ chat }: ChatHeaderProps) {
bg="white"
_dark={{ bg: "gray.700" }}
size="sm"
borderRadius={4}
fontSize="1rem"
w="100%"
autoFocus={true}
Expand Down
3 changes: 2 additions & 1 deletion src/components/OptionsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ function OptionsButton({
<IconButton
aria-label="Options menu"
isDisabled={isDisabled}
size="lg"
size="md"
fontSize="1.25rem"
variant="outline"
icon={<PiGearBold />}
isRound
Expand Down
4 changes: 2 additions & 2 deletions src/components/PromptForm/DesktopPromptForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function KeyboardHint({ isVisible }: KeyboardHintProps) {
}

return (
<Text fontSize="sm" color="gray">
<Text fontSize="sm" color="gray" px={2}>
<span>
{settings.enterBehaviour === "newline" ? (
<span>
Expand Down Expand Up @@ -316,7 +316,7 @@ function DesktopPromptForm({
<Flex dir="column" w="100%" h="100%">
<Card flex={1} my={3} mx={1}>
<chakra.form onSubmit={handlePromptSubmit} h="100%">
<CardBody h="100%" p={6}>
<CardBody h="100%" px={6} py={4}>
<VStack w="100%" h="100%" gap={3}>
<InputGroup
h="100%"
Expand Down
4 changes: 2 additions & 2 deletions src/components/PromptForm/MicIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ export default function MicIcon({
variant={isRecording ? "solid" : isMobile ? "outline" : "ghost"}
colorScheme={isRecording ? "red" : "blue"}
aria-label="Record speech"
size={isRecording ? "lg" : "md"}
size="md"
transition={"all 150ms ease-in-out"}
fontSize="18px"
fontSize="1.25rem"
ref={micIconRef}
onClick={handleMicToggle}
onBlur={() => onRecordingCancel()}
Expand Down
11 changes: 5 additions & 6 deletions src/components/PromptForm/MobilePromptForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ function MobilePromptForm({
};

return (
<Box flex={1} w="100%" h="100%" px={1} pt={2} pb={4}>
<Box flex={1} w="100%" h="100%" my={1} px={2} py={1}>
<chakra.form onSubmit={handlePromptSubmit} h="100%">
<Flex mt={2} pb={2} px={1} alignItems="end" gap={2}>
<Flex alignItems="end" gap={2}>
<OptionsButton
chat={chat}
forkUrl={forkUrl}
Expand Down Expand Up @@ -222,7 +222,7 @@ function MobilePromptForm({
))}
</Flex>
{inputType === "audio" ? (
<Box py={2} px={1}>
<Box p={2}>
<AudioStatus
isRecording={isRecording}
isTranscribing={isTranscribing}
Expand All @@ -241,12 +241,11 @@ function MobilePromptForm({
_dark={{ bg: "gray.700" }}
overflowY="auto"
placeholder="Ask about..."
mb={1}
/>
)}
</Box>

{isTranscriptionSupported() && (
{isTranscriptionSupported() && !isTranscribing && !prompt && (
<MicIcon
isDisabled={isLoading}
onRecording={handleRecording}
Expand All @@ -256,7 +255,7 @@ function MobilePromptForm({
/>
)}

<PromptSendButton isLoading={isLoading} />
{!isRecording && <PromptSendButton isLoading={isLoading} />}
</Flex>
</chakra.form>
</Box>
Expand Down
80 changes: 38 additions & 42 deletions src/components/PromptForm/PromptSendButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,56 +63,20 @@ function MobilePromptSendButton({ isLoading }: PromptSendButtonProps) {
<Menu placement="top" strategy="fixed" closeOnSelect={false} offset={[-90, 0]}>
<IconButton
type="submit"
size="lg"
size="md"
fontSize="1.375rem"
width="2.75rem"
variant="solid"
isRound
aria-label="Submit"
isLoading={isLoading}
icon={<TbSend />}
/>
{isTtsSupported && (
<Tooltip
label={
settings.textToSpeech.announceMessages
? "Text-to-Speech Enabled"
: "Text-to-Speech Disabled"
}
>
<IconButton
type="button"
size="lg"
variant="solid"
aria-label={
settings.textToSpeech.announceMessages
? "Text-to-Speech Enabled"
: "Text-to-Speech Disabled"
}
icon={
settings.textToSpeech.announceMessages ? (
<MdVolumeUp size={25} />
) : (
<MdVolumeOff size={25} />
)
}
onClick={() => {
if (settings.textToSpeech.announceMessages) {
// Flush any remaining audio clips being announced
clearAudioQueue();
}
setSettings({
...settings,
textToSpeech: {
...settings.textToSpeech,
announceMessages: !settings.textToSpeech.announceMessages,
},
});
}}
/>
</Tooltip>
)}
<MenuButton
as={IconButton}
size="lg"
size="md"
width="2.75rem"
fontSize="1.375rem"
isRound
variant="solid"
aria-label="Choose Model"
Expand Down Expand Up @@ -181,6 +145,37 @@ function MobilePromptSendButton({ isLoading }: PromptSendButtonProps) {
/>
</InputGroup>
</MenuGroup>
{isTtsSupported && (
<>
<MenuDivider />
<MenuItem
icon={
settings.textToSpeech.announceMessages ? (
<MdVolumeUp style={{ fontSize: "1.25rem" }} />
) : (
<MdVolumeOff style={{ fontSize: "1.25rem" }} />
)
}
onClick={() => {
if (settings.textToSpeech.announceMessages) {
// Flush any remaining audio clips being announced
clearAudioQueue();
}
setSettings({
...settings,
textToSpeech: {
...settings.textToSpeech,
announceMessages: !settings.textToSpeech.announceMessages,
},
});
}}
>
{settings.textToSpeech.announceMessages
? "Text-to-Speech Enabled"
: "Text-to-Speech Disabled"}
</MenuItem>
</>
)}
</MenuList>
</Menu>
</ButtonGroup>
Expand Down Expand Up @@ -271,6 +266,7 @@ function DesktopPromptSendButton({ isLoading }: PromptSendButtonProps) {
<MenuButton
as={IconButton}
size="sm"
fontSize="1.25rem"
aria-label="Choose Model"
title="Choose Model"
icon={<TbChevronUp />}
Expand Down

0 comments on commit fa04130

Please sign in to comment.