This commit is contained in:
NyxCode 2022-08-17 14:02:04 +00:00 committed by GitHub
commit ef04c003bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 110 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<script>
import { Checkbox } from "carbon-components-svelte";
export let value = undefined;
</script>
<Checkbox bind:checked="{value}" {...$$restProps} />

View file

@ -0,0 +1,65 @@
<script>
import { Form } from "carbon-components-svelte";
import Checkbox from "./Checkbox.svelte";
import TextInput from "./TextInput.svelte";
export let component;
export let props;
const components = { Checkbox, TextInput };
const usedProps = {};
</script>
<div class="playground">
<div class="element">
<div class="element-wrapper">
<svelte:component this="{component}" {...usedProps} />
</div>
</div>
<div class="options">
<h4 class="options-heading">Options</h4>
<div class="options-content">
<Form>
{#each Object.entries(props) as [name, prop]}
<svelte:component
this="{components[prop.component]}"
bind:value="{usedProps[name]}"
{...prop.props}
/>
{/each}
</Form>
</div>
</div>
</div>
<style>
.playground {
border: 1px solid var(--cds-ui-03);
display: flex;
flex-direction: row;
margin: 0 -1rem;
max-width: 56rem;
}
.element {
border-right: 1px solid var(--cds-ui-03);
flex-basis: 60%;
display: flex;
align-items: center;
padding: 1rem;
}
.options {
flex-basis: 40%;
}
.options-heading {
border-bottom: 1px solid var(--cds-ui-03);
padding: 0.5rem 1rem;
}
.options-content {
padding: 1rem;
}
</style>

View file

@ -0,0 +1,7 @@
<script>
import { TextInput } from "carbon-components-svelte";
export let value;
</script>
<TextInput style="margin-bottom: 1rem;" bind:value {...$$restProps} />

View file

@ -1,8 +1,38 @@
<script> <script>
import { Checkbox, InlineNotification } from "carbon-components-svelte"; import { Checkbox, InlineNotification } from "carbon-components-svelte";
import Preview from "../../components/Preview.svelte"; import Preview from "../../components/Preview.svelte";
import Playground from "../../components/playground/Playground.svelte";
</script> </script>
<Playground
component={Checkbox}
props={{
labelText: {
component: "TextInput",
props: { value: "Label text", labelText: "Label" }
},
checked: {
component: "Checkbox",
props: { labelText: "Checked" }
},
indeterminate: {
component: "Checkbox",
props: { labelText: "Indeterminate" }
},
hideLabel: {
component: "Checkbox",
props: { labelText: "Hide label" }
},
disabled: {
component: "Checkbox",
props: { labelText: "Disabled" }
},
skeleton: {
component: "Checkbox",
props: { labelText: "Skeleton" }
},
}} />
### Default (unchecked) ### Default (unchecked)
<Checkbox labelText="Label text" /> <Checkbox labelText="Label text" />

View file

@ -77,6 +77,7 @@ function plugin() {
if ( if (
node.lang !== "svelte" && node.lang !== "svelte" &&
!node.value.startsWith("<FileSource") && !node.value.startsWith("<FileSource") &&
!node.value.startsWith("<Playground") &&
!node.value.startsWith("<script>") && !node.value.startsWith("<script>") &&
!node.value.match(/svx-ignore/g) !node.value.match(/svx-ignore/g)
) { ) {