Skip to content

Commit 2a49f55

Browse files
ioedeveloperAniket-Engg
authored andcommitted
Show highlight in pinned-panel
1 parent d9c90ff commit 2a49f55

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed

apps/remix-ide/src/app/components/pinned-panel.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ const pinnedPanel = {
1111
displayName: 'Pinned Panel',
1212
description: 'Remix IDE pinned panel',
1313
version: packageJson.version,
14-
methods: ['addView', 'removeView', 'currentFocus', 'pinView', 'unPinView']
14+
methods: ['addView', 'removeView', 'currentFocus', 'pinView', 'unPinView', 'highlight']
1515
}
1616

1717
export class PinnedPanel extends AbstractPanel {
1818
dispatch: React.Dispatch<any> = () => {}
19-
loggedState: any
19+
loggedState: Record<string, any>
20+
highlightStamp: number
2021

2122
constructor() {
2223
super(pinnedPanel)
@@ -61,24 +62,30 @@ export class PinnedPanel extends AbstractPanel {
6162
this.emit('unPinnedPlugin', profile)
6263
}
6364

65+
highlight () {
66+
this.highlightStamp = Date.now()
67+
this.renderComponent()
68+
}
69+
6470
setDispatch (dispatch: React.Dispatch<any>) {
6571
this.dispatch = dispatch
6672
}
6773

6874
render() {
6975
return (
70-
<section className='panel pinned-panel'> <PluginViewWrapper plugin={this} /></section>
76+
<section className='panel pinned-panel highlight'> <PluginViewWrapper plugin={this} /></section>
7177
)
7278
}
7379

7480
updateComponent(state: any) {
75-
return <RemixPluginPanel header={<RemixUIPanelHeader plugins={state.plugins} pinView={this.pinView.bind(this)} unPinView={this.unPinView.bind(this)}></RemixUIPanelHeader>} plugins={state.plugins} pluginState={state.pluginState} />
81+
return <RemixPluginPanel header={<RemixUIPanelHeader plugins={state.plugins} pinView={this.pinView.bind(this)} unPinView={this.unPinView.bind(this)}></RemixUIPanelHeader>} { ...state } />
7682
}
7783

7884
renderComponent() {
7985
this.dispatch({
8086
plugins: this.plugins,
81-
pluginState: this.loggedState
87+
pluginState: this.loggedState,
88+
highlightStamp: this.highlightStamp
8289
})
8390
}
8491
}

libs/remix-ui/panel/src/lib/plugins/panel-plugin.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import './panel.css'
55
interface panelPLuginProps {
66
pluginRecord: PluginRecord,
77
initialState?: any,
8+
highlightStamp?: number,
89
children?: any
910
}
1011

1112
const RemixUIPanelPlugin = (props: panelPLuginProps, panelRef: any) => {
1213
const localRef = useRef<HTMLDivElement>(null)
1314
const [view, setView] = useState<JSX.Element | HTMLDivElement>()
15+
const [showHighlight, setShowHighlight] = useState<boolean>(false)
16+
1417
useEffect(() => {
1518
const ref: any = panelRef || localRef
1619
if (ref.current) {
@@ -39,8 +42,20 @@ const RemixUIPanelPlugin = (props: panelPLuginProps, panelRef: any) => {
3942
}
4043
}, [])
4144

45+
useEffect(() => {
46+
setShowHighlight(true)
47+
}, [props.highlightStamp])
48+
49+
useEffect(() => {
50+
if (showHighlight) {
51+
setTimeout(() => {
52+
setShowHighlight(false)
53+
}, 500)
54+
}
55+
}, [showHighlight])
56+
4257
return (
43-
<div className={props.pluginRecord.active ? `${props.pluginRecord.class}` : 'd-none'} ref={panelRef || localRef}>
58+
<div className={`${props.pluginRecord.active ? `${props.pluginRecord.class}` : 'd-none'} ${showHighlight ? 'highlight' : ''}`} ref={panelRef || localRef}>
4459
<>{view}</>
4560
</div>
4661
)

libs/remix-ui/panel/src/lib/plugins/panel.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,7 @@ iframe {
106106

107107
.terminal-wrap.minimized.desktop {
108108
}
109+
110+
.highlight {
111+
animation: highlight 2s forwards;
112+
}

libs/remix-ui/panel/src/lib/plugins/remix-ui-panel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface RemixPanelProps {
99
plugins: Record<string, PluginRecord>,
1010
header: JSX.Element,
1111
pluginState?: any,
12+
highlightStamp?: number
1213
}
1314

1415
export function RemixPluginPanel(props: RemixPanelProps) {
@@ -18,7 +19,7 @@ export function RemixPluginPanel(props: RemixPanelProps) {
1819
<div className="pluginsContainer">
1920
<div className="plugins" id="plugins">
2021
{Object.values(props.plugins).map((pluginRecord) => {
21-
return <RemixUIPanelPlugin key={pluginRecord.profile.name} pluginRecord={pluginRecord} initialState={props.pluginState} />
22+
return <RemixUIPanelPlugin key={pluginRecord.profile.name} pluginRecord={pluginRecord} initialState={props.pluginState} highlightStamp={props.highlightStamp} />
2223
})}
2324
</div>
2425
</div>

libs/remix-ui/vertical-icons-panel/src/lib/components/Icon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const Icon = ({ iconRecord, verticalIconPlugin, contextMenuAction, theme }: Icon
101101
className={`remixui_icon m-0 pt-1`}
102102
onClick={() => {
103103
if (iconRecord.pinned) {
104-
console.log('called an already pinned plugin')
104+
verticalIconPlugin.call('pinnedPanel', 'highlight')
105105
} else {
106106
(verticalIconPlugin as any).toggle(name)
107107
}

0 commit comments

Comments
 (0)