docs(preview): append current theme to iframe url

This commit is contained in:
Eric Liu 2020-10-26 12:25:38 -07:00
commit 4d89c83723

View file

@ -7,8 +7,10 @@
import { CodeSnippet, Button } from "carbon-components-svelte"; import { CodeSnippet, Button } from "carbon-components-svelte";
import Launch16 from "carbon-icons-svelte/lib/Launch16"; import Launch16 from "carbon-icons-svelte/lib/Launch16";
import copy from "clipboard-copy"; import copy from "clipboard-copy";
import { url, beforeUrlChange } from "@sveltech/routify"; import { url } from "@sveltech/routify";
import { theme } from "../store"; import { theme } from "../store";
$: themedSrcUrl = $url(`${src}?theme=${$theme}`);
</script> </script>
<style global> <style global>
@ -84,6 +86,10 @@
color: #bb8eff; color: #bb8eff;
} }
.token.number {
color: #a7f0ba;
}
.token.comment { .token.comment {
color: #bebebe; color: #bebebe;
} }
@ -138,7 +144,7 @@
kind="ghost" kind="ghost"
target="_blank" target="_blank"
size="field" size="field"
href="{$url(src)}" href="{themedSrcUrl}"
icon="{Launch16}" icon="{Launch16}"
> >
Open in new tab Open in new tab
@ -147,10 +153,7 @@
{/if} {/if}
<div class="preview-viewer" class:framed> <div class="preview-viewer" class:framed>
{#if framed} {#if framed}
<iframe <iframe title="{src.split('/').pop()}" src="{themedSrcUrl}"></iframe>
title="{src.split('/').pop()}"
src="{$url(`${src}?theme=${$theme}`)}"
></iframe>
{:else} {:else}
<slot /> <slot />
{/if} {/if}