-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See #1
- Loading branch information
Showing
13 changed files
with
365 additions
and
19 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script> | ||
import { Cartesian } from "svelte-cartesian" | ||
import Button from "$lib/Button.svelte" | ||
const props = { | ||
props: { | ||
size: ["small", "medium", "large"], | ||
variant: ["primary", "secondary"], | ||
disabled: [true, false], | ||
definitions: [{ animals: "a holistic group of species" }], | ||
}, | ||
Component: Button, | ||
} | ||
</script> | ||
|
||
<h1>Labelled Cartesian</h1> | ||
|
||
<h2>Short - explicit</h2> | ||
|
||
<Cartesian {...props} labels="short">Make popcorn</Cartesian> | ||
|
||
<h2>Short - implicit</h2> | ||
|
||
<Cartesian {...props} labels>Make popcorn</Cartesian> | ||
|
||
<h2>Long</h2> | ||
|
||
<Cartesian {...props} labels="long">Make popcorn</Cartesian> | ||
|
||
<h2>Long with objects</h2> | ||
|
||
<Cartesian {...props} labels="long-with-objects">Make popcorn</Cartesian> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<script> | ||
import { Cartesian } from "svelte-cartesian" | ||
import Button from "$lib/Button.svelte" | ||
const props = { | ||
props: { | ||
size: ["small", "medium", "large"], | ||
variant: ["primary", "secondary"], | ||
disabled: [true, false], | ||
definitions: [{ animals: "a holistic group of species" }], | ||
}, | ||
Component: Button, | ||
} | ||
/** | ||
* @param {Record<string, any>} innerProps | ||
*/ | ||
function customLabel(innerProps) { | ||
return Object.entries(innerProps) | ||
.map(([key, value]) => { | ||
let refinedValue = value | ||
if (typeof value === "object") { | ||
refinedValue = JSON.stringify(value) | ||
} else if (typeof value !== "string" && typeof value !== "number") { | ||
refinedValue = typeof value | ||
} | ||
return `${key}: ${refinedValue}` | ||
}) | ||
.join("\n") | ||
} | ||
</script> | ||
|
||
<h2>Custom label, string value</h2> | ||
|
||
<Cartesian {...props} labels="long-with-objects"> | ||
Make popcorn | ||
<div class="label-container" slot="label" let:label> | ||
<span class="label">Props</span> | ||
<pre class="props">{label}</pre> | ||
</div> | ||
</Cartesian> | ||
|
||
<h2>Custom label, object value</h2> | ||
|
||
<Cartesian {...props} labels="long-with-objects"> | ||
Make popcorn | ||
<div class="label-container" slot="label" let:innerProps> | ||
<span class="label">Props</span> | ||
<pre class="props">{customLabel(innerProps)}</pre> | ||
</div> | ||
</Cartesian> | ||
|
||
<style> | ||
.label-container { | ||
border: 1px solid black; | ||
border-radius: 3px; | ||
padding: 0.5rem; | ||
margin-top: 0.5rem; | ||
} | ||
.label { | ||
font-size: 1.25rem; | ||
font-weight: 600; | ||
} | ||
.props { | ||
color: crimson; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<script> | ||
import Page from "../+page.svelte" | ||
</script> | ||
|
||
<Page /> | ||
|
||
<style> | ||
:global(body) { | ||
background-color: #000; | ||
color: #fff; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.