Skip to content

Commit ac2f244

Browse files
committed
Add danger button variant and back button functionality to response preview footer
1 parent d13a934 commit ac2f244

4 files changed

Lines changed: 33 additions & 4 deletions

File tree

packages/ui/src/components/editor/common/Button/Button.module.scss

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
gap: 3px;
66
min-height: 28px;
77
font-size: 13px;
8-
padding: 4px 16px;
98
font-family: system-ui, sans-serif;
109
border: none;
1110
text-decoration: none;
@@ -35,7 +34,6 @@
3534
}
3635

3736
&--secondary {
38-
color: var(--vscode-button-secondaryForeground);
3937
background-color: var(--vscode-button-secondaryBackground);
4038

4139
&:hover {
@@ -49,6 +47,24 @@
4947
}
5048
}
5149

50+
&--danger {
51+
background-color: var(--vscode-inputValidation-errorBorder);
52+
53+
&:hover {
54+
background-color: color-mix(
55+
in srgb,
56+
var(--vscode-inputValidation-errorBorder) 80%,
57+
var(--cwc-text-color)
58+
);
59+
}
60+
61+
&:disabled {
62+
&:hover {
63+
background-color: var(--vscode-inputValidation-errorBorder);
64+
}
65+
}
66+
}
67+
5268
&--small {
5369
min-height: unset;
5470
font-size: 11px;

packages/ui/src/components/editor/common/Button/Button.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type Props = {
1010
codicon?: string
1111
title?: string
1212
is_secondary?: boolean
13+
is_danger?: boolean
1314
is_focused?: boolean
1415
is_small?: boolean
1516
}
@@ -25,7 +26,8 @@ export const Button: FC<Props> = (props) => {
2526

2627
const className = cn(styles.button, {
2728
[styles['button--secondary']]: props.is_secondary,
28-
[styles['button--small']]: props.is_small
29+
[styles['button--small']]: props.is_small,
30+
[styles['button--danger']]: props.is_danger
2931
})
3032

3133
const children = (

packages/ui/src/components/editor/panel/ResponsePreviewFooter/ResponsePreviewFooter.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@ import { Button } from '../../common/Button'
22
import styles from './ResponsePreviewFooter.module.scss'
33

44
type Props = {
5+
on_back: () => void
56
on_reject: () => void
67
on_accept: () => void
78
is_accept_disabled: boolean
89
}
910

1011
export const ResponsePreviewFooter: React.FC<Props> = ({
12+
on_back,
1113
on_reject,
1214
on_accept,
1315
is_accept_disabled
1416
}) => {
1517
return (
1618
<div className={styles.container}>
17-
<Button on_click={on_reject} is_secondary>
19+
<Button on_click={on_back} is_secondary>
20+
Back
21+
</Button>
22+
<Button on_click={on_reject} is_danger>
1823
Reject
1924
</Button>
2025
<Button on_click={on_accept} disabled={is_accept_disabled}>

packages/vscode/src/views/panel/frontend/Panel.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,12 @@ export const Panel = () => {
419419
}}
420420
footer_slot={
421421
<UiResponsePreviewFooter
422+
on_back={() => {
423+
post_message(vscode, {
424+
command: 'RESPONSE_PREVIEW',
425+
files: []
426+
})
427+
}}
422428
on_reject={() => {
423429
if (preview_item_created_at) {
424430
set_response_history((prev) =>

0 commit comments

Comments
 (0)