Skip to content

Commit d2717f5

Browse files
committed
Split the prompt type dropdown into a split button layout with a separate trigger and alternate action button
- hover-highlight also the right side which triggers dropdown. - on alternate button, border right should be made of pseudoelement moved 0.5px to the left
1 parent a3318ff commit d2717f5

2 files changed

Lines changed: 75 additions & 46 deletions

File tree

‎packages/ui/src/components/editor/panel/PromptTypeDropdown/PromptTypeDropdown.module.scss‎

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,31 @@
77
.button {
88
display: flex;
99
align-items: center;
10-
padding-right: 5px;
1110
height: 24px;
12-
border: 1px solid var(--cwc-border-color-dimmed);
11+
outline: 1px solid var(--cwc-border-color-dimmed);
1312
border-radius: 4px;
14-
cursor: pointer;
1513
color: var(--vscode-foreground);
1614
width: 100%;
1715
background: transparent;
1816
user-select: none;
19-
box-sizing: border-box;
17+
overflow: hidden;
2018

2119
&:hover {
22-
border-color: var(--cwc-border-color);
20+
outline-color: var(--cwc-border-color);
2321
}
2422

2523
&--open {
26-
border-color: var(--cwc-border-color);
24+
outline-color: var(--cwc-border-color);
2725
}
2826

2927
&__alternate {
3028
display: flex;
3129
align-items: center;
3230
justify-content: center;
33-
width: 24px;
31+
width: 22px;
3432
height: 100%;
3533
cursor: pointer;
3634
text-decoration: none;
37-
border-right: 1px solid var(--cwc-border-color);
3835
flex-shrink: 0;
3936

4037
> span {
@@ -51,6 +48,27 @@
5148
}
5249
}
5350

51+
&__separator {
52+
width: 1px;
53+
height: 100%;
54+
background-color: var(--cwc-border-color-dimmed);
55+
flex-shrink: 0;
56+
}
57+
58+
&__trigger {
59+
display: flex;
60+
align-items: center;
61+
flex-grow: 1;
62+
height: 100%;
63+
padding-right: 5px;
64+
cursor: pointer;
65+
overflow: hidden;
66+
67+
&:hover {
68+
background-color: var(--vscode-toolbar-hoverBackground);
69+
}
70+
}
71+
5472
&__label {
5573
overflow: hidden;
5674
text-overflow: ellipsis;

‎packages/ui/src/components/editor/panel/PromptTypeDropdown/PromptTypeDropdown.tsx‎

Lines changed: 49 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -102,49 +102,60 @@ export const PromptTypeDropdown = <T extends string>(
102102
>
103103
<div
104104
className={cn(styles.button, { [styles['button--open']]: is_open })}
105-
onClick={handle_toggle}
106-
onKeyDown={(e) => {
107-
if (e.key === 'Enter' || e.key === ' ') {
108-
e.preventDefault()
109-
handle_toggle()
110-
}
111-
}}
112-
role="button"
113-
tabIndex={0}
114105
style={{ maxWidth: props.max_width }}
115106
title={props.title}
116107
>
117108
{props.on_alternate_click && (
118-
<button
119-
type="button"
120-
onClick={(e) => {
121-
e.stopPropagation()
122-
if (props.on_alternate_click) {
123-
props.on_alternate_click()
124-
}
125-
}}
126-
className={styles.button__alternate}
127-
title="Toggle previous prompt type"
128-
>
129-
<span className={cn('codicon', 'codicon-sync')} />
130-
</button>
131-
)}
132-
<span className={styles.button__label}>
133-
{selected_option ? selected_option.label : 'Select an option'}
134-
</span>
135-
{is_open ? (
136-
<span
137-
className={cn('codicon', 'codicon-chevron-up', styles.button__icon)}
138-
/>
139-
) : (
140-
<span
141-
className={cn(
142-
'codicon',
143-
'codicon-chevron-down',
144-
styles.button__icon
145-
)}
146-
/>
109+
<>
110+
<button
111+
type="button"
112+
onClick={(e) => {
113+
e.stopPropagation()
114+
if (props.on_alternate_click) {
115+
props.on_alternate_click()
116+
}
117+
}}
118+
className={styles.button__alternate}
119+
title="Toggle previous prompt type"
120+
>
121+
<span className={cn('codicon', 'codicon-sync')} />
122+
</button>
123+
<div className={styles.button__separator} />
124+
</>
147125
)}
126+
<div
127+
className={styles.button__trigger}
128+
onClick={handle_toggle}
129+
onKeyDown={(e) => {
130+
if (e.key === 'Enter' || e.key === ' ') {
131+
e.preventDefault()
132+
handle_toggle()
133+
}
134+
}}
135+
role="button"
136+
tabIndex={0}
137+
>
138+
<span className={styles.button__label}>
139+
{selected_option ? selected_option.label : 'Select an option'}
140+
</span>
141+
{is_open ? (
142+
<span
143+
className={cn(
144+
'codicon',
145+
'codicon-chevron-up',
146+
styles.button__icon
147+
)}
148+
/>
149+
) : (
150+
<span
151+
className={cn(
152+
'codicon',
153+
'codicon-chevron-down',
154+
styles.button__icon
155+
)}
156+
/>
157+
)}
158+
</div>
148159
</div>
149160

150161
<DropdownMenu

0 commit comments

Comments
 (0)