Skip to content

Commit e3c53ab

Browse files
ci-bothsy822
authored andcommitted
wip: resolve scroll stutter issue
1 parent 86228f6 commit e3c53ab

File tree

6 files changed

+76
-27
lines changed

6 files changed

+76
-27
lines changed

apps/remix-ide/src/app.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ import Editor from './app/editor/editor'
110110
import Terminal from './app/panels/terminal'
111111
import TabProxy from './app/panels/tab-proxy.js'
112112
import { Plugin } from '@remixproject/engine'
113+
import BottomBarPanel from './app/components/bottom-bar-panel'
113114

114115
const _paq = (window._paq = window._paq || [])
115116

@@ -526,7 +527,9 @@ class AppComponent {
526527
const landingPage = new LandingPage(appManager, this.menuicons, fileManager, filePanel, contentImport)
527528
this.settings = new SettingsTab(Registry.getInstance().get('config').api, editor)//, appManager)
528529

529-
this.engine.register([this.menuicons, landingPage, this.hiddenPanel, this.sidePanel, this.statusBar, this.topBar, filePanel, pluginManagerComponent, this.settings, this.pinnedPanel, this.popupPanel])
530+
const bottomBarPanel = new BottomBarPanel()
531+
532+
this.engine.register([this.menuicons, landingPage, this.hiddenPanel, this.sidePanel, this.statusBar, this.topBar, filePanel, pluginManagerComponent, this.settings, this.pinnedPanel, this.popupPanel, bottomBarPanel])
530533

531534
// CONTENT VIEWS & DEFAULT PLUGINS
532535
const openZeppelinProxy = new OpenZeppelinProxy(blockchain)
@@ -573,6 +576,7 @@ class AppComponent {
573576
tabs: { plugin: tabProxy, active: true },
574577
editor: { plugin: editor, active: true },
575578
main: { plugin: appPanel, active: false },
579+
bottomBar: { plugin: bottomBarPanel, active: true },
576580
terminal: { plugin: terminal, active: true, minimized: false }
577581
}
578582
}
@@ -607,6 +611,7 @@ class AppComponent {
607611
await this.appManager.activatePlugin(['mainPanel', 'menuicons', 'tabs'])
608612
await this.appManager.activatePlugin(['topbar'])
609613
await this.appManager.activatePlugin(['statusBar'])
614+
await this.appManager.activatePlugin(['bottomBar'])
610615
await this.appManager.activatePlugin(['sidePanel']) // activating host plugin separately
611616
await this.appManager.activatePlugin(['pinnedPanel'])
612617
await this.appManager.activatePlugin(['popupPanel'])
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from 'react'
2+
import { Plugin } from '@remixproject/engine'
3+
import { PluginViewWrapper } from '@remix-ui/helper'
4+
import * as packageJson from '../../../../../package.json'
5+
import BottomBar from './bottom-bar'
6+
7+
const profile = {
8+
displayName: 'Bottom Bar',
9+
name: 'bottomBar',
10+
methods: [],
11+
events: [],
12+
description: 'Editor bottom bar (renders above dragbar-terminal)',
13+
version: packageJson.version
14+
}
15+
16+
export default class BottomBarPanel extends Plugin {
17+
private dispatch: ((state: any) => void) | null = null
18+
19+
constructor() {
20+
super(profile)
21+
}
22+
23+
setDispatch = (dispatch) => {
24+
this.dispatch = dispatch
25+
}
26+
27+
onActivation() {
28+
this.renderComponent()
29+
}
30+
31+
render() {
32+
return (
33+
<div className="panel" data-id="bottomBarPanelView">
34+
<PluginViewWrapper plugin={this} />
35+
</div>
36+
)
37+
}
38+
39+
updateComponent() {
40+
return <BottomBar plugin={this} />
41+
}
42+
43+
renderComponent() {
44+
this.dispatch && this.dispatch({})
45+
}
46+
}

apps/remix-ide/src/app/components/bottom-bar.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ export const BottomBar = ({ plugin }: BottomBarProps) => {
2828
setCurrentFilePath(path)
2929
const ext = path?.split('.').pop()?.toLowerCase() || ''
3030
setCurrentExt(ext)
31-
} catch (err) {
32-
console.info('No current file selected.')
31+
} catch {
3332
setCurrentFilePath('')
3433
setCurrentExt('')
3534
}
@@ -38,32 +37,30 @@ export const BottomBar = ({ plugin }: BottomBarProps) => {
3837
getAI()
3938
getCurrentExt()
4039

41-
plugin.on('settings', 'copilotChoiceUpdated', (isChecked) => {
42-
setAiSwitch(isChecked)
43-
})
40+
const onCopilot = (isChecked: boolean) => setAiSwitch(!!isChecked)
4441

42+
plugin.on('settings', 'copilotChoiceUpdated', onCopilot)
4543
plugin.on('fileManager', 'currentFileChanged', getCurrentExt)
4644

4745
return () => {
46+
plugin.off('settings', 'copilotChoiceUpdated')
4847
plugin.off('fileManager', 'currentFileChanged')
4948
}
50-
5149
}, [plugin])
5250

