Skip to content

Commit 9b712a7

Browse files
committed
Simplify mode buttons by removing subtitle text and updating mode names to Web and API
- simplify mode buttons; left should show 'WEB', right should show 'API' - for modes in main's header, use WEB/API labels, like in home - should use `apps/editor/src/views/prompt/types/main-view-mode.ts` for labels in home and main's header - translate 'Tokens in context' ├── apps │ └── editor │ └── src │ └── views │ └── prompt │ ├── frontend │ │ ├── Home │ │ │ └── Home.tsx │ │ ├── Main │ │ │ └── MainView │ │ │ ├── MainView.module.scss │ │ │ ├── MainView.tsx │ │ │ ├── components │ │ │ │ └── Header │ │ │ │ ├── Header.module.scss │ │ │ │ ├── Header.tsx │ │ │ │ ├── hooks │ │ │ │ │ └── use-keyboard-shortcuts.ts │ │ │ │ └── index.ts │ │ │ ├── hooks │ │ │ │ ├── use-invocation-counts.ts │ │ │ │ ├── use-last-choice-tooltip.ts │ │ │ │ └── use-re-render-on-interval.ts │ │ │ ├── index.ts │ │ │ └── prompt-type-labels.ts │ │ └── i18n │ │ ├── translations │ │ │ ├── actions.ts │ │ │ ├── configurations.ts │ │ │ ├── footer.ts │ │ │ ├── header.ts │ │ │ ├── home.ts │ │ │ ├── index.ts │ │ │ ├── modals.ts │ │ │ ├── prompt-field.ts │ │ │ └── recent-donations.ts │ │ └── use-translation.tsx │ └── types │ └── main-view-mode.ts └── packages └── ui └── src └── components └── editor ├── common │ └── prompts │ └── PromptField │ ├── PromptField.module.scss │ ├── PromptField.stories.tsx │ ├── PromptField.tsx │ ├── components │ │ ├── Tooltip.module.scss │ │ ├── Tooltip.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 └── prompt └── ModeButton ├── ModeButton.module.scss ├── ModeButton.stories.tsx ├── ModeButton.tsx └── index.ts
1 parent b78cfd6 commit 9b712a7

12 files changed

Lines changed: 60 additions & 149 deletions

File tree

‎apps/editor/src/views/prompt/frontend/Home/Home.module.scss‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
&__left {
3333
display: flex;
3434
align-items: center;
35-
gap: 4px;
35+
gap: 6px;
3636
}
3737

3838
&__right {

‎apps/editor/src/views/prompt/frontend/Home/Home.tsx‎

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Tasks as UiTasks } from '@ui/components/editor/prompt/Tasks'
1616
import { use_tasks } from './hooks/use-tasks'
1717
import { use_has_scrolled_past_mode_button } from './hooks/use-has-scrolled-past-mode-button'
1818
import { use_compacting } from '@shared/hooks'
19+
import { MODE } from '@/views/prompt/types/main-view-mode'
1920

