Skip to content

Commit eeebd7e

Browse files
committed
Add prompt-type-based hover colors and integrated ascii art effect to target buttons
- 'target button' should be allowed to have set 'hover color' (blue/purple) - on terget button, set blue when its prompt type is 'edit', purple when its prompt type is 'ask' - render 'ascii art effect' by the target button itself, configure its color dynamically based on active color - leave only blue and purple colors ├── apps │ └── editor │ └── src │ └── views │ └── prompt │ └── frontend │ ├── Home │ │ └── Home.tsx │ ├── Main │ │ └── MainView │ │ ├── MainView.tsx │ │ └── components │ │ └── Header │ │ └── Header.tsx │ └── Prompt.tsx └── packages └── ui └── src └── components └── editor └── prompt ├── AsciiArtEffect │ ├── AsciiArtEffect.module.scss │ └── AsciiArtEffect.tsx ├── IconAccentButton │ ├── IconAccentButton.module.scss │ ├── IconAccentButton.stories.tsx │ ├── IconAccentButton.tsx │ └── index.ts └── TargetButton ├── TargetButton.module.scss ├── TargetButton.stories.tsx └── TargetButton.tsx
1 parent 8e29f2a commit eeebd7e

8 files changed

Lines changed: 54 additions & 64 deletions

File tree

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Scrollable as UiScrollable } from '@ui/components/editor/common/Scrolla
44
import { Tabs as UiTabs } from '@ui/components/editor/prompt/Tabs'
55
import { TargetButton as UiTargetButton } from '@ui/components/editor/prompt/TargetButton'
66
import { KeycapWrapper as UiKeycapWrapper } from '@ui/components/editor/prompt/KeycapWrapper'
7-
import { AsciiArtEffect as UiAsciiArtEffect } from '@ui/components/editor/prompt/AsciiArtEffect'
87
import cn from 'classnames'
98
import { post_message } from '../utils/post-message'
109
import { BackendMessage } from '@/views/prompt/types/messages'
@@ -16,6 +15,7 @@ import { use_tasks } from './hooks/use-tasks'
1615
import { use_has_scrolled_past_target_button } from './hooks/use-has-scrolled-past-mode-button'
1716
import { use_compacting } from '@shared/hooks'
1817
import { TARGET } from '@shared/types/mode'
18+
import { ApiPromptType, WebPromptType } from '@shared/types/prompt-types'
1919
import { use_keyboard_shortcuts } from './hooks/use-keyboard-shortcuts'
2020

