Skip to content

Commit 6070532

Browse files
committed
Add tooltips to hover buttons
Add placeholder for about page Fixes #56 Partial #27
1 parent 954d86f commit 6070532

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

src/AiResponse.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ function AiImageResponse({imageUrl, prompt, rejectImage}: AiImageResponseProps):
3131
return (
3232
<View style={[styles.horizontalContainer, {flexWrap: 'nowrap', alignItems: 'flex-start'}]}>
3333
<Pressable
34-
onPress={() => Linking.openURL(imageUrl)}>
34+
onPress={() => {
35+
if (imageUrl) {
36+
Linking.openURL(imageUrl);
37+
}
38+
}}>
3539
<Image
3640
source={{uri: imageUrl}}
3741
alt={prompt}
@@ -133,9 +137,9 @@ function AiSection({children, isLoading, contentShownOnHover}: AiSectionProps):
133137
<View style={{flexDirection: 'row'}}>
134138
<Text style={[styles.sectionTitle, {flexGrow: 1}]}>AI</Text>
135139
{hovering && contentShownOnHover}
136-
{hovering && <HoverButton content="📋" onPress={() => console.log("Copy: Not yet implemented")}/>}
137-
<HoverButton content="👍" onPress={() => { showFeedbackPopup(true); }}/>
138-
<HoverButton content="👎" onPress={() => { showFeedbackPopup(false); }}/>
140+
{hovering && <HoverButton content="📋" tooltip="Copy to clipboard" onPress={() => console.log("Copy: Not yet implemented")}/>}
141+
<HoverButton content="👍" tooltip="Give positive feedback" onPress={() => { showFeedbackPopup(true); }}/>
142+
<HoverButton content="👎" tooltip="Give negative feedback" onPress={() => { showFeedbackPopup(false); }}/>
139143
</View>
140144
{isLoading &&
141145
<ActivityIndicator/>

src/Chat.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ function Chat({entries, humanText, onPrompt, clearConversation}: ChatProps): JSX
173173
disableEdit={true}
174174
disableCopy={true}
175175
contentShownOnHover={
176-
<HoverButton content="⚙️" onPress={() => setShowSettingsPopup(true)}/>
176+
<>
177+
<HoverButton content="❔" tooltip="About" onPress={() => console.log("About dialog: Not yet implemented")}/>
178+
<HoverButton content="⚙️" tooltip="Settings" onPress={() => setShowSettingsPopup(true)}/>
179+
</>
177180
}>
178181
<ChatEntry
179182
defaultText={humanText}

src/Controls.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import {
33
Button,
44
Image,
5+
ImageSourcePropType,
56
Linking,
67
Pressable,
78
Text,
@@ -13,22 +14,24 @@ import { CodeBlock } from './CodeBlock';
1314

1415
type HoverButtonProps = {
1516
content: string;
17+
tooltip: string,
1618
onPress: () => void;
1719
};
18-
function HoverButton({content, onPress}: HoverButtonProps): JSX.Element {
20+
function HoverButton({content, tooltip, onPress}: HoverButtonProps): JSX.Element {
1921
const [hovering, setHovering] = React.useState(false);
2022

2123
const backgroundBaseStyle = {padding: 2, borderRadius: 8, borderWidth: 1, borderColor: 'transparent'};
2224
const backgroundPressedStyle = {borderColor: 'white', backgroundColor: 'black'};
2325
const backgroundHoverStyle = {borderColor: 'white', backgroundColor: 'gray'};
2426
return (
2527
<Pressable
28+
tooltip={tooltip}
2629
onPress={onPress}
2730
onHoverIn={() => setHovering(true)}
2831
onHoverOut={() => setHovering(false)}>
2932
{({pressed}) => (
3033
<View style={[backgroundBaseStyle, pressed ? backgroundPressedStyle : hovering ? backgroundHoverStyle : null]}>
31-
<Text >{content}</Text>
34+
<Text>{content}</Text>
3235
</View>
3336
)}
3437
</Pressable>

src/HumanQuery.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type HumanSectionProps = PropsWithChildren<{
1414
content?: string;
1515
disableEdit?: boolean;
1616
disableCopy?: boolean;
17-
contentShownOnHover?: JSX.Element;
17+
contentShownOnHover?: React.ReactNode;
1818
}>;
1919
function HumanSection({children, content, disableEdit, disableCopy, contentShownOnHover}: HumanSectionProps): JSX.Element {
2020
const [hovering, setHovering] = React.useState(false);
@@ -27,8 +27,8 @@ function HumanSection({children, content, disableEdit, disableCopy, contentShown
2727
onHoverOut={() => setHovering(false)}>
2828
<View style={{flexDirection: 'row', minHeight: 26}}>
2929
<Text style={[styles.sectionTitle, {flexGrow: 1}]}>HUMAN</Text>
30-
{hovering && !disableCopy && <HoverButton content="📋" onPress={() => Clipboard.setString(content ?? "")}/>}
31-
{hovering && !disableEdit && <HoverButton content="📝" onPress={() => {console.log("Edit: Not yet implemented")}}/>}
30+
{hovering && !disableCopy && <HoverButton content="📋" tooltip="Copy to clipboard" onPress={() => Clipboard.setString(content ?? "")}/>}
31+
{hovering && !disableEdit && <HoverButton content="📝" tooltip="Edit" onPress={() => {console.log("Edit: Not yet implemented")}}/>}
3232
{hovering && contentShownOnHover}
3333
</View>
3434
{content ? <Text>{content}</Text> : null}

0 commit comments

Comments
 (0)