Skip to content

Commit 44853ab

Browse files
committed
Add tooltips and internationalization for prompt field controls including target switching, task completion, and tab management
- above target, show tooltip 'Change target' - n ../../packages/ui/src/components/editor/common/prompts/PromptField/PromptField.stories.tsx:693:7 TS2741: Property 'change_target' is missing in type '{ voice_input: string; stop_recording: string; reference_file: string; insert_symbol: string; use_template: string; edit_format: string; edit_format_whole: string; edit_format_search_replace: string; ... 15 more ...; clear_session: string; }' but required in type '{ voice_input: string; stop_recording: string; reference_file: string; insert_symbol: string; use_template: string; edit_format: string; edit_format_whole: string; edit_format_search_replace: string; ... 16 more ...; change_target: string; }'. 691 | prompt_token_count={0} 692 | completed_tasks={[]} > 693 | translations={{ | ^^^^^^^^^^^^ 694 | voice_input: 'Voice input', - to the right of checkbox, show tooltip: 'Mark as complete' (should have it's triangle tip on the left edge) - tooltip rendering is incorrect when set to position:right - tooltip when placed on the right of the checkbox, should be moved away from it on distance: 10px - 'change target' tooltip is slightly lower than 'send with' or 'more' - should be on the same vertical level - remove 'more' tooltip - below 'new tab' place 'New tab' tooltip (pointing upwards), also place Clear tab or Close tab tooltip - [Pasted text] - tooltips in top right corner are misaligned and have too big font - tooltip text should not wrap into two lines - allow moving tooltip with additional translate from props - from tooltip, remove translate prop - [Fragment] is not valid BEM should be __icon - should not show 'close tab' tooltip, but 'clear tab' when: there is only one tab, and it's empty ├── apps │ └── editor │ └── src │ └── views │ └── prompt │ └── frontend │ ├── Main │ │ └── MainView │ │ └── MainView.tsx │ └── i18n │ └── translations │ └── prompt-field.ts └── packages └── ui └── src └── components └── editor └── common ├── Tooltip │ ├── Tooltip.module.scss │ ├── Tooltip.tsx │ └── index.ts └── prompts ├── PromptField │ ├── PromptField.module.scss │ ├── PromptField.stories.tsx │ ├── PromptField.tsx │ ├── components │ │ ├── CompletedTasks │ │ │ ├── CompletedTasks.module.scss │ │ │ ├── CompletedTasks.tsx │ │ │ └── index.ts │ │ ├── Footer │ │ │ ├── Footer.module.scss │ │ │ ├── Footer.tsx │ │ │ └── index.ts │ │ └── Tabs │ │ ├── Tabs.module.scss │ │ ├── Tabs.tsx │ │ └── index.ts │ ├── hooks │ │ ├── use-drag-drop.ts │ │ ├── use-dropdown.ts │ │ ├── use-ghost-text.ts │ │ ├── use-handlers │ │ │ ├── handle-copy.ts │ │ │ ├── handle-cut.ts │ │ │ ├── handle-input-change.ts │ │ │ ├── handle-input-click.ts │ │ │ ├── handle-key-down.ts │ │ │ ├── handle-paste.ts │ │ │ ├── handle-submit.ts │ │ │ ├── index.ts │ │ │ ├── types.ts │ │ │ ├── use-handlers.ts │ │ │ └── utils.ts │ │ └── use-keyboard-shortcuts.ts │ └── index.ts ├── Template │ ├── Template.module.scss │ ├── Template.tsx │ └── index.ts └── shared └── symbols ├── caret.ts ├── get-highlighted-text.tsx ├── index.ts ├── position-mapping.ts ├── prompt-symbols.module.scss ├── reconstruct-raw-value.ts └── use-symbol-deletion.ts
1 parent d0951e5 commit 44853ab

10 files changed

Lines changed: 325 additions & 113 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,14 @@ export const MainView: React.FC<Props> = (props) => {
544544
preview_prompt: t('prompt-field.action.preview-prompt'),
545545
send: t('prompt-field.action.send'),
546546
attach_selected_files: t('prompt-field.attach-selected-files'),
547-
more: t('prompt-field.more'),
548547
completed_tasks: t('prompt-field.completed-tasks'),
549548
completed_task: t('prompt-field.completed-task'),
550-
clear_session: t('prompt-field.clear-session')
549+
clear_session: t('prompt-field.clear-session'),
550+
change_target: t('prompt-field.change-target'),
551+
mark_as_complete: t('prompt-field.mark-as-complete'),
552+
new_tab: t('prompt-field.new-tab'),
553+
clear_tab: t('prompt-field.clear-tab'),
554+
close_tab: t('prompt-field.close-tab')
551555
}}
552556
/>
553557
</div>

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

Lines changed: 90 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -359,24 +359,6 @@ export const prompt_field = {
359359
hu: 'Kiválasztott fájlok csatolása',
360360
bg: 'Прикачване на избраните файлове'
361361
},
362-
'prompt-field.more': {
363-
en: 'More',
364-
pl: 'Więcej',
365-
'zh-cn': '更多',
366-
ja: 'もっと見る',
367-
'zh-tw': '更多',
368-
de: 'Mehr',
369-
es: 'Más',
370-
fr: 'Plus',
371-
'pt-br': 'Mais',
372-
ru: 'Ещё',
373-
ko: '더 보기',
374-
it: 'Altro',
375-
tr: 'Daha Fazla',
376-
cs: 'Více',
377-
hu: 'Több',
378-
bg: 'Още'
379-
},
380362
'prompt-field.completed-task': {
381363
en: 'completed task',
382364
pl: 'ukończone zadanie',
@@ -430,5 +412,95 @@ export const prompt_field = {
430412
cs: 'Vymazat relaci',
431413
hu: 'Munkamenet törlése',
432414
bg: 'Изчистване на сесията'
415+
},
416+
'prompt-field.change-target': {
417+
en: 'Change target',
418+
pl: 'Zmień cel',
419+
'zh-cn': '更改目标',
420+
ja: 'ターゲットを変更',
421+
'zh-tw': '更改目標',
422+
de: 'Ziel ändern',
423+
es: 'Cambiar objetivo',
424+
fr: 'Changer la cible',
425+
'pt-br': 'Alterar alvo',
426+
ru: 'Изменить цель',
427+
ko: '대상 변경',
428+
it: 'Cambia destinazione',
429+
tr: 'Hedefi değiştir',
430+
cs: 'Změnit cíl',
431+
hu: 'Cél módosítása',
432+
bg: 'Промяна на целта'
433+
},
434+
'prompt-field.mark-as-complete': {
435+
en: 'Mark as complete',
436+
pl: 'Oznacz jako ukończone',
437+
'zh-cn': '标记为完成',
438+
ja: '完了としてマーク',
439+
'zh-tw': '標記為完成',
440+
de: 'Als erledigt markieren',
441+
es: 'Marcar como completado',
442+
fr: 'Marquer comme terminé',
443+
'pt-br': 'Marcar como concluído',
444+
ru: 'Отметить как выполненное',
445+
ko: '완료로 표시',
446+
it: 'Segna come completato',
447+
tr: 'Tamamlandı olarak işaretle',
448+
cs: 'Označit jako dokončené',
449+
hu: 'Megjelölés befejezettként',
450+
bg: 'Маркиране като завършено'
451+
},
452+
'prompt-field.new-tab': {
453+
en: 'New tab',
454+
pl: 'Nowa karta',
455+
'zh-cn': '新标签页',
456+
ja: '新しいタブ',
457+
'zh-tw': '新分頁',
458+
de: 'Neuer Tab',
459+
es: 'Nueva pestaña',
460+
fr: 'Nouvel onglet',
461+
'pt-br': 'Nova aba',
462+
ru: 'Новая вкладка',
463+
ko: '새 탭',
464+
it: 'Nuova scheda',
465+
tr: 'Yeni sekme',
466+
cs: 'Nová karta',
467+
hu: 'Új lap',
468+
bg: 'Нов раздел'
469+
},
470+
'prompt-field.clear-tab': {
471+
en: 'Clear tab',
472+
pl: 'Wyczyść kartę',
473+
'zh-cn': '清除标签页',
474+
ja: 'タブをクリア',
475+
'zh-tw': '清除分頁',
476+
de: 'Tab leeren',
477+
es: 'Borrar pestaña',
478+
fr: "Effacer l'onglet",
479+
'pt-br': 'Limpar aba',
480+
ru: 'Очистить вкладку',
481+
ko: '탭 지우기',
482+
it: 'Cancella scheda',
483+
tr: 'Sekmeyi temizle',
484+
cs: 'Vymazat kartu',
485+
hu: 'Lap törlése',
486+
bg: 'Изчистване на раздела'
487+
},
488+
'prompt-field.close-tab': {
489+
en: 'Close tab',
490+
pl: 'Zamknij kartę',
491+
'zh-cn': '关闭标签页',
492+
ja: 'タブを閉じる',
493+
'zh-tw': '關閉分頁',
494+
de: 'Tab schließen',
495+
es: 'Cerrar pestaña',
496+
fr: "Fermer l'onglet",
497+
'pt-br': 'Fechar aba',
498+
ru: 'Закрыть вкладку',
499+
ko: '탭 닫기',
500+
it: 'Chiudi scheda',
501+
tr: 'Sekmeyi kapat',
502+
cs: 'Zavřít kartu',
503+
hu: 'Lap bezárása',
504+
bg: 'Затваряне на раздела'
433505
}
434506
} as const

‎packages/ui/src/components/editor/common/Tooltip/Tooltip.module.scss‎

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
.tooltip {
22
position: absolute;
3-
z-index: 2;
43
font-size: 12px;
5-
white-space: normal;
4+
font-weight: 400;
5+
width: max-content;
66
max-width: calc(100vw - 50px);
7-
display: flex;
8-
align-items: center;
9-
gap: 4px;
107
padding: 3px 6px;
118
border-radius: 6px;
129
background-color: var(--vscode-quickInput-background);
@@ -25,8 +22,22 @@
2522
&::after {
2623
content: '';
2724
position: absolute;
28-
border-left: 5px solid transparent;
29-
border-right: 5px solid transparent;
25+
}
26+
27+
&--position-top,
28+
&--position-bottom {
29+
&::after {
30+
border-left: 5px solid transparent;
31+
border-right: 5px solid transparent;
32+
}
33+
}
34+
35+
&--position-left,
36+
&--position-right {
37+
&::after {
38+
border-top: 5px solid transparent;
39+
border-bottom: 5px solid transparent;
40+
}
3041
}
3142

3243
&--position-top {
@@ -45,7 +56,7 @@
4556
transform: translateY(calc(-100% + 1px));
4657
}
4758
&.tooltip--align-center {
48-
transform: translateX(-50%) translateY(calc(-100% - 4px));
59+
transform: translateX(-50%) translateY(calc(-100% - 5px));
4960
}
5061
}
5162

@@ -69,29 +80,51 @@
6980
}
7081
}
7182

