Skip to content

Commit 27b06b0

Browse files
committed
Add tooltips to action buttons in the PromptField component
- 'tootlip details' should be an integral part of the Tooltip component - place 'reference file', 'place symbol', 'prompt templates' in translations. Use tooltips for them. - in prompt field, move 'left' tooltips to where 'right' tooltips are defined
1 parent 19a118a commit 27b06b0

5 files changed

Lines changed: 140 additions & 16 deletions

File tree

‎apps/editor/src/views/panel/frontend/Main/MainView/MainView.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,10 @@ export const MainView: React.FC<Props> = (props) => {
435435
translations={{
436436
invocation_count: t('prompt-field.invocation-count'),
437437
voice_input: t('prompt-field.voice-input'),
438-
exit_voice_input: t('prompt-field.exit-voice-input')
438+
exit_voice_input: t('prompt-field.exit-voice-input'),
439+
reference_file: t('prompt-field.reference-file'),
440+
insert_symbol: t('prompt-field.insert-symbol'),
441+
prompt_templates: t('prompt-field.prompt-templates')
439442
}}
440443
/>
441444
<UiContextUtilisation

‎apps/editor/src/views/panel/frontend/i18n/translations/prompt-field.ts‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,59 @@ export const prompt_field = {
5252
cs: 'Ukončit hlasový vstup',
5353
hu: 'Hangbemenet befejezése',
5454
bg: 'Изход от гласово въвеждане'
55+
},
56+
'prompt-field.reference-file': {
57+
en: 'Reference file',
58+
pl: 'Plik referencyjny',
59+
'zh-cn': '引用文件',
60+
ja: '参照ファイル',
61+
'zh-tw': '引用檔案',
62+
de: 'Referenzdatei',
63+
es: 'Archivo de referencia',
64+
fr: 'Fichier de référence',
65+
'pt-br': 'Arquivo de referência',
66+
ru: 'Эталонный файл',
67+
ko: '참조 파일',
68+
it: 'File di riferimento',
69+
tr: 'Referans dosyası',
70+
cs: 'Referenční soubor',
71+
hu: 'Referencia fájl',
72+
bg: 'Референтен файл'
73+
},
74+
'prompt-field.insert-symbol': {
75+
en: 'Insert symbol',
76+
pl: 'Wstaw symbol',
77+
'zh-cn': '插入符号',
78+
ja: '記号を挿入',
79+
'zh-tw': '插入符號',
80+
de: 'Symbol einfügen',
81+
es: 'Insertar símbolo',
82+
fr: 'Insérer un symbole',
83+
'pt-br': 'Inserir símbolo',
84+
ru: 'Вставить символ',
85+
ko: '기호 삽입',
86+
it: 'Inserisci simbolo',
87+
tr: 'Sembol ekle',
88+
cs: 'Vložit symbol',
89+
hu: 'Szimbólum beszúrása',
90+
bg: 'Вмъкване на символ'
91+
},
92+
'prompt-field.prompt-templates': {
93+
en: 'Prompt templates',
94+
pl: 'Szablony promptów',
95+
'zh-cn': '提示模板',
96+
ja: 'プロンプトテンプレート',
97+
'zh-tw': '提示模板',
98+
de: 'Prompt-Vorlagen',
99+
es: 'Plantillas de prompt',
100+
fr: 'Modèles de prompt',
101+
'pt-br': 'Modelos de prompt',
102+
ru: 'Шаблоны промптов',
103+
ko: '프롬프트 템플릿',
104+
it: 'Modelli di prompt',
105+
tr: 'İstem şablonları',
106+
cs: 'Šablony promptů',
107+
hu: 'Prompt sablonok',
108+
bg: 'Шаблони за промпт'
55109
}
56110
} as const

‎packages/ui/src/components/editor/panel/prompts/PromptField/PromptField.module.scss‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@
173173
height: var(--size);
174174
width: var(--size);
175175
border-radius: 5px;
176+
position: relative;
176177

