forked from tsai/budibase
committed by
GitHub
13 changed files with 112 additions and 95 deletions
@ -0,0 +1,16 @@ |
|||||
|
import { fade, blur, scale, fly } from "svelte/transition" |
||||
|
|
||||
|
// Default options
|
||||
|
const transitions = new Map([ |
||||
|
["fade", { tn: fade, opt: {} }], |
||||
|
["blur", { tn: blur, opt: {} }], |
||||
|
// This one seems to not result in any effect
|
||||
|
// ["slide", { tn: slide, opt: {} }],
|
||||
|
["scale", { tn: scale, opt: {} }], |
||||
|
["fly", { tn: fly, opt: { y: 80 } }], |
||||
|
]) |
||||
|
|
||||
|
export default function transition(node, { type, options = {} }) { |
||||
|
const { tn, opt } = transitions.get(type) || { tn: () => {}, opt: {} } |
||||
|
return tn(node, { ...opt, ...options }) |
||||
|
} |
||||
@ -1,62 +1,62 @@ |
|||||
<script> |
<script> |
||||
import { getContext } from "svelte" |
import { getContext } from "svelte" |
||||
|
|
||||
const { styleable } = getContext("sdk") |
const { styleable, transition } = getContext("sdk") |
||||
const component = getContext("component") |
const component = getContext("component") |
||||
|
|
||||
export let type = "div" |
export let type = "div" |
||||
</script> |
</script> |
||||
|
|
||||
{#if type === 'div'} |
{#if type === 'div'} |
||||
<div use:styleable={$component.styles}> |
<div in:transition={{type: $component.transition}} use:styleable={$component.styles}> |
||||
<slot /> |
<slot /> |
||||
</div> |
</div> |
||||
{:else if type === 'header'} |
{:else if type === 'header'} |
||||
<header use:styleable={$component.styles}> |
<header in:transition={{type: $component.transition}} use:styleable={$component.styles}> |
||||
<slot /> |
<slot /> |
||||
</header> |
</header> |
||||
{:else if type === 'main'} |
{:else if type === 'main'} |
||||
<main use:styleable={$component.styles}> |
<main in:transition={{type: $component.transition}} use:styleable={$component.styles}> |
||||
<slot /> |
<slot /> |
||||
</main> |
</main> |
||||
{:else if type === 'footer'} |
{:else if type === 'footer'} |
||||
<footer use:styleable={$component.styles}> |
<footer in:transition={{type: $component.transition}} use:styleable={$component.styles}> |
||||
<slot /> |
<slot /> |
||||
</footer> |
</footer> |
||||
{:else if type === 'aside'} |
{:else if type === 'aside'} |
||||
<aside use:styleable={$component.styles}> |
<aside in:transition={{type: $component.transition}} use:styleable={$component.styles}> |
||||
<slot /> |
<slot /> |
||||
</aside> |
</aside> |
||||
{:else if type === 'summary'} |
{:else if type === 'summary'} |
||||
<summary use:styleable={$component.styles}> |
<summary in:transition={{type: $component.transition}} use:styleable={$component.styles}> |
||||
<slot /> |
<slot /> |
||||
</summary> |
</summary> |
||||
{:else if type === 'details'} |
{:else if type === 'details'} |
||||
<details use:styleable={$component.styles}> |
<details in:transition={{type: $component.transition}} use:styleable={$component.styles}> |
||||
<slot /> |
<slot /> |
||||
</details> |
</details> |
||||
{:else if type === 'article'} |
{:else if type === 'article'} |
||||
<article use:styleable={$component.styles}> |
<article in:transition={{type: $component.transition}} use:styleable={$component.styles}> |
||||
<slot /> |
<slot /> |
||||
</article> |
</article> |
||||
{:else if type === 'nav'} |
{:else if type === 'nav'} |
||||
<nav use:styleable={$component.styles}> |
<nav in:transition={{type: $component.transition}} use:styleable={$component.styles}> |
||||
<slot /> |
<slot /> |
||||
</nav> |
</nav> |
||||
{:else if type === 'mark'} |
{:else if type === 'mark'} |
||||
<mark use:styleable={$component.styles}> |
<mark in:transition={{type: $component.transition}} use:styleable={$component.styles}> |
||||
<slot /> |
<slot /> |
||||
</mark> |
</mark> |
||||
{:else if type === 'figure'} |
{:else if type === 'figure'} |
||||
<figure use:styleable={$component.styles}> |
<figure in:transition={{type: $component.transition}} use:styleable={$component.styles}> |
||||
<slot /> |
<slot /> |
||||
</figure> |
</figure> |
||||
{:else if type === 'figcaption'} |
{:else if type === 'figcaption'} |
||||
<figcaption use:styleable={$component.styles}> |
<figcaption in:transition={{type: $component.transition}} use:styleable={$component.styles}> |
||||
<slot /> |
<slot /> |
||||
</figcaption> |
</figcaption> |
||||
{:else if type === 'paragraph'} |
{:else if type === 'paragraph'} |
||||
<p use:styleable={$component.styles}> |
<p in:transition={{type: $component.transition}} use:styleable={$component.styles}> |
||||
<slot /> |
<slot /> |
||||
</p> |
</p> |
||||
{/if} |
{/if} |
||||
|
|||||
Loading…
Reference in new issue