72-
&--align-left {
73-
left: 2px;
83+
&--position-right {
84+
left: 100%;
85+
top: 50%;
86+
7487
&::after {
75-
left: var(--tooltip-offset);
88+
left: -4.5px;
89+
border-right: 5px solid var(--vscode-quickInput-background);
90+
filter: drop-shadow(-1px 0 0.5px var(--cwc-border-color-dimmed));
7691
}
77-
}
78-
&--align-right {
79-
right: 2px;
80-
&::after {
81-
right: var(--tooltip-offset);
92+
93+
&.tooltip--align-center {
94+
transform: translateY(-50%) translateX(6px);
95+
96+
&::after {
97+
top: 50%;
98+
margin-top: -5px;
99+
}
82100
}
83101
}
84-
&--align-center {
85-
left: 50%;
86-
white-space: nowrap;
87-
&::after {
102+
103+
&--position-top,
104+
&--position-bottom {
105+
&.tooltip--align-left {
106+
left: 2px;
107+
&::after {
108+
left: var(--tooltip-offset);
109+
}
110+
}
111+
&.tooltip--align-right {
112+
right: 2px;
113+
&::after {
114+
right: var(--tooltip-offset);
115+
}
116+
}
117+
&.tooltip--align-center {
88118
left: 50%;
89-
margin-left: -5px;
119+
&::after {
120+
left: 50%;
121+
margin-left: -5px;
122+
}
90123
}
91124
}
92125

93126
&__details {
94-
margin-left: 4px;
127+
margin-left: 5px;
95128
opacity: var(--dimmed-opacity);
96129
}
97130
}

‎packages/ui/src/components/editor/common/Tooltip/Tooltip.tsx‎

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,42 @@ import React from 'react'
22
import cn from 'classnames'
33
import styles from './Tooltip.module.scss'
44

5-
export type TooltipProps = {
5+
type Props = {
66
message: React.ReactNode
77
align?: 'left' | 'right' | 'center'
8-
position?: 'top' | 'bottom'
8+
position?: 'top' | 'bottom' | 'right'
99
is_warning?: boolean
1010
details?: React.ReactNode
1111
offset?: number
1212
}
1313

14-
export const Tooltip: React.FC<TooltipProps> = (params) => (
15-
<div
16-
className={cn(styles.tooltip, {
17-
[styles['tooltip--align-left']]: params.align == 'left',
18-
[styles['tooltip--align-right']]: params.align == 'right',
19-
[styles['tooltip--align-center']]: (params.align || 'center') == 'center',
20-
[styles['tooltip--position-top']]: (params.position || 'top') == 'top',
21-
[styles['tooltip--position-bottom']]: params.position == 'bottom',
22-
[styles['tooltip--warning']]: params.is_warning
23-
})}
24-
style={
25-
params.offset !== undefined
26-
? ({ '--tooltip-offset': `${params.offset}px` } as React.CSSProperties)
27-
: undefined
28-
}
29-
>
30-
<span>
31-
{params.message}
32-
{params.details && (
33-
<span className={styles.tooltip__details}>{params.details}</span>
34-
)}
35-
</span>
36-
</div>
37-
)
14+
export const Tooltip: React.FC<Props> = (params) => {
15+
const style = {
16+
...(params.offset !== undefined
17+
? { '--tooltip-offset': `${params.offset}px` }
18+
: {})
19+
} as React.CSSProperties
20+
21+
return (
22+
<div
23+
className={cn(styles.tooltip, {
24+
[styles['tooltip--align-left']]: params.align == 'left',
25+
[styles['tooltip--align-right']]: params.align == 'right',
26+
[styles['tooltip--align-center']]:
27+
(params.align || 'center') == 'center',
28+
[styles['tooltip--position-top']]: (params.position || 'top') == 'top',
29+
[styles['tooltip--position-bottom']]: params.position == 'bottom',
30+
[styles['tooltip--position-right']]: params.position == 'right',
31+
[styles['tooltip--warning']]: params.is_warning
32+
})}
33+
style={Object.keys(style).length > 0 ? style : undefined}
34+
>
35+
<span>
36+
{params.message}
37+
{params.details && (
38+
<span className={styles.tooltip__details}>{params.details}</span>
39+
)}
40+
</span>
41+
</div>
42+
)
43+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
float: right;
8383
display: flex;
8484
align-items: center;
85-
margin: 3px 5px 0 4px;
85+
padding: 3px 0 0 4px;
8686
position: relative;
8787
z-index: 2;
8888
gap: 4px;

0 commit comments

Comments
 (0)