1
0
Fork 0
mirror of synced 2024-10-05 20:44:47 +13:00

Refactor theme binding into device databindings fn

This commit is contained in:
Dean 2023-08-30 09:27:23 +01:00
parent f7d0f98a45
commit eb6269a0bb
3 changed files with 32 additions and 46 deletions

View file

@ -497,22 +497,33 @@ const getDeviceBindings = () => {
let bindings = []
if (get(store).clientFeatures?.deviceAwareness) {
const safeDevice = makePropSafe("device")
bindings.push({
type: "context",
runtimeBinding: `${safeDevice}.${makePropSafe("mobile")}`,
readableBinding: `Device.Mobile`,
category: "Device",
icon: "DevicePhone",
display: { type: "boolean", name: "mobile" },
})
bindings.push({
type: "context",
runtimeBinding: `${safeDevice}.${makePropSafe("tablet")}`,
readableBinding: `Device.Tablet`,
category: "Device",
icon: "DevicePhone",
display: { type: "boolean", name: "tablet" },
})
bindings = [
{
type: "context",
runtimeBinding: `${safeDevice}.${makePropSafe("mobile")}`,
readableBinding: `Device.Mobile`,
category: "Device",
icon: "DevicePhone",
display: { type: "boolean", name: "mobile" },
},
{
type: "context",
runtimeBinding: `${safeDevice}.${makePropSafe("tablet")}`,
readableBinding: `Device.Tablet`,
category: "Device",
icon: "DevicePhone",
display: { type: "boolean", name: "tablet" },
},
{
type: "context",
runtimeBinding: `${safeDevice}.${makePropSafe("theme")}`,
readableBinding: `App.Theme`,
category: "Device",
icon: "DevicePhone",
display: { type: "string", name: "App Theme" },
},
]
}
return bindings
}

View file

@ -1,11 +1,6 @@
<script>
import Panel from "components/design/Panel.svelte"
import {
store,
selectedComponent,
selectedScreen,
themeStore,
} from "builderStore"
import { store, selectedComponent, selectedScreen } from "builderStore"
import ComponentSettingsSection from "./ComponentSettingsSection.svelte"
import DesignSection from "./DesignSection.svelte"
import CustomStylesSection from "./CustomStylesSection.svelte"
@ -27,20 +22,6 @@
$store.selectedComponentId
)
// frontend Constant Themes
$: globalBindings = [
...bindings,
{
type: "context",
runtimeBinding: `[device].[theme]`, //app.settings?
readableBinding: `App.Theme`,
category: "Settings",
icon: "Settings",
display: { type: "string", name: "Theme" },
},
]
$: console.log(globalBindings)
$: componentBindings = getComponentBindableProperties(
$selectedScreen,
$store.selectedComponentId
@ -78,28 +59,24 @@
<ComponentSettingsSection
{componentInstance}
{componentDefinition}
bindings={globalBindings}
{bindings}
{componentBindings}
{isScreen}
/>
{/if}
{#if section == "styles"}
<DesignSection
{componentInstance}
{componentDefinition}
bindings={globalBindings}
/>
<DesignSection {componentInstance} {componentDefinition} {bindings} />
<CustomStylesSection
{componentInstance}
{componentDefinition}
bindings={globalBindings}
{bindings}
/>
{/if}
{#if section == "conditions"}
<ConditionalUISection
{componentInstance}
{componentDefinition}
bindings={globalBindings}
{bindings}
/>
{/if}
</Panel>

View file

@ -15,7 +15,6 @@
})
$: theme = $themeStore.theme
$: baseTheme = $themeStore.baseTheme
$: data = {
mobile: width && width < tabletBreakpoint,
@ -23,7 +22,6 @@
width,
height,
theme,
baseTheme,
}
onMount(() => {