mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
docs: display button variants
This commit is contained in:
parent
4016dd0847
commit
9aa01ce5fb
9 changed files with 184 additions and 24 deletions
|
@ -14,25 +14,53 @@
|
|||
<script>
|
||||
export let data = {};
|
||||
|
||||
import { onMount } from "svelte";
|
||||
import { onMount, getContext } from "svelte";
|
||||
|
||||
const ctx = getContext("navigation");
|
||||
|
||||
let component = undefined;
|
||||
|
||||
onMount(async () => {
|
||||
ctx.setTail(data);
|
||||
|
||||
try {
|
||||
component = await import(`../examples/${data.title}.svelte`);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
return () => {
|
||||
ctx.setTail(undefined);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.preview {
|
||||
margin-left: -1rem;
|
||||
margin-right: -1rem;
|
||||
padding: 1rem;
|
||||
white-space: nowrap;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
:global(.preview > div) {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 0.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
<svelte:head>
|
||||
<title>{data.title}</title>
|
||||
</svelte:head>
|
||||
|
||||
<h1>{data.title}</h1>
|
||||
|
||||
{#if component}
|
||||
<svelte:component this={component.default} />
|
||||
{/if}
|
||||
<div class="preview">
|
||||
{#if component}
|
||||
<svelte:component this={component.default} />
|
||||
{/if}
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue