Skip to content

Commit 9805b77

Browse files
committed
Refactor the UI by extracting the "Apply," "Undo," and "Commit changes" buttons into a shared Footer component and wrap main views in a Layout component to consistently display the footer
1 parent 23e25d6 commit 9805b77

15 files changed

Lines changed: 403 additions & 436 deletions

File tree

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
display: flex;
33
flex-direction: column;
44
align-items: flex-start;
5-
gap: var(--padding-2px);
6-
padding: var(--padding-6px) var(--padding-8px)
7-
calc(var(--padding-6px) + var(--padding-5px)) var(--padding-8px);
5+
padding: var(--padding-6px) var(--padding-8px) var(--padding-8px)
6+
var(--padding-8px);
87
margin-bottom: calc(var(--padding-5px) * -1);
98
background: linear-gradient(
109
135deg,
@@ -15,10 +14,10 @@
1514
--border-radius: var(--border-radius-8px);
1615
border-top-left-radius: var(--border-radius);
1716
border-top-right-radius: var(--border-radius);
17+
}
1818

19-
> span {
20-
font-weight: 500;
21-
}
19+
.heading {
20+
font-weight: 500;
2221
}
2322

2423
.links {

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import { FC } from 'react'
21
import styles from './BrowserExtensionMessage.module.scss'
32

4-
export const BrowserExtensionMessage: FC = () => {
3+
export const BrowserExtensionMessage: React.FC = () => {
54
return (
65
<div className={styles.container}>
7-
<span>Install Connector for chat initializations</span>
6+
<div className={styles.heading}>
7+
Install Connector for chat initializations
8+
</div>
89
<div className={styles.links}>
910
<a href="https://chromewebstore.google.com/detail/code-web-chat-connector/ljookipcanaglfaocjbgdicfbdhhjffp">
10-
<span>Chrome Web Store</span>
11+
Chrome Web Store
1112
</a>
1213
<a href="https://addons.mozilla.org/en-US/firefox/addon/code-web-chat-connector/">
13-
<span>Firefox Add-ons</span>
14+
Firefox Add-ons
1415
</a>
1516
</div>
1617
</div>

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

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
.container {
2-
position: relative;
3-
display: flex;
4-
flex-direction: column;
5-
height: 100%;
6-
}
7-
81
.header {
92
display: flex;
103
align-items: center;
@@ -116,53 +109,3 @@
116109
text-decoration: underline;
117110
}
118111
}
119-
120-
.footer {
121-
display: flex;
122-
justify-content: space-between;
123-
align-items: center;
124-
gap: var(--padding-4px);
125-
padding: var(--padding-8px) var(--padding-12px);
126-
border-top: 1px solid var(--vscode-sideBarSectionHeader-border);
127-
128-
&__social {
129-
display: flex;
130-
justify-content: flex-start;
131-
align-items: center;
132-
gap: var(--padding-8px);
133-
134-
&__icon {
135-
display: flex;
136-
align-items: center;
137-
justify-content: center;
138-
--size: 24px;
139-
width: var(--size);
140-
height: var(--size);
141-
border-radius: var(--border-radius-4px);
142-
143-
> svg {
144-
fill: white;
145-
width: 15px;
146-
}
147-
148-
&--x {
149-
background-color: black;
150-
}
151-
152-
&--reddit {
153-
background-color: #ff6314;
154-
}
155-
156-
&--discord {
157-
background-color: #7289da;
158-
}
159-
}
160-
}
161-
162-
&__version {
163-
flex: 1;
164-
text-align: right;
165-
user-select: text;
166-
color: var(--vscode-descriptionForeground);
167-
}
168-
}

‎packages/vscode/src/views/panel/frontend/Home/Home.tsx‎

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { Scrollable } from '@ui/components/editor/panel/Scrollable'
33
import { Enter } from '@ui/components/editor/panel/Enter'
44
import { HomeLinkButton } from '@ui/components/editor/panel/HomeLinkButton'
55
import { Donations } from '@ui/components/editor/panel/Donations'
6-
import { Icon } from '@ui/components/editor/common/Icon'
76
import { use_latest_donations } from './hooks/latest-donations-hook'
87
import cn from 'classnames'
98
import { post_message } from '../utils/post_message'
109
import { FrontendMessage } from '@/views/panel/types/messages'
10+
import { Layout } from '../components/Layout/Layout'
1111

1212
type Props = {
1313
vscode: any
@@ -37,7 +37,7 @@ export const Home: React.FC<Props> = (props) => {
3737
}
3838

3939
return (
40-
<div className={styles.container}>
40+
<Layout>
4141
<div className={styles['header']}>
4242
<div className={styles['header__left']}>
4343
<div className={styles['header__home']}>
@@ -106,6 +106,7 @@ export const Home: React.FC<Props> = (props) => {
106106

107107
<div className={styles.bottom}>
108108
<div className={styles.bottom__links}>
109+
<div>{props.version}</div>
109110
<div>
110111
Released under the{' '}
111112
<a href="https://github.com/robertpiosik/CodeWebChat/blob/dev/LICENSE">
@@ -120,33 +121,6 @@ export const Home: React.FC<Props> = (props) => {
120121
</div>
121122
</div>
122123
</Scrollable>
123-
124-
<div className={styles.footer}>
125-
<div className={styles.footer__social}>
126-
<a
127-
href="https://x.com/CodeWebChat"
128-
title="Follow on X"
129-
className={cn(
130-
styles.footer__social__icon,
131-
styles['footer__social__icon--x']
132-
)}
133-
>
134-
<Icon variant="X" />
135-
</a>
136-
<a
137-
href="https://discord.gg/KJySXsrSX5"
138-
title="Join Discord server"
139-
className={cn(
140-
styles.footer__social__icon,
141-
styles['footer__social__icon--discord']
142-
)}
143-
>
144-
<Icon variant="DISCORD" />
145-
</a>
146-
</div>
147-
148-
<div className={styles.footer__version}>{props.version}</div>
149-
</div>
150-
</div>
124+
</Layout>
151125
)
152126
}

‎packages/vscode/src/views/panel/frontend/Main/Main.tsx‎

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ type Props = {
5252
has_active_selection: boolean
5353
chat_input_focus_and_select_key: number
5454
chat_input_focus_key: number
55-
commit_button_enabling_trigger_count: number
5655
context_size_warning_threshold: number
5756
}
5857

@@ -84,9 +83,6 @@ export const Main: React.FC<Props> = (props) => {
8483
const [caret_position_to_set, set_caret_position_to_set] = useState<
8584
number | undefined
8685
>()
87-
const [has_changes_to_commit, set_has_changes_to_commit] =
88-
useState<boolean>(false)
89-
const [can_undo, set_can_undo] = useState<boolean>(false)
9086

9187
const is_in_code_completions_mode =
9288
(props.home_view_type == HOME_VIEW_TYPES.WEB &&
@@ -146,12 +142,6 @@ export const Main: React.FC<Props> = (props) => {
146142
case 'EDIT_FORMAT_INSTRUCTIONS':
147143
set_edit_format_instructions(message.instructions)
148144
break
149-
case 'GIT_STATE_CHANGED':
150-
set_has_changes_to_commit(message.has_changes_to_commit)
151-
break
152-
case 'CAN_UNDO_CHANGED':
153-
set_can_undo(message.can_undo)
154-
break
155145
case 'SELECTED_PRESET_OR_GROUP_CHANGED':
156146
set_selected_preset_or_group_name_by_mode((prev) => ({
157147
...prev,
@@ -179,8 +169,7 @@ export const Main: React.FC<Props> = (props) => {
179169
{ command: 'GET_INSTRUCTIONS' },
180170
{ command: 'GET_EDIT_FORMAT' },
181171
{ command: 'GET_EDIT_FORMAT_INSTRUCTIONS' },
182-
{ command: 'GET_API_TOOL_CONFIGURATIONS' },
183-
{ command: 'REQUEST_GIT_STATE' }
172+
{ command: 'GET_API_TOOL_CONFIGURATIONS' }
184173
]
185174
initial_messages.forEach((message) => post_message(props.vscode, message))
186175

@@ -556,12 +545,6 @@ export const Main: React.FC<Props> = (props) => {
556545
})
557546
}
558547

559-
const handle_commit_click = () => {
560-
post_message(props.vscode, {
561-
command: 'COMMIT_CHANGES'
562-
})
563-
}
564-
565548
const handle_response_history_item_click = (item: {
566549
response: string
567550
raw_instructions?: string
@@ -575,12 +558,6 @@ export const Main: React.FC<Props> = (props) => {
575558
})
576559
}
577560

578-
const handle_undo_click = () => {
579-
post_message(props.vscode, {
580-
command: 'UNDO'
581-
})
582-
}
583-
584561
const instructions =
585562
current_mode == 'ask'
586563
? props.ask_instructions
@@ -651,12 +628,8 @@ export const Main: React.FC<Props> = (props) => {
651628
presets={presets_for_current_mode}
652629
on_create_preset={handle_create_preset}
653630
on_quick_action_click={handle_quick_action_click}
654-
on_commit_click={handle_commit_click}
655-
on_undo_click={handle_undo_click}
656631
has_active_editor={props.has_active_editor}
657632
has_active_selection={props.has_active_selection}
658-
has_changes_to_commit={has_changes_to_commit}
659-
can_undo={can_undo}
660633
chat_history={current_history || []}
661634
token_count={token_count}
662635
web_mode={props.web_mode}
@@ -696,9 +669,6 @@ export const Main: React.FC<Props> = (props) => {
696669
on_caret_position_set={() => set_caret_position_to_set(undefined)}
697670
chat_input_focus_and_select_key={props.chat_input_focus_and_select_key}
698671
chat_input_focus_key={props.chat_input_focus_key}
699-
commit_button_enabling_trigger_count={
700-
props.commit_button_enabling_trigger_count
701-
}
702672
response_history={props.response_history}
703673
on_response_history_item_click={handle_response_history_item_click}
704674
selected_history_item_created_at={props.selected_history_item_created_at}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
border-top-right-radius: var(--border-radius-5px);
2525
border: 1px solid var(--vscode-commandCenter-inactiveBorder);
2626
border-bottom: 0px;
27-
padding-bottom: 5px;
28-
margin-bottom: -5px;
27+
padding-bottom: var(--padding-5px);
28+
margin-bottom: calc(var(--padding-5px) * -1);
2929
overflow: hidden;
3030

3131
&__item {

‎packages/vscode/src/views/panel/frontend/Main/MainView/MainView.tsx‎

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import { use_cycle_mode } from './hooks/use-cycle-mode'
2020
import { use_re_render_on_interval } from './hooks/use-re-render-on-interval'
2121
import { ContextUtilisation as UiContextUtilisation } from '@ui/components/editor/panel/ContextUtilisation'
2222
import { WEB_MODES, API_MODES } from './modes'
23-
import { Footer } from './components/Footer'
2423
import { Header } from './components/Header'
2524
import cn from 'classnames'
2625
import { FileInPreview } from '@shared/types/file-in-preview'
26+
import { Layout } from '../../components/Layout/Layout'
2727

2828
dayjs.extend(relativeTime)
2929

@@ -43,8 +43,6 @@ type Props = {
4343
on_hash_sign_click: () => void
4444
on_curly_braces_click: () => void
4545
on_quick_action_click: (command: string) => void
46-
on_commit_click: () => void
47-
on_undo_click: () => void
4846
is_connected: boolean
4947
presets: Preset[]
5048
configurations: ApiToolConfiguration[]
@@ -55,8 +53,6 @@ type Props = {
5553
on_manage_configurations: () => void
5654
has_active_editor: boolean
5755
has_active_selection: boolean
58-
has_changes_to_commit: boolean
59-
can_undo: boolean
6056
chat_history: string[]
6157
token_count: number
6258
context_size_warning_threshold: number
@@ -105,7 +101,6 @@ type Props = {
105101
}) => void
106102
selected_history_item_created_at?: number
107103
on_selected_history_item_change: (created_at: number) => void
108-
commit_button_enabling_trigger_count: number // Incremented when commit changes operation is cancelled
109104
}
110105

111106
export const MainView: React.FC<Props> = (props) => {
@@ -180,7 +175,7 @@ export const MainView: React.FC<Props> = (props) => {
180175
}`
181176

182177
return (
183-
<div className={styles.container}>
178+
<Layout>
184179
<Header
185180
home_view_type={props.home_view_type}
186181
on_home_view_type_change={props.on_home_view_type_change}
@@ -350,18 +345,6 @@ export const MainView: React.FC<Props> = (props) => {
350345
)}
351346
</div>
352347
</Scrollable>
353-
354-
<Footer
355-
home_view_type={props.home_view_type}
356-
on_quick_action_click={props.on_quick_action_click}
357-
on_undo_click={props.on_undo_click}
358-
can_undo={props.can_undo}
359-
on_commit_click={props.on_commit_click}
360-
has_changes_to_commit={props.has_changes_to_commit}
361-
commit_button_enabling_trigger_count={
362-
props.commit_button_enabling_trigger_count
363-
}
364-
/>
365-
</div>
348+
</Layout>
366349
)
367350
}

0 commit comments

Comments
 (0)