Skip to content

Commit

Permalink
Merge pull request #378 from guardian/ei/hide-html-by-default
Browse files Browse the repository at this point in the history
Don't show HTML and CSS by default
  • Loading branch information
emma-imber authored Apr 19, 2024
2 parents 1c0a6b0 + b3eae57 commit 97a49fb
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/lib/Code.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
<script lang="ts">
import { slide } from 'svelte/transition';
export let html: string;
export let css: string;
export let showHTML = false;
export let showCSS = false;
</script>

<section id="code">
<h3>CODE</h3>

<div class="html">
<h2>HTML</h2>
<pre>{html}</pre>
<button on:click={() => (showHTML = !showHTML)}>
{showHTML ? 'Hide HTML' : 'Show HTML'}
</button>
{#if showHTML}
<pre transition:slide>{html}</pre>
{/if}
</div>
<div>
<h2>CSS</h2>
<pre>{css}</pre>
<button on:click={() => (showCSS = !showCSS)}>
{#if showCSS}
Hide CSS
{:else}
Show CSS
{/if}
</button>
{#if showCSS}
<pre transition:slide>{css}</pre>
{/if}
</div>
</section>

Expand All @@ -31,4 +49,14 @@
h3 {
grid-column: span 2;
}
button {
color: white;
border: 2px solid darkblue;
background-color: darkblue;
border-radius: 15px;
font-size: 1rem;
font-family: inherit;
padding: 5px 10px;
}
</style>

0 comments on commit 97a49fb

Please sign in to comment.