2121
type Props = {
@@ -30,6 +30,8 @@ type Props = {
3030
on_donate_click: () => void
3131
on_forward_task: (text: string) => void
3232
bottom_spacer_height?: number
33+
web_prompt_type: WebPromptType
34+
api_prompt_type: ApiPromptType
3335
}
3436

3537
export const Home: React.FC<Props> = (props) => {
@@ -166,19 +168,24 @@ export const Home: React.FC<Props> = (props) => {
166168
has_scrolled_past_target_button
167169
})}
168170
>
169-
<UiAsciiArtEffect density={2.3} />
170171
<UiKeycapWrapper char={is_alt_pressed ? 'W' : undefined} full_width>
171172
<UiTargetButton
172173
label={TARGET.WEB}
173174
on_click={props.on_chatbots_click}
174175
is_compact
176+
hover_color={
177+
props.web_prompt_type == 'edit-files' ? 'blue' : 'purple'
178+
}
175179
/>
176180
</UiKeycapWrapper>
177181
<UiKeycapWrapper char={is_alt_pressed ? 'A' : undefined} full_width>
178182
<UiTargetButton
179183
label={TARGET.API}
180184
on_click={props.on_api_calls_click}
181185
is_compact
186+
hover_color={
187+
props.api_prompt_type == 'edit-files' ? 'blue' : 'purple'
188+
}
182189
/>
183190
</UiKeycapWrapper>
184191
</div>
@@ -188,7 +195,6 @@ export const Home: React.FC<Props> = (props) => {
188195
<div className={styles.content}>
189196
<div className={styles.inner}>
190197
<div className={styles.inner__target} ref={target_ref}>
191-
<UiAsciiArtEffect />
192198
<UiKeycapWrapper
193199
char={is_alt_pressed ? 'W' : undefined}
194200
full_width
@@ -201,6 +207,9 @@ export const Home: React.FC<Props> = (props) => {
201207
: t('home.target.web.description')
202208
}
203209
on_click={props.on_chatbots_click}
210+
hover_color={
211+
props.web_prompt_type == 'edit-files' ? 'blue' : 'purple'
212+
}
204213
/>
205214
</UiKeycapWrapper>
206215
<UiKeycapWrapper
@@ -211,6 +220,9 @@ export const Home: React.FC<Props> = (props) => {
211220
label={TARGET.API}
212221
description={t('home.target.api.description')}
213222
on_click={props.on_api_calls_click}
223+
hover_color={
224+
props.api_prompt_type == 'edit-files' ? 'blue' : 'purple'
225+
}
214226
/>
215227
</UiKeycapWrapper>
216228
</div>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ export const Prompt = () => {
371371
vscode={vscode}
372372
is_active={active_view == 'home'}
373373
is_connected={is_connected}
374+
web_prompt_type={web_prompt_type}
375+
api_prompt_type={api_prompt_type}
374376
on_go_forward={() => set_active_view('main')}
375377
on_chatbots_click={() => {
376378
set_active_view('main')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
.inner {
2121
position: absolute;
2222
inset: 0;
23-
background-color: var(--cwc-text-color-dimmed);
23+
background-color: var(--ascii-color, var(--cwc-text-color-dimmed));
2424
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Ctext x='15' y='25' fill='black' font-family='monospace' font-size='12'%3E%2B%3C/text%3E%3Ctext x='55' y='45' fill='black' font-family='monospace' font-size='16'%3E*%3C/text%3E%3Ctext x='85' y='85' fill='black' font-family='monospace' font-size='14'%3E%C2%B7%3C/text%3E%3Ctext x='25' y='85' fill='black' font-family='monospace' font-size='10'%3E%C3%97%3C/text%3E%3Ctext x='85' y='25' fill='black' font-family='monospace' font-size='12'%3E%C2%B0%3C/text%3E%3Ctext x='10' y='65' fill='black' font-family='monospace' font-size='14'%3E%C2%B7%3C/text%3E%3Ctext x='45' y='95' fill='black' font-family='monospace' font-size='12'%3E%2B%3C/text%3E%3Ctext x='95' y='55' fill='black' font-family='monospace' font-size='10'%3E%C3%97%3C/text%3E%3C/svg%3E");
2525
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Ctext x='15' y='25' fill='black' font-family='monospace' font-size='12'%3E%2B%3C/text%3E%3Ctext x='55' y='45' fill='black' font-family='monospace' font-size='16'%3E*%3C/text%3E%3Ctext x='85' y='85' fill='black' font-family='monospace' font-size='14'%3E%C2%B7%3C/text%3E%3Ctext x='25' y='85' fill='black' font-family='monospace' font-size='10'%3E%C3%97%3C/text%3E%3Ctext x='85' y='25' fill='black' font-family='monospace' font-size='12'%3E%C2%B0%3C/text%3E%3Ctext x='10' y='65' fill='black' font-family='monospace' font-size='14'%3E%C2%B7%3C/text%3E%3Ctext x='45' y='95' fill='black' font-family='monospace' font-size='12'%3E%2B%3C/text%3E%3Ctext x='95' y='55' fill='black' font-family='monospace' font-size='10'%3E%C3%97%3C/text%3E%3C/svg%3E");
2626
mask-repeat: repeat;

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,6 @@
4343
}
4444
}
4545

46-
&.button--green {
47-
background-color: var(--cwc-green-background);
48-
49-
.button__icon,
50-
.button__label {
51-
color: var(--cwc-green-foreground);
52-
}
53-
54-
&:hover {
55-
background-color: var(--cwc-green-background);
56-
}
57-
}
58-
59-
&.button--red {
60-
background-color: var(--cwc-red-background);
61-
62-
.button__icon,
63-
.button__label {
64-
color: var(--cwc-red-foreground);
65-
}
66-
67-
&:hover {
68-
background-color: var(--cwc-red-background);
69-
}
70-
}
71-
7246
&.button--purple {
7347
background-color: var(--cwc-purple-background);
7448

@@ -81,19 +55,6 @@
8155
background-color: var(--cwc-purple-background);
8256
}
8357
}
84-
85-
&.button--yellow {
86-
background-color: var(--cwc-yellow-background);
87-
88-
.button__icon,
89-
.button__label {
90-
color: var(--cwc-yellow-foreground);
91-
}
92-
93-
&:hover {
94-
background-color: var(--cwc-yellow-background);
95-
}
96-
}
9758
}
9859

9960
&--compact {

‎packages/ui/src/components/editor/prompt/IconAccentButton/IconAccentButton.stories.tsx‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,12 @@ export const ActiveBlue = () => (
3939
/>
4040
)
4141

42-
export const ActiveGreen = () => (
42+
export const ActivePurple = () => (
4343
<IconAccentButton
44-
label="Active Green Button"
44+
label="Active Purple Button"
4545
icon="check"
4646
is_active
47-
active_color="green"
48-
on_click={() => console.log('Clicked')}
49-
/>
50-
)
51-
52-
export const ActiveRed = () => (
53-
<IconAccentButton
54-
label="Active Red Button"
55-
icon="check"
56-
is_active
57-
active_color="red"
47+
active_color="purple"
5848
on_click={() => console.log('Clicked')}
5949
/>
6050
)

‎packages/ui/src/components/editor/prompt/IconAccentButton/IconAccentButton.tsx‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export namespace IconAccentButton {
88
icon: string
99
is_compact?: boolean
1010
is_active?: boolean
11-
active_color?: 'blue' | 'green' | 'red' | 'yellow' | 'purple'
11+
active_color?: 'blue' | 'purple'
1212
on_click?: () => void
1313
}
1414
}
@@ -21,13 +21,8 @@ export const IconAccentButton: FC<IconAccentButton.Props> = (props) => {
2121
[styles['button--compact']]: props.is_compact,
2222
[styles['button--blue']]:
2323
props.is_active && props.active_color == 'blue',
24-
[styles['button--green']]:
25-
props.is_active && props.active_color == 'green',
26-
[styles['button--red']]: props.is_active && props.active_color == 'red',
2724
[styles['button--purple']]:
28-
props.is_active && props.active_color == 'purple',
29-
[styles['button--yellow']]:
30-
props.is_active && props.active_color == 'yellow'
25+
props.is_active && props.active_color == 'purple'
3126
})}
3227
onClick={props.on_click}
3328
type="button"

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
}
3535
}
3636