5351
const handleExplain = async () => {
5452
if (!currentFilePath) {
55-
plugin.call('notification', 'toast', 'No file selected to explain.');
53+
plugin.call('notification', 'toast', 'No file selected to explain.')
5654
return
5755
}
5856
setExplaining(true)
5957
try {
6058
await plugin.call('menuicons', 'select', 'remixaiassistant')
61-
await new Promise(resolve => setTimeout(resolve, 500))
59+
await new Promise((resolve) => setTimeout(resolve, 500))
6260
const content = await plugin.call('fileManager', 'readFile', currentFilePath)
6361
await plugin.call('remixAI', 'chatPipe', 'code_explaining', content)
64-
6562
} catch (err) {
66-
console.error("Explain failed:", err)
63+
console.error('Explain failed:', err)
6764
}
6865
setExplaining(false)
6966
}
@@ -84,21 +81,22 @@ export const BottomBar = ({ plugin }: BottomBarProps) => {
8481
}
8582

8683
return (
87-
<div className="bottom-bar border-top border-bottom">
84+
<div className="bottom-bar border-top border-bottom" data-id="bottomBarPanel">
8885
{getExplainLabel() && (
8986
<button
9087
className="btn btn-ai"
9188
onClick={handleExplain}
9289
disabled={explaining || !currentFilePath}
90+
data-id="bottomBarExplainBtn"
9391
>
9492
<img src="assets/img/remixAI_small.svg" alt="Remix AI" className="explain-icon" />
9593
<span>{getExplainLabel()}</span>
9694
</button>
9795
)}
9896
<div className="copilot-toggle">
99-
<span className={aiSwitch ? "on" : ""}>AI copilot</span>
100-
<label className="switch" data-id="copilot_toggle" >
101-
<input type="checkbox" checked={aiSwitch} onChange={toggleAI}/>
97+
<span className={aiSwitch ? 'on' : ''}>AI copilot</span>
98+
<label className="switch" data-id="copilot_toggle">
99+
<input type="checkbox" checked={aiSwitch} onChange={toggleAI} />
102100
<span className="slider"></span>
103101
</label>
104102
</div>
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
.bottom-bar {
22
display: flex;
3+
flex: 0 0 auto;
34
align-items: center;
45
padding: 4px 16px;
56
background-color: var(--bs-light) !important;
67
height: 32px;
78
}
89

9-
.explain-icon {
10+
.bottom-bar .explain-icon {
1011
width: 12px;
1112
height: 12px;
1213
}
1314

14-
.copilot-toggle {
15+
.bottom-bar .copilot-toggle {
1516
margin-left: auto;
1617
display: flex;
1718
align-items: center;
@@ -22,32 +23,32 @@
2223
line-height: 1;
2324
}
2425

25-
.copilot-toggle span {
26+
.bottom-bar .copilot-toggle span {
2627
font-family: 'Nunito Sans', sans-serif;
2728
font-size: 12px;
2829
font-weight: 700;
2930
color: var(--text-muted);
3031
transition: color 0.3s;
3132
}
3233

33-
.copilot-toggle span.on {
34+
.bottom-bar .copilot-toggle span.on {
3435
color: var(--text-bright);
3536
}
3637

37-
.switch {
38+
.bottom-bar .switch {
3839
position: relative;
3940
display: inline-block;
4041
width: 18px;
4142
height: 10px;
4243
}
4344

44-
.switch input {
45+
.bottom-bar .switch input {
4546
opacity: 0;
4647
width: 0;
4748
height: 0;
4849
}
4950

50-
.slider {
51+
.bottom-bar .slider {
5152
position: absolute;
5253
cursor: pointer;
5354
top: 0; left: 0; right: 0; bottom: 0;
@@ -57,7 +58,7 @@
5758
padding: 1px;
5859
}
5960

60-
.slider:before {
61+
.bottom-bar .slider:before {
6162
position: absolute;
6263
content: "";
6364
height: 8px;
@@ -69,10 +70,10 @@
6970
border-radius: 50%;
7071
}
7172

72-
.switch input:checked + .slider {
73+
.bottom-bar .switch input:checked + .slider {
7374
background-color: var(--custom-ai-color);
7475
}
7576

76-
.switch input:checked + .slider:before {
77+
.bottom-bar .switch input:checked + .slider:before {
7778
transform: translateX(8px);
7879
}

apps/remix-ide/src/app/panels/layout.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface panels {
1818
tabs: panelState
1919
editor: panelState
2020
main: panelState
21+
bottomBar: panelState
2122
terminal: panelState
2223
}
2324

apps/remix-ide/src/app/panels/terminal.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import EventManager from '../../lib/events'
1010

1111
import { CompilerImports } from '@remix-project/core-plugin' // eslint-disable-line
1212
import { RemixUiXterminals } from '@remix-ui/xterm'
13-
import { BottomBar } from '../components/bottom-bar'
1413

1514
const KONSOLES = []
1615

@@ -143,7 +142,6 @@ export default class Terminal extends Plugin {
143142
updateComponent(state) {
144143
return (
145144
<>
146-
<BottomBar plugin={this} />
147145
<RemixUITerminalWrapper
148146
plugin={state.plugin}
149147
onReady={state.onReady}

0 commit comments

Comments
 (0)