Skip to content

Commit 83c1cbe

Browse files
committed
Refactor the MainView component by extracting the Header and Footer into separate components and remove trailing periods from initialization messages
1 parent 13d1191 commit 83c1cbe

15 files changed

Lines changed: 501 additions & 423 deletions

File tree

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,29 @@ export const Dropdown = <T extends string>(props: Dropdown.Props<T>) => {
4343
set_just_opened(false)
4444
}
4545

46+
const handle_wheel = (event: React.WheelEvent<HTMLDivElement>) => {
47+
event.preventDefault()
48+
event.stopPropagation()
49+
50+
const current_index = props.options.findIndex(
51+
(option) => option.value === props.selected_value
52+
)
53+
if (current_index == -1) {
54+
return
55+
}
56+
57+
const options_count = props.options.length
58+
if (options_count <= 1) return
59+
60+
let next_index
61+
if (event.deltaY < 0) {
62+
next_index = (current_index - 1 + options_count) % options_count
63+
} else {
64+
next_index = (current_index + 1) % options_count
65+
}
66+
props.on_change(props.options[next_index].value)
67+
}
68+
4669
useEffect(() => {
4770
const handle_click_outside = (event: MouseEvent) => {
4871
if (
@@ -64,6 +87,7 @@ export const Dropdown = <T extends string>(props: Dropdown.Props<T>) => {
6487
<div
6588
className={cn(styles.container, { [styles['button--open']]: is_open })}
6689
ref={container_ref}
90+
onWheel={handle_wheel}
6791
>
6892
<button
6993
className={cn(styles.button, { [styles['button--open']]: is_open })}

‎packages/ui/src/components/editor/panel/modals/ChatInitializedModal/ChatInitializedModal.stories.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const Default = () => {
1414

1515
return visible ? (
1616
<ChatInitializedModal
17-
title="Chat has been initialized in the connected browser."
17+
title="Chat has been initialized in the connected browser"
1818
duration={3000}
1919
on_close={handle_close}
2020
/>

‎packages/vscode/src/views/panel/backend/message-handlers/handle-send-prompt.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ export const handle_send_prompt = async (params: {
229229
command: 'SHOW_CHAT_INITIALIZED',
230230
title:
231231
resolved_preset_names.length > 1
232-
? 'Chats have been initialized in the connected browser.'
233-
: 'Chat has been initialized in the connected browser.'
232+
? 'Chats have been initialized in the connected browser'
233+
: 'Chat has been initialized in the connected browser'
234234
})
235235
}
236236

‎packages/vscode/src/views/panel/frontend/Home/Home.module.scss‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@
6161
height: var(--size);
6262
color: var(--vscode-icon-foreground);
6363
}
64-
65-
&:hover .header__settings__icon-wrapper {
66-
animation: rotate 4s linear infinite;
67-
}
6864
}
6965
}
7066

@@ -170,12 +166,3 @@
170166
color: var(--vscode-descriptionForeground);
171167
}
172168
}
173-
174-
@keyframes rotate {
175-
from {
176-
transform: rotate(0deg);
177-
}
178-
to {
179-
transform: rotate(360deg);
180-
}
181-
}

‎packages/vscode/src/views/panel/frontend/Main/MainView/MainView.module.scss‎

Lines changed: 0 additions & 178 deletions
Original file line numberDiff line numberDiff line change
@@ -16,82 +16,6 @@
1616
padding: 0 0 var(--padding-8px) 0;
1717
}
1818

