Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 50 additions & 18 deletions components/playground/element.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
.wrapper {
display: grid;

grid-template-areas: "left runner";
grid-template-rows: 1fr;
grid-template-areas:
"left banner"
"left runner";
grid-template-rows: auto 1fr;
grid-template-columns: 1fr 1fr;

gap: 1rem;

height: 100%;

&:not(:has(.playground__runner-report-hint-banner)) {
grid-template-areas: "left runner";
grid-template-rows: 1fr;
}

section {
display: flex;

Expand Down Expand Up @@ -91,32 +98,57 @@
height: calc(100% - 2em);
}
}
}

&.playground__runner-console {
grid-area: runner;
.playground__runner-report-hint-banner {
display: flex;

overflow: hidden;
flex-wrap: wrap;

grid-area: banner;

gap: 0.5rem;
align-items: center;

padding: 0.5rem 0;

mdn-button {
align-self: flex-end;
border: var(--border);
border-radius: 0.25rem;
}

mdn-play-runner {
flex-grow: 1;
@media (--screen-medium-and-narrower) {
mdn-button {
align-self: center;
}
}
}

.playground__console {
background-color: var(--color-background-secondary);
border-top: var(--border);
.playground__runner-console {
grid-area: runner;

div {
font-size: var(--font-size-small);
font-weight: var(--font-weight-bold);
text-align: center;
}
overflow: hidden;

mdn-play-console {
height: 6rem;
}
border: var(--border);
border-radius: 0.25rem;

mdn-play-runner {
flex-grow: 1;
}

.playground__console {
background-color: var(--color-background-secondary);
border-top: var(--border);

div {
font-size: var(--font-size-small);
font-weight: var(--font-weight-bold);
text-align: center;
}

mdn-play-console {
height: 6rem;
}
}
}
Expand Down
30 changes: 25 additions & 5 deletions components/playground/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createRef, ref } from "lit/directives/ref.js";

import { L10nMixin } from "../../l10n/mixin.js";
import { gleanClick } from "../../utils/glean.js";
import warningIcon from "../icon/triangle-alert.svg?lit";
import { globalUser } from "../user/context.js";

import styles from "./element.css?lit";
Expand All @@ -30,6 +31,7 @@ export class MDNPlayground extends L10nMixin(LitElement) {

static properties = {
_gistID: { state: true },
_showReportHintBanner: { state: true },
};

constructor() {
Expand All @@ -38,6 +40,8 @@ export class MDNPlayground extends L10nMixin(LitElement) {
this._autoRun = true;
/** @type {string | undefined} */
this._gistId = undefined;
/** @type {boolean} */
this._showReportHintBanner = false;
}

/** @type {Ref<MDNPlayController>} */
Expand Down Expand Up @@ -81,6 +85,7 @@ export class MDNPlayground extends L10nMixin(LitElement) {
) {
controller.clear();
this._autoRun = true;
this._showReportHintBanner && this._dismissReportHintBanner();
this._storeSession();
this.requestUpdate();
const urlWithoutSearch = new URL(location.href);
Expand Down Expand Up @@ -188,6 +193,7 @@ ${"```"}`,

if (idParam) {
this._gistId = idParam;
this._showReportHintBanner = true;
}

const { srcPrefix: srcPrefixState, code } =
Expand Down Expand Up @@ -255,6 +261,10 @@ ${"```"}`,
this.requestUpdate();
}

_dismissReportHintBanner() {
this._showReportHintBanner = false;
}

_reportOpen() {
this._reportModal.value?.showModal();
}
Expand Down Expand Up @@ -282,6 +292,18 @@ ${"```"}`,
this._user.run();
}

_renderReportHintBanner() {
return html`<section class="playground__runner-report-hint-banner">
<mdn-button
@click=${this._reportOpen}
variant="plain"
.icon=${warningIcon}
>
Seeing something inappropriate?
</mdn-button>
</section>`;
}

render() {
const { code, initialCode } = this._controller.value ?? {};
const hasCode = Object.values(code ?? {}).some(Boolean);
Expand Down Expand Up @@ -355,12 +377,10 @@ ${"```"}`,
></mdn-play-editor>
</details>
</section>
${this._gistId && this._showReportHintBanner
? html`${this._renderReportHintBanner()}`
: nothing}
<section class="playground__runner-console">
${this._gistId
? html`<mdn-button @click=${this._reportOpen} variant="plain">
${this.l10n`Seeing something inappropriate?`}
</mdn-button>`
: nothing}
<mdn-play-runner></mdn-play-runner>
<div class="playground__console">
<div>${this.l10n`Console`}</div>
Expand Down
Loading