2021
type Props = {
2122
vscode: any
@@ -127,19 +128,13 @@ export const Home: React.FC<Props> = (props) => {
127128
})}
128129
>
129130
<UiModeButton
130-
pre={
131-
props.is_connected
132-
? t('home.mode.autofill')
133-
: t('home.mode.copy-prompt')
134-
}
135-
label={t('home.mode.chatbots')}
131+
label={MODE.WEB}
136132
on_click={props.on_chatbots_click}
137133
is_compact
138134
/>
139135
<div className={styles['header__modes-divider']} />
140136
<UiModeButton
141-
pre={t('home.mode.make')}
142-
label={t('home.mode.api-calls')}
137+
label={MODE.API}
143138
on_click={props.on_api_calls_click}
144139
is_compact
145140
/>
@@ -171,20 +166,8 @@ export const Home: React.FC<Props> = (props) => {
171166

172167
<div className={styles.inner__mode} ref={mode_ref}>
173168
<AsciiArtEffect />
174-
<UiModeButton
175-
pre={
176-
props.is_connected
177-
? t('home.mode.autofill')
178-
: t('home.mode.copy-prompt')
179-
}
180-
label={t('home.mode.chatbots')}
181-
on_click={props.on_chatbots_click}
182-
/>
183-
<UiModeButton
184-
pre={t('home.mode.make')}
185-
label={t('home.mode.api-calls')}
186-
on_click={props.on_api_calls_click}
187-
/>
169+
<UiModeButton label={MODE.WEB} on_click={props.on_chatbots_click} />
170+
<UiModeButton label={MODE.API} on_click={props.on_api_calls_click} />
188171
</div>
189172

190173
<UiSeparator height={8} />

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,8 @@ export const MainView: React.FC<Props> = (props) => {
377377
send_with_ellipsis: t('prompt-field.action.send-with-ellipsis'),
378378
copy_prompt: t('prompt-field.action.copy-prompt'),
379379
more_actions: t('prompt-field.action.more-actions'),
380-
send: t('prompt-field.action.send')
380+
send: t('prompt-field.action.send'),
381+
tokens_in_context: t('prompt-field.tokens-in-context')
381382
}}
382383
/>
383384
</div>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export const Header: React.FC<Props> = (props) => {
4545
title={`${t('header.return')} (Esc)`}
4646
/>
4747
<UiModeToggler
48-
mode={props.mode == MODE.WEB ? 'Chatbots' : 'API Calls'}
49-
alt_mode={props.mode == MODE.WEB ? 'API Calls' : 'Chatbots'}
48+
mode={props.mode == MODE.WEB ? MODE.WEB : MODE.API}
49+
alt_mode={props.mode == MODE.WEB ? MODE.API : MODE.WEB}
5050
is_alt_pressed={is_alt_pressed}
5151
on_toggle={() =>
5252
props.on_mode_change(

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

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -107,96 +107,6 @@ export const home = {
107107
hu: 'Szerzői jog © {year} {link}',
108108
bg: 'Авторско право © {year} {link}'
109109
},
110-
'home.mode.copy-prompt': {
111-
en: 'Copy prompt',
112-
pl: 'Skopiuj prompt',
113-
'zh-cn': '复制提示词',
114-
ja: 'プロンプトをコピー',
115-
'zh-tw': '複製提示詞',
116-
de: 'Prompt kopieren',
117-
es: 'Copiar prompt',
118-
fr: 'Copier le prompt',
119-
'pt-br': 'Copiar prompt',
120-
ru: 'Скопировать промпт',
121-
ko: '프롬프트 복사',
122-
it: 'Copia prompt',
123-
tr: 'İstemi kopyala',
124-
cs: 'Kopírovat prompt',
125-
hu: 'Prompt másolása',
126-
bg: 'Копиране на промпта'
127-
},
128-
'home.mode.autofill': {
129-
en: 'Autofill',
130-
pl: 'Autouzupełnij',
131-
'zh-cn': '自动填充',
132-
ja: '自動入力',
133-
'zh-tw': '自動填入',
134-
de: 'Automatisch ausfüllen',
135-
es: 'Autocompletar',
136-
fr: 'Saisie automatique',
137-
'pt-br': 'Preenchimento automático',
138-
ru: 'Автозаполнение',
139-
ko: '자동 완성',
140-
it: 'Compilazione automatica',
141-
tr: 'Otomatik doldur',
142-
cs: 'Automatické vyplnění',
143-
hu: 'Automatikus kitöltés',
144-
bg: 'Автоматично попълване'
145-
},
146-
'home.mode.make': {
147-
en: 'Make',
148-
pl: 'Wykonaj',
149-
'zh-cn': '执行',
150-
ja: '実行',
151-
'zh-tw': '執行',
152-
de: 'Ausführen',
153-
es: 'Realizar',
154-
fr: 'Effectuer',
155-
'pt-br': 'Realizar',
156-
ru: 'Выполнить',
157-
ko: '실행',
158-
it: 'Esegui',
159-
tr: 'Gerçekleştir',
160-
cs: 'Provést',
161-
hu: 'Végrehajtás',
162-
bg: 'Изпълни'
163-
},
164-
'home.mode.chatbots': {
165-
en: 'Chatbots',
166-
pl: 'Czatboty',
167-
'zh-cn': '聊天机器人',
168-
ja: 'チャットボット',
169-
'zh-tw': '聊天機器人',
170-
de: 'Chatbots',
171-
es: 'Chatbots',
172-
fr: 'Chatbots',
173-
'pt-br': 'Chatbots',
174-
ru: 'Чат-боты',
175-
ko: '챗봇',
176-
it: 'Chatbot',
177-
tr: 'Sohbet Botları',
178-
cs: 'Chatboti',
179-
hu: 'Chatbotok',
180-
bg: 'Чатботове'
181-
},
182-
'home.mode.api-calls': {
183-
en: 'API calls',
184-
pl: 'Żądania API',
185-
'zh-cn': 'API 调用',
186-
ja: 'API呼び出し',
187-
'zh-tw': 'API 呼叫',
188-
de: 'API-Aufrufe',
189-
es: 'Llamadas API',
190-
fr: 'Appels API',
191-
'pt-br': 'Chamadas de API',
192-
ru: 'Вызовы API',
193-
ko: 'API 호출',
194-
it: 'Chiamate API',
195-
tr: 'API çağrıları',
196-
cs: 'Volání API',
197-
hu: 'API hívások',
198-
bg: 'API заявки'
199-
},
200110
'home.shrink-source-code': {
201111
en: 'Strip function bodies',
202112
pl: 'Usuń ciała funkcji',

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,5 +358,23 @@ export const prompt_field = {
358358
cs: 'Odeslat',
359359
hu: 'Küldés',
360360
bg: 'Изпращане'
361+
},
362+
'prompt-field.tokens-in-context': {
363+
en: 'Tokens in context',
364+
pl: 'Tokeny w kontekście',
365+
'zh-cn': '上下文中的令牌数',
366+
ja: 'コンテキスト内のトークン数',
367+
'zh-tw': '上下文中的權杖數',
368+
de: 'Tokens im Kontext',
369+
es: 'Tokens en contexto',
370+
fr: 'Tokens dans le contexte',
371+
'pt-br': 'Tokens no contexto',
372+
ru: 'Токены в контексте',
373+
ko: '컨텍스트 내 토큰 수',
374+
it: 'Token nel contesto',
375+
tr: 'Bağlamdaki belirteçler',
376+
cs: 'Tokeny v kontextu',
377+
hu: 'Tokenek a kontextusban',
378+
bg: 'Токени в контекста'
361379
}
362380
} as const
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const MODE = {
2-
WEB: 'CHATBOTS',
3-
API: 'API CALLS'
2+
WEB: 'WEB',
3+
API: 'API'
44
}
55

66
export type Mode = (typeof MODE)[keyof typeof MODE]

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

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ export const Empty = () => (
6666
send_with_ellipsis: 'Send with...',
6767
copy_prompt: 'Copy prompt',
6868
more_actions: 'More actions',
69-
send: 'Send'
69+
send: 'Send',
70+
tokens_in_context: 'Tokens in context'
7071
}}
7172
/>
7273
)
@@ -132,7 +133,8 @@ export const WithText = () => (
132133
send_with_ellipsis: 'Send with...',
133134
copy_prompt: 'Copy prompt',
134135
more_actions: 'More actions',
135-
send: 'Send'
136+
send: 'Send',
137+
tokens_in_context: 'Tokens in context'
136138
}}
137139
/>
138140
)
@@ -198,7 +200,8 @@ export const LongText = () => (
198200
send_with_ellipsis: 'Send with...',
199201
copy_prompt: 'Copy prompt',
200202
more_actions: 'More actions',
201-
send: 'Send'
203+
send: 'Send',
204+
tokens_in_context: 'Tokens in context'
202205
}}
203206
/>
204207
)
@@ -264,7 +267,8 @@ export const WithPlaceholderSavedContext = () => (
264267
send_with_ellipsis: 'Send with...',
265268
copy_prompt: 'Copy prompt',
266269
more_actions: 'More actions',
267-
send: 'Send'
270+
send: 'Send',
271+
tokens_in_context: 'Tokens in context'
268272
}}
269273
/>
270274
)
@@ -336,7 +340,8 @@ export const WithPlaceholderSelection = () => (
336340
send_with_ellipsis: 'Send with...',
337341
copy_prompt: 'Copy prompt',
338342
more_actions: 'More actions',
339-
send: 'Send'
343+
send: 'Send',
344+
tokens_in_context: 'Tokens in context'
340345
}}
341346
/>
342347
)
@@ -402,7 +407,8 @@ export const WithCommit = () => (
402407
send_with_ellipsis: 'Send with...',
403408
copy_prompt: 'Copy prompt',
404409
more_actions: 'More actions',
405-
send: 'Send'
410+
send: 'Send',
411+
tokens_in_context: 'Tokens in context'
406412
}}
407413
/>
408414
)
@@ -468,7 +474,8 @@ export const WithCommitWithQuotes = () => (
468474
send_with_ellipsis: 'Send with...',
469475
copy_prompt: 'Copy prompt',
470476
more_actions: 'More actions',
471-
send: 'Send'
477+
send: 'Send',
478+
tokens_in_context: 'Tokens in context'
472479
}}
473480
/>
474481
)
@@ -539,7 +546,8 @@ export const WithEditFormatSelector = () => {
539546
send_with_ellipsis: 'Send with...',
540547
copy_prompt: 'Copy prompt',
541548
more_actions: 'More actions',
542-
send: 'Send'
549+
send: 'Send',
550+
tokens_in_context: 'Tokens in context'
543551
}}
544552
/>
545553
)
@@ -606,7 +614,8 @@ export const WithFilePaths = () => (
606614
send_with_ellipsis: 'Send with...',
607615
copy_prompt: 'Copy prompt',
608616
more_actions: 'More actions',
609-
send: 'Send'
617+
send: 'Send',
618+
tokens_in_context: 'Tokens in context'
610619
}}
611620
/>
612621
)
@@ -700,7 +709,8 @@ export const WithTabs = () => {
700709
send_with_ellipsis: 'Send with...',
701710
copy_prompt: 'Copy prompt',
702711
more_actions: 'More actions',
703-
send: 'Send'
712+
send: 'Send',
713+
tokens_in_context: 'Tokens in context'
704714
}}
705715
/>
706716
)
@@ -765,7 +775,8 @@ export const WithWarning = () => (
765775
send_with_ellipsis: 'Send with...',
766776
copy_prompt: 'Copy prompt',
767777
more_actions: 'More actions',
768-
send: 'Send'
778+
send: 'Send',
779+
tokens_in_context: 'Tokens in context'
769780
}}
770781
warning="Add a configuration"
771782
/>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export type PromptFieldProps = {
101101
copy_prompt: string
102102
more_actions: string
103103
send: string
104+
tokens_in_context: string
104105
}
105106
}
106107

