Skip to content

Commit d874d50

Browse files
committed
hideing on click outside panel
1 parent c5f5829 commit d874d50

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

apps/remix-ide/src/app/ui/landing-page/landing-page.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ export class LandingPage extends ViewPlugin {
111111
this.verticalIcons = verticalIcons
112112
this.gistHandler = new GistHandler()
113113
const themeQuality = globalRegistry.get('themeModule').api.currentTheme().quality
114-
window.addEventListener('resize', () => this.adjustRightPanel())
114+
window.addEventListener('resize', () => this.adjustMediaPanel())
115+
window.addEventListener('click', (e) => this.hideMediaPanel(e))
115116
this.twitterFrame = yo`
116117
<div class="px-2 ${css.media}">
117118
<a class="twitter-timeline"
@@ -158,18 +159,29 @@ export class LandingPage extends ViewPlugin {
158159
</div>
159160
</div>
160161
`
161-
this.adjustRightPanel()
162+
this.adjustMediaPanel()
162163
globalRegistry.get('themeModule').api.events.on('themeChanged', (theme) => {
163164
console.log("theme is ", theme.quality)
164165
this.onThemeChanged(theme.quality)
165166
})
166167
}
167168

168-
adjustRightPanel () {
169+
adjustMediaPanel () {
169170
this.twitterPanel.style.maxHeight = Math.max(window.innerHeight - 150, 200) + 'px'
170171
this.mediumPanel.style.maxHeight = Math.max(window.innerHeight - 150, 200) + 'px'
171172
}
172173

174+
hideMediaPanel (e) {
175+
const mediaPanelsTitle = document.getElementById('remixIDEMediaPanelsTitle')
176+
const mediaPanels = document.getElementById('remixIDEMediaPanels')
177+
if (!mediaPanelsTitle.contains(e.target) && !mediaPanels.contains(e.target)) {
178+
this.mediumPanel.classList.remove('d-block')
179+
this.mediumPanel.classList.add('d-none')
180+
this.twitterPanel.classList.remove('d-block')
181+
this.twitterPanel.classList.add('d-none')
182+
}
183+
}
184+
173185
onThemeChanged (themeQuality) {
174186
console.log("themes in listener is", themeQuality)
175187
let twitterFrame = yo`
@@ -411,11 +423,11 @@ export class LandingPage extends ViewPlugin {
411423
</div><!-- end of hpSections -->
412424
</div>
413425
<div class="d-flex flex-column ${css.rightPanel}">
414-
<div class="d-flex pr-2 py-2 align-self-end">
426+
<div class="d-flex pr-2 py-2 align-self-end" id="remixIDEMediaPanelsTitle">
415427
${this.badgeTwitter}
416428
${this.badgeMedium}
417429
</div>
418-
<div class="mr-3 d-flex bg-light ${css.panels}">
430+
<div class="mr-3 d-flex bg-light ${css.panels}" id="remixIDEMediaPanels">
419431
${this.mediumPanel}
420432
${this.twitterPanel}
421433
</div>

0 commit comments

Comments
 (0)