Skip to content

Commit 49e160c

Browse files
committed
Rename PromptTypeButton to IconAccentButton and add support for green and red active colors
- rename 'prompt type button' to 'icon accent button' - to 'icon accent button' add more possible colors: green and red ├── apps │ └── editor │ └── src │ └── views │ └── prompt │ └── frontend │ └── Main │ └── MainView │ └── components │ └── Header │ └── Header.tsx └── packages └── ui └── src ├── components │ └── editor │ └── prompt │ └── IconAccentButton │ ├── IconAccentButton.module.scss │ ├── IconAccentButton.stories.tsx │ ├── IconAccentButton.tsx │ └── index.ts └── styles └── foundation └── _colors.scss
1 parent 4aa6aaf commit 49e160c

6 files changed

Lines changed: 67 additions & 18 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { MODE, Mode } from '@shared/types/mode'
22
import { use_compacting } from '@shared/hooks'
33
import { ApiPromptType, WebPromptType } from '@shared/types/prompt-types'
4-
import { PromptTypeButton as UiPromptTypeButton } from '@ui/components/editor/prompt/PromptTypeButton'
4+
import { IconAccentButton as UiIconAccentButton } from '@ui/components/editor/prompt/IconAccentButton'
55
import { KeycapWrapper as UiKeycapWrapper } from '@ui/components/editor/prompt/KeycapWrapper'
66
import { IconButton as UiIconButton } from '@ui/components/editor/common/IconButton'
77
import styles from './Header.module.scss'
@@ -45,7 +45,7 @@ export const Header: React.FC<Props> = (props) => {
4545
{props.mode == MODE.WEB && (
4646
<>
4747
<UiKeycapWrapper char={is_alt_pressed ? 'E' : undefined}>
48-
<UiPromptTypeButton
48+
<UiIconAccentButton
4949
label={web_prompt_type_labels['edit-files']}
5050
icon="edit-sparkle"
5151
is_active={props.web_prompt_type == 'edit-files'}
@@ -59,7 +59,7 @@ export const Header: React.FC<Props> = (props) => {
5959
/>
6060
</UiKeycapWrapper>
6161
<UiKeycapWrapper char={is_alt_pressed ? 'A' : undefined}>
62-
<UiPromptTypeButton
62+
<UiIconAccentButton
6363
label={web_prompt_type_labels['ask-about-files']}
6464
icon="chat-sparkle"
6565
is_active={props.web_prompt_type == 'ask-about-files'}
@@ -77,7 +77,7 @@ export const Header: React.FC<Props> = (props) => {
7777
</>
7878
)}
7979
{props.mode == MODE.API && (
80-
<UiPromptTypeButton
80+
<UiIconAccentButton
8181
label={api_prompt_type_labels['edit-files']}
8282
icon="edit-sparkle"
8383
is_active={props.api_prompt_type == 'edit-files'}

packages/ui/src/components/editor/prompt/PromptTypeButton/PromptTypeButton.module.scss renamed to packages/ui/src/components/editor/prompt/IconAccentButton/IconAccentButton.module.scss

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,32 @@
5555
background-color: var(--cwc-bg-orange);
5656
}
5757
}
58+
59+
&.button--green {
60+
background-color: var(--cwc-bg-green);
61+
62+
.button__icon,
63+
.button__label {
64+
color: var(--cwc-text-color-green);
65+
}
66+
67+
&:hover {
68+
background-color: var(--cwc-bg-green);
69+
}
70+
}
71+
72+
&.button--red {
73+
background-color: var(--cwc-bg-red);
74+
75+
.button__icon,
76+
.button__label {
77+
color: var(--cwc-text-color-red);
78+
}
79+
80+
&:hover {
81+
background-color: var(--cwc-bg-red);
82+
}
83+
}
5884
}
5985

6086
&--compact {

packages/ui/src/components/editor/prompt/PromptTypeButton/PromptTypeButton.stories.tsx renamed to packages/ui/src/components/editor/prompt/IconAccentButton/IconAccentButton.stories.tsx

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
import { PromptTypeButton } from './PromptTypeButton'
1+
import { IconAccentButton } from './IconAccentButton'
22

33
export default {
4-
component: PromptTypeButton
4+
component: IconAccentButton
55
}
66

77
export const Default = () => (
8-
<PromptTypeButton
8+
<IconAccentButton
99
label="Default Button"
1010
icon="gear"
1111
on_click={() => console.log('Clicked')}
1212
/>
1313
)
1414

1515
export const WithIcon = () => (
16-
<PromptTypeButton
16+
<IconAccentButton
1717
label="Run Prompt"
1818
icon="play"
1919
on_click={() => console.log('Clicked')}
2020
/>
2121
)
2222

2323
export const Active = () => (
24-
<PromptTypeButton
24+
<IconAccentButton
2525
label="Active Button"
2626
icon="check"
2727
is_active
@@ -30,7 +30,7 @@ export const Active = () => (
3030
)
3131

3232
export const ActiveBlue = () => (
33-
<PromptTypeButton
33+
<IconAccentButton
3434
label="Active Blue Button"
3535
icon="check"
3636
is_active
@@ -40,7 +40,7 @@ export const ActiveBlue = () => (
4040
)
4141

4242
export const ActiveOrange = () => (
43-
<PromptTypeButton
43+
<IconAccentButton
4444
label="Active Orange Button"
4545
icon="check"
4646
is_active
@@ -49,8 +49,28 @@ export const ActiveOrange = () => (
4949
/>
5050
)
5151

52+
export const ActiveGreen = () => (
53+
<IconAccentButton
54+
label="Active Green Button"
55+
icon="check"
56+
is_active
57+
active_color="green"
58+
on_click={() => console.log('Clicked')}
59+
/>
60+
)
61+
62+
export const ActiveRed = () => (
63+
<IconAccentButton
64+
label="Active Red Button"
65+
icon="check"
66+
is_active
67+
active_color="red"
68+
on_click={() => console.log('Clicked')}
69+
/>
70+
)
71+
5272
export const Compact = () => (
53-
<PromptTypeButton
73+
<IconAccentButton
5474
label="Compact Button"
5575
icon="gear"
5676
is_compact

packages/ui/src/components/editor/prompt/PromptTypeButton/PromptTypeButton.tsx renamed to packages/ui/src/components/editor/prompt/IconAccentButton/IconAccentButton.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { FC } from 'react'
2-
import styles from './PromptTypeButton.module.scss'
2+
import styles from './IconAccentButton.module.scss'
33
import cn from 'classnames'
44

5-
export namespace PromptTypeButton {
5+
export namespace IconAccentButton {
66
export type Props = {
77
label: string
88
icon: string
99
is_compact?: boolean
1010
is_active?: boolean
11-
active_color?: 'blue' | 'orange'
11+
active_color?: 'blue' | 'orange' | 'green' | 'red'
1212
on_click?: () => void
1313
}
1414
}
1515

16-
export const PromptTypeButton: FC<PromptTypeButton.Props> = (props) => {
16+
export const IconAccentButton: FC<IconAccentButton.Props> = (props) => {
1717
return (
1818
<button
1919
className={cn(styles.button, {
@@ -22,7 +22,10 @@ export const PromptTypeButton: FC<PromptTypeButton.Props> = (props) => {
2222
[styles['button--blue']]:
2323
props.is_active && props.active_color == 'blue',
2424
[styles['button--orange']]:
25-
props.is_active && props.active_color == 'orange'
25+
props.is_active && props.active_color == 'orange',
26+
[styles['button--green']]:
27+
props.is_active && props.active_color == 'green',
28+
[styles['button--red']]: props.is_active && props.active_color == 'red'
2629
})}
2730
onClick={props.on_click}
2831
type="button"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './IconAccentButton'

‎packages/ui/src/components/editor/prompt/PromptTypeButton/index.ts‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)