diff options
Diffstat (limited to 'static/shared/playground/playground.ts')
| -rw-r--r-- | static/shared/playground/playground.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/static/shared/playground/playground.ts b/static/shared/playground/playground.ts index 882f097f..c0dd0cf4 100644 --- a/static/shared/playground/playground.ts +++ b/static/shared/playground/playground.ts @@ -19,6 +19,7 @@ const PlayExampleClassName = { PLAY_CONTAINER: '.js-exampleContainer', EXAMPLE_INPUT: '.Documentation-exampleCode', EXAMPLE_OUTPUT: '.Documentation-exampleOutput', + EXAMPLE_OUTPUT_CONTAINER: '.js-exampleOutputContainer', EXAMPLE_ERROR: '.Documentation-exampleError', PLAY_BUTTON: '.Documentation-examplePlayButton', SHARE_BUTTON: '.Documentation-exampleShareButton', @@ -72,6 +73,11 @@ export class PlaygroundExampleController { private readonly outputEl: Element | null; /** + * The container for the output. + */ + private readonly outputContainerEl: HTMLElement | null; + + /** * @param exampleEl The div that contains playground content for the given example. */ constructor(private readonly exampleEl: HTMLDetailsElement) { @@ -84,6 +90,7 @@ export class PlaygroundExampleController { this.runButtonEl = exampleEl.querySelector(PlayExampleClassName.RUN_BUTTON); this.inputEl = this.makeTextArea(exampleEl.querySelector(PlayExampleClassName.EXAMPLE_INPUT)); this.outputEl = exampleEl.querySelector(PlayExampleClassName.EXAMPLE_OUTPUT); + this.outputContainerEl = exampleEl.querySelector(PlayExampleClassName.EXAMPLE_OUTPUT_CONTAINER); // This is legacy listener to be replaced the listener for shareButtonEl. this.playButtonEl?.addEventListener('click', () => this.handleShareButtonClick()); @@ -167,6 +174,9 @@ export class PlaygroundExampleController { if (this.outputEl) { this.outputEl.textContent = output; } + if (this.outputContainerEl) { + this.outputContainerEl.hidden = false; + } } /** @@ -176,6 +186,9 @@ export class PlaygroundExampleController { if (this.outputEl) { this.outputEl.textContent += output; } + if (this.outputContainerEl) { + this.outputContainerEl.hidden = false; + } } private setOutputHTML(output: string) { |