37+
&.button--hover-blue {
38+
--ascii-color: var(--cwc-blue-foreground);
39+
}
40+
41+
&.button--hover-purple {
42+
--ascii-color: var(--cwc-purple-foreground);
43+
}
44+
3745
&:not(:disabled):hover {
3846
background-color: var(--vscode-toolbar-hoverBackground);
3947

@@ -45,6 +53,24 @@
4553
color: var(--vscode-foreground);
4654
opacity: 1;
4755
}
56+
57+
&.button--hover-blue {
58+
background-color: var(--cwc-blue-background);
59+
color: var(--cwc-blue-foreground);
60+
61+
.button__description {
62+
color: var(--cwc-blue-foreground);
63+
}
64+
}
65+
66+
&.button--hover-purple {
67+
background-color: var(--cwc-purple-background);
68+
color: var(--cwc-purple-foreground);
69+
70+
.button__description {
71+
color: var(--cwc-purple-foreground);
72+
}
73+
}
4874
}
4975

5076
&--compact:not(:disabled):hover .button__label-char {

‎packages/ui/src/components/editor/prompt/TargetButton/TargetButton.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import styles from './TargetButton.module.scss'
22
import cn from 'classnames'
3+
import { AsciiArtEffect } from '../AsciiArtEffect'
34

45
type Props = {
56
label: string
67
description?: string
78
on_click: () => void
89
is_compact?: boolean
910
disabled?: boolean
11+
hover_color?: 'blue' | 'purple'
1012
}
1113

1214
export const TargetButton: React.FC<Props> = (props) => {
@@ -18,11 +20,13 @@ export const TargetButton: React.FC<Props> = (props) => {
1820
>
1921
<button
2022
className={cn(styles.button, {
21-
[styles['button--compact']]: props.is_compact
23+
[styles['button--compact']]: props.is_compact,
24+
[styles[`button--hover-${props.hover_color}`]]: props.hover_color
2225
})}
2326
onClick={props.disabled ? undefined : props.on_click}
2427
disabled={!!props.disabled}
2528
>
29+
<AsciiArtEffect />
2630
<div className={styles['button__label']}>
2731
{props.label.split('').map((char, index) => (
2832
<span

0 commit comments

Comments
 (0)