2022-03-20 00:19:51 -07:00
|
|
|
<script lang="ts">
|
2022-05-20 19:53:13 -07:00
|
|
|
import { Button } from 'omorphia';
|
|
|
|
|
import IconMoon from 'virtual:icons/heroicons-outline/moon';
|
|
|
|
|
import IconSun from 'virtual:icons/heroicons-outline/sun';
|
2022-03-20 00:19:51 -07:00
|
|
|
|
2022-04-16 00:29:35 -07:00
|
|
|
export let meta: { raised: boolean };
|
|
|
|
|
|
2022-05-20 19:53:13 -07:00
|
|
|
let theme = 'light';
|
|
|
|
|
let background = meta.raised ? 'var(--color-raised-bg)' : 'var(--color-bg)';
|
2022-03-20 00:19:51 -07:00
|
|
|
</script>
|
|
|
|
|
|
2022-03-29 00:44:23 -07:00
|
|
|
<div class="example">
|
2022-05-20 19:53:13 -07:00
|
|
|
<div class="example__preview theme-{theme} base" style:background>
|
|
|
|
|
<slot name="example" />
|
2022-04-02 16:17:58 -07:00
|
|
|
</div>
|
|
|
|
|
<div class="example__source">
|
|
|
|
|
<div class="example__source__options">
|
2022-05-20 19:53:13 -07:00
|
|
|
<Button
|
|
|
|
|
color="primary-light"
|
|
|
|
|
on:click={() => (theme === 'light' ? (theme = 'dark') : (theme = 'light'))}
|
|
|
|
|
>
|
2022-03-29 00:44:23 -07:00
|
|
|
{#if theme === 'light'}
|
2022-05-20 19:53:13 -07:00
|
|
|
<IconMoon />
|
2022-03-29 00:44:23 -07:00
|
|
|
{:else}
|
2022-05-20 19:53:13 -07:00
|
|
|
<IconSun />
|
2022-03-29 00:44:23 -07:00
|
|
|
{/if}
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
2022-05-20 19:53:13 -07:00
|
|
|
<pre class="example__source__code language-svelte"><slot name="code" /></pre>
|
2022-03-20 00:19:51 -07:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<style lang="postcss">
|
|
|
|
|
.example {
|
2022-05-20 19:53:13 -07:00
|
|
|
margin: 15px 0 32px;
|
2022-03-20 11:14:46 -07:00
|
|
|
|
2022-03-20 00:19:51 -07:00
|
|
|
&__preview {
|
|
|
|
|
border-radius: var(--rounded-sm-top);
|
|
|
|
|
border: solid 2px hsl(0, 0%, 20%);
|
|
|
|
|
border-bottom: none;
|
|
|
|
|
display: flex;
|
|
|
|
|
grid-gap: 16px;
|
|
|
|
|
flex-wrap: wrap;
|
2022-03-29 00:44:23 -07:00
|
|
|
position: relative;
|
|
|
|
|
justify-content: flex-start;
|
2022-03-30 18:36:13 -07:00
|
|
|
z-index: 1;
|
2022-04-03 11:45:04 -07:00
|
|
|
padding: 16px;
|
2022-04-02 16:17:58 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&__source {
|
|
|
|
|
position: relative;
|
2022-03-29 00:44:23 -07:00
|
|
|
|
|
|
|
|
&__options {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
padding: 8px;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: flex-end;
|
2022-04-02 16:17:58 -07:00
|
|
|
|
|
|
|
|
:global(button) {
|
|
|
|
|
color: black;
|
|
|
|
|
}
|
2022-03-29 00:44:23 -07:00
|
|
|
}
|
2022-03-20 00:19:51 -07:00
|
|
|
|
2022-04-02 16:17:58 -07:00
|
|
|
&__code {
|
|
|
|
|
margin: 0;
|
|
|
|
|
border-radius: var(--rounded-sm-bottom) !important;
|
|
|
|
|
background: hsl(220, 13%, 22%);
|
|
|
|
|
}
|
2022-03-20 00:19:51 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|