fixes to transitions and adds default fade to screens

This commit is contained in:
Keviin Åberg Kultalahti 2021-03-02 13:37:54 +01:00
parent c37aefc0cf
commit 4575285d5f
4 changed files with 11 additions and 14 deletions

View File

@ -1,11 +1,8 @@
<script> <script>
import { goto } from "@sveltech/routify"
import { store, backendUiStore, allScreens } from "builderStore" import { store, backendUiStore, allScreens } from "builderStore"
import { Input, Select, ModalContent, Toggle } from "@budibase/bbui" import { Input, Select, ModalContent, Toggle } from "@budibase/bbui"
import getTemplates from "builderStore/store/screenTemplates" import getTemplates from "builderStore/store/screenTemplates"
import analytics from "analytics" import analytics from "analytics"
import { onMount } from "svelte"
import api from "builderStore/api"
const CONTAINER = "@budibase/standard-components/container" const CONTAINER = "@budibase/standard-components/container"
@ -19,9 +16,6 @@
$: templates = getTemplates($store, $backendUiStore.tables) $: templates = getTemplates($store, $backendUiStore.tables)
$: route = !route && $allScreens.length === 0 ? "*" : route $: route = !route && $allScreens.length === 0 ? "*" : route
$: baseComponents = Object.values($store.components)
.filter(componentDefinition => componentDefinition.baseComponent)
.map(c => c._component)
$: { $: {
if (templates && templateIndex === undefined) { if (templates && templateIndex === undefined) {
templateIndex = 0 templateIndex = 0
@ -31,7 +25,6 @@
const templateChanged = newTemplateIndex => { const templateChanged = newTemplateIndex => {
if (newTemplateIndex === undefined) return if (newTemplateIndex === undefined) return
const template = templates[newTemplateIndex]
draftScreen = templates[newTemplateIndex].create() draftScreen = templates[newTemplateIndex].create()
if (draftScreen.props._instanceName) { if (draftScreen.props._instanceName) {
name = draftScreen.props._instanceName name = draftScreen.props._instanceName
@ -60,6 +53,7 @@
if (routeError) return false if (routeError) return false
draftScreen.props._instanceName = name draftScreen.props._instanceName = name
draftScreen.props._transition = "fade"
draftScreen.props._component = baseComponent draftScreen.props._component = baseComponent
draftScreen.routing = { route, roleId } draftScreen.routing = { route, roleId }

View File

@ -25,9 +25,11 @@
] ]
const transitions = [ const transitions = [
'fade', 'blur', 'fly', 'scale' // slide is hidden because it does not seem to result in any effect 'none', 'fade', 'blur', 'fly', 'scale' // slide is hidden because it does not seem to result in any effect
] ]
const capitalize = ([first,...rest]) => first.toUpperCase() + rest.join('');
$: groups = componentDefinition?.styleable ? Object.keys(allStyles) : [] $: groups = componentDefinition?.styleable ? Object.keys(allStyles) : []
</script> </script>
@ -71,10 +73,9 @@
</div> </div>
{#if componentDefinition?.transitionable} {#if componentDefinition?.transitionable}
<div class="transitions"> <div class="transitions">
<Select value={componentInstance._transition || ""} on:change={event => onUpdateTransition(event.target.value)} name="transition" label="Transition" secondary thin> <Select value={componentInstance._transition} on:change={event => onUpdateTransition(event.target.value)} name="transition" label="Transition" secondary thin>
<option value="">Choose a transition</option>
{#each transitions as transition} {#each transitions as transition}
<option value={transition}>{transition}</option> <option value={transition}>{capitalize(transition)}</option>
{/each} {/each}
</Select> </Select>
</div> </div>

View File

@ -11,6 +11,6 @@ const transitions = new Map([
]) ])
export default function transition(node, { type, options = {} }) { export default function transition(node, { type, options = {} }) {
const { tn, opt } = transitions.get(type) || {} const { tn, opt } = transitions.get(type) || { tn: () => {}, opt: {}}
return tn ? tn(node, { ...opt, ...options }) : fade(node, { duration: 0 }) return tn(node, { ...opt, ...options })
} }

View File

@ -21,6 +21,7 @@ exports.createHomeScreen = () => ({
active: {}, active: {},
selected: {}, selected: {},
}, },
_transition: "fade",
type: "div", type: "div",
_children: [ _children: [
{ {
@ -69,6 +70,7 @@ exports.createLoginScreen = app => ({
active: {}, active: {},
selected: {}, selected: {},
}, },
_transition: "fade",
type: "div", type: "div",
_children: [ _children: [
{ {