Skip to content

Commit 7139f2c

Browse files
committed
fix(playground): allow report hint banner to be dismissed
1 parent e4e4bf9 commit 7139f2c

2 files changed

Lines changed: 52 additions & 4 deletions

File tree

components/playground/element.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,32 @@
104104
flex-grow: 1;
105105
}
106106

107+
.playground__runner-report-hint-banner {
108+
display: flex;
109+
110+
&:hover {
111+
background-color: var(--color-background-secondary);
112+
}
113+
114+
button {
115+
padding: 0.5em;
116+
117+
font-size: 0.875em;
118+
font-weight: 450;
119+
120+
background-color: transparent;
121+
border: none;
122+
}
123+
124+
.report-hint-button {
125+
flex-grow: 1;
126+
}
127+
128+
.report-hint-close-button span:hover {
129+
color: var(--error-color, #dd3333);
130+
}
131+
}
132+
107133
.playground__console {
108134
background-color: var(--color-background-secondary);
109135
border-top: var(--border);

components/playground/element.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class MDNPlayground extends L10nMixin(LitElement) {
3030

3131
static properties = {
3232
_gistID: { state: true },
33+
_showReportHintBanner: { state: true },
3334
};
3435

3536
constructor() {
@@ -38,6 +39,8 @@ export class MDNPlayground extends L10nMixin(LitElement) {
3839
this._autoRun = true;
3940
/** @type {string | undefined} */
4041
this._gistId = undefined;
42+
/** @type {boolean} */
43+
this._showReportHintBanner = false;
4144
}
4245

4346
/** @type {Ref<MDNPlayController>} */
@@ -188,6 +191,7 @@ ${"```"}`,
188191

189192
if (idParam) {
190193
this._gistId = idParam;
194+
this._showReportHintBanner = true;
191195
}
192196

193197
const { srcPrefix: srcPrefixState, code } =
@@ -255,7 +259,12 @@ ${"```"}`,
255259
this.requestUpdate();
256260
}
257261

262+
_dismissReportHintBanner() {
263+
this._showReportHintBanner = false;
264+
}
265+
258266
_reportOpen() {
267+
this._dismissReportHintBanner();
259268
this._reportModal.value?.showModal();
260269
}
261270

@@ -282,6 +291,21 @@ ${"```"}`,
282291
this._user.run();
283292
}
284293

294+
_renderReportHintBanner() {
295+
return html`<div class="playground__runner-report-hint-banner">
296+
<button class="report-hint-button" @click=${this._reportOpen}>
297+
Seeing something inappropriate?
298+
</button>
299+
<button
300+
class="report-hint-close-button"
301+
@click=${this._dismissReportHintBanner}
302+
aria-label=${this.l10n`Close report hint banner`}
303+
>
304+
<span>X</span>
305+
</button>
306+
</div>`;
307+
}
308+
285309
render() {
286310
const { code, initialCode } = this._controller.value ?? {};
287311
const hasCode = Object.values(code ?? {}).some(Boolean);
@@ -356,10 +380,8 @@ ${"```"}`,
356380
</details>
357381
</section>
358382
<section class="playground__runner-console">
359-
${this._gistId
360-
? html`<mdn-button @click=${this._reportOpen} variant="plain">
361-
Seeing something inappropriate?
362-
</mdn-button>`
383+
${this._gistId && this._showReportHintBanner
384+
? html`${this._renderReportHintBanner()}`
363385
: nothing}
364386
<mdn-play-runner></mdn-play-runner>
365387
<div class="playground__console">

0 commit comments

Comments
 (0)