@@ -584,7 +585,10 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
584585
onMouseLeave={() => set_is_token_count_hovered(false)}
585586
>
586587
{is_token_count_hovered && (
587-
<Tooltip message="Tokens in context" align="center" />
588+
<Tooltip
589+
message={props.translations.tokens_in_context}
590+
align="center"
591+
/>
588592
)}
589593
<span className={styles['footer__right__token-count']}>
590594
{props.token_count < 1000

‎packages/ui/src/components/editor/prompt/ModeButton/ModeButton.module.scss‎

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
transform: translateY(0);
55
}
66
25% {
7-
transform: translateY(-2px);
7+
transform: translateY(-4px);
88
}
99
75% {
1010
transform: translateY(0);
@@ -26,10 +26,6 @@
2626
height: 100%;
2727
gap: 8px;
2828

29-
.button__pre {
30-
display: none;
31-
}
32-
3329
.button__label {
3430
font-size: 18px;
3531
}
@@ -46,21 +42,12 @@
4642

4743
&__label {
4844
font-family: var(--font-family-accent);
49-
font-size: 22px;
50-
line-height: 1.2;
51-
letter-spacing: 1px;
52-
white-space: nowrap;
53-
overflow: hidden;
54-
text-overflow: ellipsis;
55-
max-width: 100%;
45+
font-size: 32px;
46+
letter-spacing: 1.5px;
5647
}
5748

5849
&__label-char {
5950
display: inline-block;
6051
position: relative;
6152
}
62-
63-
&__pre {
64-
opacity: var(--dimmed-opacity);
65-
}
6653
}

0 commit comments

Comments
 (0)