1
0
Fork 0
mirror of synced 2024-06-30 03:50:37 +12:00

Add component data binding and simplify context sharing

This commit is contained in:
Andrew Kingston 2020-11-24 11:02:10 +00:00
parent 853f5d8745
commit e62fbf8ef7
31 changed files with 180 additions and 148 deletions

View file

@ -2,11 +2,11 @@
import { setContext, onMount } from "svelte" import { setContext, onMount } from "svelte"
import Component from "./Component.svelte" import Component from "./Component.svelte"
import SDK from "../sdk" import SDK from "../sdk"
import { routeStore, screenStore, createDataContextStore } from "../store" import { routeStore, screenStore, createDataStore } from "../store"
// Provide contexts // Provide contexts
setContext("sdk", SDK) setContext("sdk", SDK)
setContext("data", createDataContextStore()) setContext("data", createDataStore())
let loaded = false let loaded = false

View file

@ -3,6 +3,8 @@
import { writable } from "svelte/store" import { writable } from "svelte/store"
import * as ComponentLibrary from "@budibase/standard-components" import * as ComponentLibrary from "@budibase/standard-components"
import Router from "./Router.svelte" import Router from "./Router.svelte"
import { enrichDataBinding } from "../utils"
import { bindingStore } from "../store"
export let definition = {} export let definition = {}
@ -23,6 +25,19 @@
return props return props
} }
// Enriches data bindings to real values based on data context
const enrichDataBindings = (data, bindings, props) => {
const state = {
...data,
...bindings,
}
let enrichedProps = {}
Object.entries(props).forEach(([key, value]) => {
enrichedProps[key] = enrichDataBinding(value, state)
})
return enrichedProps
}
// Gets the component constructor for the specified component // Gets the component constructor for the specified component
const getComponentConstructor = name => { const getComponentConstructor = name => {
return name === "screenslot" ? Router : ComponentLibrary[componentName] return name === "screenslot" ? Router : ComponentLibrary[componentName]
@ -32,14 +47,25 @@
$: componentName = extractComponentName(definition._component) $: componentName = extractComponentName(definition._component)
$: constructor = getComponentConstructor(componentName) $: constructor = getComponentConstructor(componentName)
$: componentProps = extractValidProps(definition) $: componentProps = extractValidProps(definition)
$: dataContext = getContext("data")
$: enrichedProps = dataContext.actions.enrichDataBindings(componentProps)
$: children = definition._children $: children = definition._children
$: id = definition._id
$: dataStore = getContext("data")
$: enrichedProps = enrichDataBindings(
$dataStore,
$bindingStore,
componentProps
)
// Set observable style context // Update component context
const styleStore = writable({}) // ID is duplicated inside style so that the "styleable" helper can set
setContext("style", styleStore) // an ID data tag for unique reference to components
$: styleStore.set({ ...definition._styles, id: definition._id }) const componentStore = writable({})
setContext("component", componentStore)
$: componentStore.set({
id,
styles: { ...definition._styles, id },
dataContext: $dataStore.data,
})
</script> </script>
{#if constructor} {#if constructor}

View file

@ -1,19 +1,19 @@
<script> <script>
import { getContext, setContext } from "svelte" import { getContext, setContext } from "svelte"
import { createDataContextStore } from "../store" import { createDataStore } from "../store"
export let row export let row
// Get current contexts // Get current contexts
const dataContext = getContext("data") const data = getContext("data")
const styles = getContext("style") const component = getContext("component")
// Clone current context to this context // Clone current context to this context
const newDataContext = createDataContextStore($dataContext) const newData = createDataStore($data)
setContext("data", newDataContext) setContext("data", newData)
// Add additional layer to context // Add additional layer to context
$: newDataContext.actions.addContext(row, $styles.id) $: newData.actions.addContext(row, $component.id)
</script> </script>
<slot /> <slot />

View file

@ -5,7 +5,7 @@
import Screen from "./Screen.svelte" import Screen from "./Screen.svelte"
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
$: routerConfig = getRouterConfig($routeStore.routes) $: routerConfig = getRouterConfig($routeStore.routes)
@ -26,7 +26,7 @@
</script> </script>
{#if routerConfig} {#if routerConfig}
<div use:styleable={$styles}> <div use:styleable={$component.styles}>
<Router on:routeLoading={onRouteLoading} routes={routerConfig} /> <Router on:routeLoading={onRouteLoading} routes={routerConfig} />
</div> </div>
{/if} {/if}

View file

@ -1,5 +1,5 @@
import * as API from "./api" import * as API from "./api"
import { authStore, routeStore, screenStore } from "./store" import { authStore, routeStore, screenStore, bindingStore } from "./store"
import { styleable, getAppId } from "./utils" import { styleable, getAppId } from "./utils"
import { link as linkable } from "svelte-spa-router" import { link as linkable } from "svelte-spa-router"
import DataProvider from "./components/DataProvider.svelte" import DataProvider from "./components/DataProvider.svelte"
@ -13,4 +13,5 @@ export default {
linkable, linkable,
getAppId, getAppId,
DataProvider, DataProvider,
setBindableValue: bindingStore.actions.setBindableValue,
} }

View file

@ -5,9 +5,6 @@ import { writable } from "svelte/store"
const createAuthStore = () => { const createAuthStore = () => {
const store = writable("") const store = writable("")
/**
* Logs a user in.
*/
const logIn = async ({ username, password }) => { const logIn = async ({ username, password }) => {
const user = await API.logIn({ username, password }) const user = await API.logIn({ username, password })
if (!user.error) { if (!user.error) {
@ -15,10 +12,6 @@ const createAuthStore = () => {
location.reload() location.reload()
} }
} }
/**
* Logs a user out.
*/
const logOut = () => { const logOut = () => {
store.set("") store.set("")
const appId = getAppId() const appId = getAppId()

View file

@ -0,0 +1,21 @@
import { writable } from "svelte/store"
const createBindingStore = () => {
const store = writable({})
const setBindableValue = (value, componentId) => {
store.update(state => {
if (componentId) {
state[componentId] = value
}
return state
})
}
return {
subscribe: store.subscribe,
actions: { setBindableValue },
}
}
export const bindingStore = createBindingStore()

View file

@ -0,0 +1,27 @@
import { writable } from "svelte/store"
import { cloneDeep } from "lodash/fp"
const initialValue = {
data: null,
}
export const createDataStore = existingContext => {
const initial = existingContext ? cloneDeep(existingContext) : initialValue
const store = writable(initial)
// Adds a context layer to the data context tree
const addContext = (row, componentId) => {
store.update(state => {
if (componentId) {
state[componentId] = row
state.data = row
}
return state
})
}
return {
subscribe: store.subscribe,
actions: { addContext },
}
}

View file

@ -1,39 +0,0 @@
import { writable, get } from "svelte/store"
import { enrichDataBinding } from "../utils"
import { cloneDeep } from "lodash/fp"
const initialValue = {
data: null,
}
export const createDataContextStore = existingContext => {
const initial = existingContext ? cloneDeep(existingContext) : initialValue
const store = writable(initial)
// Adds a context layer to the data context tree
const addContext = (row, componentId) => {
store.update(state => {
if (row && componentId) {
state[componentId] = row
state.data = row
}
return state
})
}
// Enriches props by running mustache and filling in any data bindings present
// in the prop values
const enrichDataBindings = props => {
const state = get(store)
let enrichedProps = {}
Object.entries(props).forEach(([key, value]) => {
enrichedProps[key] = enrichDataBinding(value, state)
})
return enrichedProps
}
return {
subscribe: store.subscribe,
actions: { addContext, enrichDataBindings },
}
}

View file

@ -1,5 +1,8 @@
export { authStore } from "./auth" export { authStore } from "./auth"
export { routeStore } from "./routes" export { routeStore } from "./routes"
export { screenStore } from "./screens" export { screenStore } from "./screens"
export { createDataContextStore } from "./dataContext"
export { builderStore } from "./builder" export { builderStore } from "./builder"
export { bindingStore } from "./binding"
// Data stores are layered and duplicated, so it is not a singleton
export { createDataStore } from "./data"

View file

@ -2,14 +2,17 @@
import { getContext } from "svelte" import { getContext } from "svelte"
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export let className = "default" export let className = "default"
export let disabled = false export let disabled = false
export let text export let text
</script> </script>
<button class="default" disabled={disabled || false} use:styleable={$styles}> <button
class="default"
disabled={disabled || false}
use:styleable={$component.styles}>
{text} {text}
</button> </button>

View file

@ -3,7 +3,7 @@
import { cssVars } from "./helpers" import { cssVars } from "./helpers"
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export const className = "" export const className = ""
export let imageUrl = "" export let imageUrl = ""
@ -26,7 +26,10 @@
$: showImage = !!imageUrl $: showImage = !!imageUrl
</script> </script>
<div use:cssVars={cssVariables} class="container" use:styleable={$styles}> <div
use:cssVars={cssVariables}
class="container"
use:styleable={$component.styles}>
{#if showImage}<img class="image" src={imageUrl} alt="" />{/if} {#if showImage}<img class="image" src={imageUrl} alt="" />{/if}
<div class="content"> <div class="content">
<h2 class="heading">{heading}</h2> <h2 class="heading">{heading}</h2>

View file

@ -3,7 +3,7 @@
import { cssVars } from "./helpers" import { cssVars } from "./helpers"
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export const className = "" export const className = ""
export let imageUrl = "" export let imageUrl = ""
@ -29,7 +29,10 @@
$: showImage = !!imageUrl $: showImage = !!imageUrl
</script> </script>
<div use:cssVars={cssVariables} class="container" use:styleable={$styles}> <div
use:cssVars={cssVariables}
class="container"
use:styleable={$component.styles}>
{#if showImage}<img class="image" src={imageUrl} alt="" />{/if} {#if showImage}<img class="image" src={imageUrl} alt="" />{/if}
<div class="content"> <div class="content">
<main> <main>

View file

@ -2,62 +2,62 @@
import { getContext } from "svelte" import { getContext } from "svelte"
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export let className = "" export let className = ""
export let type = "div" export let type = "div"
</script> </script>
{#if type === 'div'} {#if type === 'div'}
<div use:styleable={$styles}> <div use:styleable={$component.styles}>
<slot /> <slot />
</div> </div>
{:else if type === 'header'} {:else if type === 'header'}
<header use:styleable={$styles}> <header use:styleable={$component.styles}>
<slot /> <slot />
</header> </header>
{:else if type === 'main'} {:else if type === 'main'}
<main use:styleable={$styles}> <main use:styleable={$component.styles}>
<slot /> <slot />
</main> </main>
{:else if type === 'footer'} {:else if type === 'footer'}
<footer use:styleable={$styles}> <footer use:styleable={$component.styles}>
<slot /> <slot />
</footer> </footer>
{:else if type === 'aside'} {:else if type === 'aside'}
<aside use:styleable={$styles}> <aside use:styleable={$component.styles}>
<slot /> <slot />
</aside> </aside>
{:else if type === 'summary'} {:else if type === 'summary'}
<summary use:styleable={$styles}> <summary use:styleable={$component.styles}>
<slot /> <slot />
</summary> </summary>
{:else if type === 'details'} {:else if type === 'details'}
<details use:styleable={$styles}> <details use:styleable={$component.styles}>
<slot /> <slot />
</details> </details>
{:else if type === 'article'} {:else if type === 'article'}
<article use:styleable={$styles}> <article use:styleable={$component.styles}>
<slot /> <slot />
</article> </article>
{:else if type === 'nav'} {:else if type === 'nav'}
<nav use:styleable={$styles}> <nav use:styleable={$component.styles}>
<slot /> <slot />
</nav> </nav>
{:else if type === 'mark'} {:else if type === 'mark'}
<mark use:styleable={$styles}> <mark use:styleable={$component.styles}>
<slot /> <slot />
</mark> </mark>
{:else if type === 'figure'} {:else if type === 'figure'}
<figure use:styleable={$styles}> <figure use:styleable={$component.styles}>
<slot /> <slot />
</figure> </figure>
{:else if type === 'figcaption'} {:else if type === 'figcaption'}
<figcaption use:styleable={$styles}> <figcaption use:styleable={$component.styles}>
<slot /> <slot />
</figcaption> </figcaption>
{:else if type === 'paragraph'} {:else if type === 'paragraph'}
<p use:styleable={$styles}> <p use:styleable={$component.styles}>
<slot /> <slot />
</p> </p>
{/if} {/if}

View file

@ -3,7 +3,7 @@
import { getContext } from "svelte" import { getContext } from "svelte"
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export let placeholder export let placeholder
export let value export let value
@ -14,6 +14,6 @@
} }
</script> </script>
<div use:styleable={$styles}> <div use:styleable={$component.styles}>
<DatePicker {placeholder} on:change={handleChange} {value} /> <DatePicker {placeholder} on:change={handleChange} {value} />
</div> </div>

View file

@ -2,12 +2,12 @@
import { getContext } from "svelte" import { getContext } from "svelte"
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export let embed export let embed
</script> </script>
<div use:styleable={$styles}> <div use:styleable={$component.styles}>
{@html embed} {@html embed}
</div> </div>

View file

@ -7,7 +7,7 @@
const { styleable, screenStore, API } = getContext("sdk") const { styleable, screenStore, API } = getContext("sdk")
const dataContextStore = getContext("data") const dataContextStore = getContext("data")
const styles = getContext("style") const component = getContext("component")
export let wide = false export let wide = false
@ -27,7 +27,7 @@
} }
</script> </script>
<div class="form-content" use:styleable={$styles}> <div class="form-content" use:styleable={$component.styles}>
<!-- <ErrorsBox errors={$store.saveRowErrors || {}} />--> <!-- <ErrorsBox errors={$store.saveRowErrors || {}} />-->
{#each fields as field} {#each fields as field}
<div class="form-field" class:wide> <div class="form-field" class:wide>

View file

@ -2,7 +2,7 @@
import { getContext } from "svelte" import { getContext } from "svelte"
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export let className = "" export let className = ""
export let type export let type
@ -10,15 +10,15 @@
</script> </script>
{#if type === 'h1'} {#if type === 'h1'}
<h1 class={className} use:styleable={$styles}>{text}</h1> <h1 class={className} use:styleable={$component.styles}>{text}</h1>
{:else if type === 'h2'} {:else if type === 'h2'}
<h2 class={className} use:styleable={$styles}>{text}</h2> <h2 class={className} use:styleable={$component.styles}>{text}</h2>
{:else if type === 'h3'} {:else if type === 'h3'}
<h3 class={className} use:styleable={$styles}>{text}</h3> <h3 class={className} use:styleable={$component.styles}>{text}</h3>
{:else if type === 'h4'} {:else if type === 'h4'}
<h4 class={className} use:styleable={$styles}>{text}</h4> <h4 class={className} use:styleable={$component.styles}>{text}</h4>
{:else if type === 'h5'} {:else if type === 'h5'}
<h5 class={className} use:styleable={$styles}>{text}</h5> <h5 class={className} use:styleable={$component.styles}>{text}</h5>
{:else if type === 'h6'} {:else if type === 'h6'}
<h6 class={className} use:styleable={$styles}>{text}</h6> <h6 class={className} use:styleable={$component.styles}>{text}</h6>
{/if} {/if}

View file

@ -3,7 +3,7 @@
import { getContext } from "svelte" import { getContext } from "svelte"
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export let icon = "" export let icon = ""
export let size = "fa-lg" export let size = "fa-lg"
@ -13,4 +13,4 @@
<i <i
style={`color: ${color};`} style={`color: ${color};`}
class={`${icon} ${size}`} class={`${icon} ${size}`}
use:styleable={$styles} /> use:styleable={$component.styles} />

View file

@ -2,7 +2,7 @@
import { getContext } from "svelte" import { getContext } from "svelte"
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export let className = "" export let className = ""
export let url = "" export let url = ""
@ -17,4 +17,4 @@
class={className} class={className}
src={url} src={url}
alt={description} alt={description}
use:styleable={$styles} /> use:styleable={$component.styles} />

View file

@ -1,21 +1,12 @@
<script> <script>
import { getContext } from "svelte" import { getContext } from "svelte"
const { styleable } = getContext("sdk") const { styleable, setBindableValue } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export let value = "" // Keep bindable value up to date
export let className = "" let value
export let type = "text" $: setBindableValue(value, $component.id)
const onchange = ev => {
value = ev.target.value
}
</script> </script>
<input <input bind:value on:change={onchange} use:styleable={$component.styles} />
class={className}
{type}
{value}
on:change={onchange}
use:styleable={$styles} />

View file

@ -2,7 +2,7 @@
import { getContext } from "svelte" import { getContext } from "svelte"
const { linkable, styleable } = getContext("sdk") const { linkable, styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export let url = "" export let url = ""
export let text = "" export let text = ""
@ -11,7 +11,7 @@
$: target = openInNewTab ? "_blank" : "_self" $: target = openInNewTab ? "_blank" : "_self"
</script> </script>
<a href={url} use:linkable {target} use:styleable={$styles}> <a href={url} use:linkable {target} use:styleable={$component.styles}>
{text} {text}
<slot /> <slot />
</a> </a>

View file

@ -4,7 +4,7 @@
const { API, styleable, DataProvider } = getContext("sdk") const { API, styleable, DataProvider } = getContext("sdk")
const dataContextStore = getContext("data") const dataContextStore = getContext("data")
const styles = getContext("style") const component = getContext("component")
export let datasource = [] export let datasource = []
@ -17,7 +17,7 @@
}) })
</script> </script>
<div use:styleable={$styles}> <div use:styleable={$component.styles}>
{#each rows as row} {#each rows as row}
<DataProvider {row}> <DataProvider {row}>
<slot /> <slot />

View file

@ -2,7 +2,7 @@
import { getContext } from "svelte" import { getContext } from "svelte"
const { authStore, styleable } = getContext("sdk") const { authStore, styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export let buttonText = "Log In" export let buttonText = "Log In"
export let logo = "" export let logo = ""
@ -29,7 +29,7 @@
} }
</script> </script>
<div class="root" use:styleable={$styles}> <div class="root" use:styleable={$component.styles}>
<div class="content"> <div class="content">
{#if logo} {#if logo}
<div class="logo-container"><img src={logo} alt="logo" /></div> <div class="logo-container"><img src={logo} alt="logo" /></div>

View file

@ -2,7 +2,7 @@
import { getContext } from "svelte" import { getContext } from "svelte"
const { authStore, linkable, styleable } = getContext("sdk") const { authStore, linkable, styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export let logoUrl export let logoUrl
export let title export let title
@ -12,7 +12,7 @@
} }
</script> </script>
<div class="nav" use:styleable={$styles}> <div class="nav" use:styleable={$component.styles}>
<div class="nav__top"> <div class="nav__top">
<a href="/" use:linkable> <a href="/" use:linkable>
{#if logoUrl} {#if logoUrl}

View file

@ -23,6 +23,6 @@
} }
</script> </script>
<div use:styleable={$styles}> <div use:styleable={$component.styles}>
<RichText bind:content={value} {options} /> <RichText bind:content={value} {options} />
</div> </div>

View file

@ -1,11 +1,11 @@
<script> <script>
import { getContext } from "svelte" import { getContext } from "svelte"
const styles = getContext("style") const component = getContext("component")
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")
</script> </script>
<div use:styleable={$styles}> <div use:styleable={$component.styles}>
<h1>Screen Slot</h1> <h1>Screen Slot</h1>
<span> <span>
The screens that you create will be displayed inside this box. The screens that you create will be displayed inside this box.

View file

@ -2,7 +2,7 @@
import { getContext } from "svelte" import { getContext } from "svelte"
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export let imageUrl = "" export let imageUrl = ""
export let heading = "" export let heading = ""
@ -14,7 +14,7 @@
$: showImage = !!imageUrl $: showImage = !!imageUrl
</script> </script>
<div class="container" use:styleable={$styles}> <div class="container" use:styleable={$component.styles}>
<a href={destinationUrl}> <a href={destinationUrl}>
<div class="content"> <div class="content">
{#if showImage} {#if showImage}

View file

@ -2,7 +2,7 @@
import { getContext } from "svelte" import { getContext } from "svelte"
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export let text = "" export let text = ""
export let className = "" export let className = ""
@ -12,28 +12,28 @@
</script> </script>
{#if isTag('none')} {#if isTag('none')}
<span use:styleable={$styles}>{text}</span> <span use:styleable={$component.styles}>{text}</span>
{:else if isTag('bold')} {:else if isTag('bold')}
<b class={className} use:styleable={$styles}>{text}</b> <b class={className} use:styleable={$component.styles}>{text}</b>
{:else if isTag('strong')} {:else if isTag('strong')}
<strong class={className} use:styleable={$styles}>{text}</strong> <strong class={className} use:styleable={$component.styles}>{text}</strong>
{:else if isTag('italic')} {:else if isTag('italic')}
<i class={className} use:styleable={$styles}>{text}</i> <i class={className} use:styleable={$component.styles}>{text}</i>
{:else if isTag('emphasis')} {:else if isTag('emphasis')}
<em class={className} use:styleable={$styles}>{text}</em> <em class={className} use:styleable={$component.styles}>{text}</em>
{:else if isTag('mark')} {:else if isTag('mark')}
<mark class={className} use:styleable={$styles}>{text}</mark> <mark class={className} use:styleable={$component.styles}>{text}</mark>
{:else if isTag('small')} {:else if isTag('small')}
<small class={className} use:styleable={$styles}>{text}</small> <small class={className} use:styleable={$component.styles}>{text}</small>
{:else if isTag('del')} {:else if isTag('del')}
<del class={className} use:styleable={$styles}>{text}</del> <del class={className} use:styleable={$component.styles}>{text}</del>
{:else if isTag('ins')} {:else if isTag('ins')}
<ins class={className} use:styleable={$styles}>{text}</ins> <ins class={className} use:styleable={$component.styles}>{text}</ins>
{:else if isTag('sub')} {:else if isTag('sub')}
<sub class={className} use:styleable={$styles}>{text}</sub> <sub class={className} use:styleable={$component.styles}>{text}</sub>
{:else if isTag('sup')} {:else if isTag('sup')}
<sup class={className} use:styleable={$styles}>{text}</sup> <sup class={className} use:styleable={$component.styles}>{text}</sup>
{:else}<span use:styleable={$styles}>{text}</span>{/if} {:else}<span use:styleable={$component.styles}>{text}</span>{/if}
<style> <style>
span { span {

View file

@ -3,15 +3,15 @@
import { chart } from "svelte-apexcharts" import { chart } from "svelte-apexcharts"
const { styleable } = getContext("sdk") const { styleable } = getContext("sdk")
const styles = getContext("style") const component = getContext("component")
export let options export let options
</script> </script>
{#if options} {#if options}
<div use:chart={options} use:styleable={$styles} /> <div use:chart={options} use:styleable={$component.styles} />
{:else if options === false} {:else if options === false}
<div use:styleable={$styles}>Invalid chart options</div> <div use:styleable={$component.styles}>Invalid chart options</div>
{/if} {/if}
<style> <style>

View file

@ -16,7 +16,7 @@
const setters = new Map([["number", number]]) const setters = new Map([["number", number]])
const SDK = getContext("sdk") const SDK = getContext("sdk")
const dataContext = getContext("data") const dataContext = getContext("data")
const styles = getContext("style") const component = getContext("component")
const { API, styleable } = SDK const { API, styleable } = SDK
export let datasource = {} export let datasource = {}
@ -28,9 +28,9 @@
// Add setting height as css var to allow grid to use correct height // Add setting height as css var to allow grid to use correct height
$: gridStyles = { $: gridStyles = {
...$styles, ...$component.styles,
normal: { normal: {
...$styles.normal, ...$component.styles.normal,
["--grid-height"]: `${height}px`, ["--grid-height"]: `${height}px`,
}, },
} }