19-
.header {
20-
display: flex;
21-
justify-content: space-between;
22-
align-items: center;
23-
padding: var(--padding-3px) var(--padding-12px) var(--padding-4px)
24-
var(--padding-12px);
25-
gap: var(--padding-12px);
26-
27-
&__left {
28-
display: flex;
29-
align-items: center;
30-
gap: var(--padding-4px);
31-
32-
&__home-view-type {
33-
font-weight: 600;
34-
}
35-
36-
&__toggler {
37-
font-weight: 600;
38-
display: flex;
39-
align-items: center;
40-
justify-content: center;
41-
border-radius: var(--border-radius-5px);
42-
--padding: var(--padding-6px);
43-
padding: 0 var(--padding);
44-
margin: 0 calc(var(--padding) * -1);
45-
height: 20px;
46-
color: var(--vscode-icon-foreground);
47-
white-space: nowrap;
48-
49-
&:focus {
50-
outline: none;
51-
}
52-
53-
&:hover {
54-
background-color: var(--vscode-toolbar-hoverBackground);
55-
}
56-
}
57-
}
58-
59-
&__right {
60-
flex: 1;
61-
display: flex;
62-
align-items: center;
63-
gap: var(--padding-8px);
64-
65-
&__dropdown {
66-
width: 100%;
67-
}
68-
69-
&__settings {
70-
display: flex;
71-
align-items: center;
72-
justify-content: center;
73-
flex-shrink: 0;
74-
--size: 20px;
75-
width: var(--size);
76-
height: var(--size);
77-
color: var(--vscode-icon-foreground);
78-
cursor: pointer;
79-
text-decoration: none;
80-
background: none;
81-
border: none;
82-
padding: 0;
83-
border-radius: var(--border-radius-5px);
84-
85-
&:hover {
86-
background-color: var(--vscode-toolbar-hoverBackground);
87-
> span {
88-
animation: rotate 4s linear infinite;
89-
}
90-
}
91-
}
92-
}
93-
}
94-
9519
.responses {
9620
margin: 0 var(--padding-16px);
9721
display: flex;
@@ -158,99 +82,6 @@
15882
}
15983
}
16084

161-
.footer {
162-
position: relative;
163-
z-index: -1; // Makes context menu of a preset appear above
164-
display: flex;
165-
justify-content: space-between;
166-
gap: var(--padding-4px);
167-
padding: var(--padding-8px) var(--padding-12px);
168-
border-top: 1px solid var(--vscode-sideBarSectionHeader-border);
169-
170-
&__right {
171-
display: flex;
172-
gap: var(--padding-4px);
173-
}
174-
175-
&__button {
176-
display: flex;
177-
align-items: center;
178-
flex-shrink: 0;
179-
gap: var(--padding-4px);
180-
height: 24px;
181-
padding: 0 var(--padding-5px);
182-
border-radius: var(--border-radius-4px);
183-
color: var(--vscode-foreground);
184-
185-
&:disabled {
186-
opacity: var(--disabled-opacity);
187-
}
188-
189-
> svg {
190-
flex-shrink: 0;
191-
fill: var(--vscode-icon-foreground);
192-
width: 16px;
193-
height: 16px;
194-
}
195-
196-
&--buy-me-a-coffee {
197-
background-color: #f7d600;
198-
transition: transform var(--transition-duration-150)
199-
var(--transition-timing-function);
200-
201-
&:hover {
202-
transform: scale(0.95);
203-
}
204-
205-
> svg {
206-
fill: black;
207-
}
208-
}
209-
210-
&--filled {
211-
background-color: var(--vscode-list-hoverBackground);
212-
&:hover {
213-
background-color: var(--vscode-toolbar-hoverBackground);
214-
}
215-
}
216-
217-
&--outlined {
218-
border: 1px solid var(--vscode-commandCenter-inactiveBorder);
219-
&:hover:not(:disabled) {
220-
border-color: var(--vscode-commandCenter-activeBorder);
221-
}
222-
}
223-
}
224-
225-
&__heart {
226-
position: absolute;
227-
z-index: 11;
228-
bottom: 32px;
229-
animation-name: float-up;
230-
animation-timing-function: ease-out;
231-
animation-fill-mode: forwards;
232-
pointer-events: none;
233-
opacity: 0;
234-
}
235-
}
236-
237-
@keyframes float-up {
238-
from {
239-
transform: translateY(0);
240-
opacity: 0;
241-
}
242-
10% {
243-
opacity: 1;
244-
}
245-
40% {
246-
opacity: 1;
247-
}
248-
to {
249-
transform: translateY(-40px);
250-
opacity: 0;
251-
}
252-
}
253-
25485
.chat-input-container {
25586
display: flex;
25687
flex-direction: column;
@@ -274,12 +105,3 @@
274105
padding: 0 var(--padding-16px);
275106
position: relative;
276107
}
277-
278-
@keyframes rotate {
279-
from {
280-
transform: rotate(0deg);
281-
}
282-
to {
283-
transform: rotate(360deg);
284-
}
285-
}

0 commit comments

Comments
 (0)