177178
&:hover {
178179
background-color: var(--vscode-toolbar-hoverBackground);

‎packages/ui/src/components/editor/panel/prompts/PromptField/PromptField.stories.tsx‎

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ export const Empty = () => (
5252
translations={{
5353
invocation_count: 'Invocation count',
5454
voice_input: 'Voice input',
55-
exit_voice_input: 'Exit voice input'
55+
exit_voice_input: 'Exit voice input',
56+
reference_file: 'Reference file',
57+
insert_symbol: 'Insert symbol',
58+
prompt_templates: 'Prompt templates'
5659
}}
5760
/>
5861
)
@@ -104,7 +107,10 @@ export const WithText = () => (
104107
translations={{
105108
invocation_count: 'Invocation count',
106109
voice_input: 'Voice input',
107-
exit_voice_input: 'Exit voice input'
110+
exit_voice_input: 'Exit voice input',
111+
reference_file: 'Reference file',
112+
insert_symbol: 'Insert symbol',
113+
prompt_templates: 'Prompt templates'
108114
}}
109115
/>
110116
)
@@ -156,7 +162,10 @@ export const LongText = () => (
156162
translations={{
157163
invocation_count: 'Invocation count',
158164
voice_input: 'Voice input',
159-
exit_voice_input: 'Exit voice input'
165+
exit_voice_input: 'Exit voice input',
166+
reference_file: 'Reference file',
167+
insert_symbol: 'Insert symbol',
168+
prompt_templates: 'Prompt templates'
160169
}}
161170
/>
162171
)
@@ -208,7 +217,10 @@ export const WithPlaceholderSavedContext = () => (
208217
translations={{
209218
invocation_count: 'Invocation count',
210219
voice_input: 'Voice input',
211-
exit_voice_input: 'Exit voice input'
220+
exit_voice_input: 'Exit voice input',
221+
reference_file: 'Reference file',
222+
insert_symbol: 'Insert symbol',
223+
prompt_templates: 'Prompt templates'
212224
}}
213225
/>
214226
)
@@ -266,7 +278,10 @@ export const WithPlaceholderSelection = () => (
266278
translations={{
267279
invocation_count: 'Invocation count',
268280
voice_input: 'Voice input',
269-
exit_voice_input: 'Exit voice input'
281+
exit_voice_input: 'Exit voice input',
282+
reference_file: 'Reference file',
283+
insert_symbol: 'Insert symbol',
284+
prompt_templates: 'Prompt templates'
270285
}}
271286
/>
272287
)
@@ -318,7 +333,10 @@ export const WithCommit = () => (
318333
translations={{
319334
invocation_count: 'Invocation count',
320335
voice_input: 'Voice input',
321-
exit_voice_input: 'Exit voice input'
336+
exit_voice_input: 'Exit voice input',
337+
reference_file: 'Reference file',
338+
insert_symbol: 'Insert symbol',
339+
prompt_templates: 'Prompt templates'
322340
}}
323341
/>
324342
)
@@ -370,7 +388,10 @@ export const WithCommitWithQuotes = () => (
370388
translations={{
371389
invocation_count: 'Invocation count',
372390
voice_input: 'Voice input',
373-
exit_voice_input: 'Exit voice input'
391+
exit_voice_input: 'Exit voice input',
392+
reference_file: 'Reference file',
393+
insert_symbol: 'Insert symbol',
394+
prompt_templates: 'Prompt templates'
374395
}}
375396
/>
376397
)
@@ -421,7 +442,10 @@ export const WithContextAtCommit = () => (
421442
translations={{
422443
invocation_count: 'Invocation count',
423444
voice_input: 'Voice input',
424-
exit_voice_input: 'Exit voice input'
445+
exit_voice_input: 'Exit voice input',
446+
reference_file: 'Reference file',
447+
insert_symbol: 'Insert symbol',
448+
prompt_templates: 'Prompt templates'
425449
}}
426450
/>
427451
)
@@ -477,7 +501,10 @@ export const WithEditFormatSelector = () => {
477501
translations={{
478502
invocation_count: 'Invocation count',
479503
voice_input: 'Voice input',
480-
exit_voice_input: 'Exit voice input'
504+
exit_voice_input: 'Exit voice input',
505+
reference_file: 'Reference file',
506+
insert_symbol: 'Insert symbol',
507+
prompt_templates: 'Prompt templates'
481508
}}
482509
/>
483510
)
@@ -530,7 +557,10 @@ export const WithFilePaths = () => (
530557
translations={{
531558
invocation_count: 'Invocation count',
532559
voice_input: 'Voice input',
533-
exit_voice_input: 'Exit voice input'
560+
exit_voice_input: 'Exit voice input',
561+
reference_file: 'Reference file',
562+
insert_symbol: 'Insert symbol',
563+
prompt_templates: 'Prompt templates'
534564
}}
535565
/>
536566
)
@@ -610,7 +640,10 @@ export const WithTabs = () => {
610640
translations={{
611641
invocation_count: 'Invocation count',
612642
voice_input: 'Voice input',
613-
exit_voice_input: 'Exit voice input'
643+
exit_voice_input: 'Exit voice input',
644+
reference_file: 'Reference file',
645+
insert_symbol: 'Insert symbol',
646+
prompt_templates: 'Prompt templates'
614647
}}
615648
/>
616649
)
@@ -659,7 +692,10 @@ export const WithWarning = () => (
659692
translations={{
660693
invocation_count: 'Invocation count',
661694
voice_input: 'Voice input',
662-
exit_voice_input: 'Exit voice input'
695+
exit_voice_input: 'Exit voice input',
696+
reference_file: 'Reference file',
697+
insert_symbol: 'Insert symbol',
698+
prompt_templates: 'Prompt templates'
663699
}}
664700
warning="Add a configuration"
665701
/>

‎packages/ui/src/components/editor/panel/prompts/PromptField/PromptField.tsx‎

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export type PromptFieldProps = {
8282
invocation_count: string
8383
voice_input: string
8484
exit_voice_input: string
85+
reference_file: string
86+
insert_symbol: string
87+
prompt_templates: string
8588
}
8689
}
8790

@@ -100,6 +103,9 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
100103
const [is_recording_hovered, set_is_recording_hovered] = useState(false)
101104
const [is_invocation_count_hovered, set_is_invocation_count_hovered] =
102105
useState(false)
106+
const [hovered_left_action, set_hovered_left_action] = useState<
107+
'at' | 'hash' | 'curly' | null
108+
>(null)
103109

104110
useEffect(() => {
105111
if (!props.value) {
@@ -400,6 +406,27 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
400406
}
401407
}}
402408
>
409+
{hovered_left_action == 'at' && (
410+
<Tooltip
411+
message={props.translations.reference_file}
412+
align="left"
413+
offset={9}
414+
/>
415+
)}
416+
{hovered_left_action == 'hash' && (
417+
<Tooltip
418+
message={props.translations.insert_symbol}
419+
align="left"
420+
offset={28}
421+
/>
422+
)}
423+
{hovered_left_action == 'curly' && (
424+
<Tooltip
425+
message={props.translations.prompt_templates}
426+
align="left"
427+
offset={48}
428+
/>
429+
)}
403430
{props.last_choice_tooltip && show_submit_tooltip && (
404431
<Tooltip
405432
message={`Send with ${props.last_choice_tooltip.name}`}
@@ -439,21 +466,24 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
439466
props.on_at_sign_click()
440467
}}
441468
className={cn(styles['footer__left__button'])}
442-
title="Reference File"
469+
onMouseEnter={() => set_hovered_left_action('at')}
470+
onMouseLeave={() => set_hovered_left_action(null)}
443471
>
444472
<Icon variant="AT_SIGN" />
445473
</button>
446474
<button
447475
onClick={props.on_hash_sign_click}
448476
className={cn(styles['footer__left__button'])}
449-
title="Insert Symbol"
477+
onMouseEnter={() => set_hovered_left_action('hash')}
478+
onMouseLeave={() => set_hovered_left_action(null)}
450479
>
451480
<Icon variant="HASH_SIGN" />
452481
</button>
453482
<button
454483
onClick={props.on_curly_braces_click}
455484
className={cn(styles['footer__left__button'])}
456-
title="Prompt Templates"
485+
onMouseEnter={() => set_hovered_left_action('curly')}
486+
onMouseLeave={() => set_hovered_left_action(null)}
457487
>
458488
<Icon variant="CURLY_BRACES" />
459489
</button>

0 commit comments

Comments
 (0)