Skip to content

Commit

Permalink
feat(frontend): Align output panel UI (#1025)
Browse files Browse the repository at this point in the history
* feat(frontend): Align output pane UI

* feat(frontend): Align UI
  • Loading branch information
fatonramadani committed Dec 16, 2022
1 parent 80c84d1 commit 0e871ca
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion frontend/src/lib/components/apps/editor/GridEditor.svelte
Expand Up @@ -74,7 +74,7 @@
</Grid>
{#if $connectingInput.opened}
<div
class="fixed top-32 left-0 w-full z-10 flex justify-center items-center"
class="fixed top-32 z-10 flex justify-center items-center"
transition:fly={{ duration: 100, y: -100 }}
>
<Alert title="Connecting" type="info">
Expand Down
Expand Up @@ -13,7 +13,7 @@
function subscribeToAllOutputs(observableOutputs: Record<string, Output<any>>) {
if (observableOutputs) {
outputs.forEach((output) => {
outputs.forEach((output: string) => {
observableOutputs[output].subscribe({
next: (value) => {
object[output] = value
Expand All @@ -27,4 +27,8 @@
subscribeToAllOutputs($worldStore.outputsById[componentId])
</script>

<ObjectViewer json={object} on:select topBrackets={true} />
{#if Object.keys(object).length > 0}
<ObjectViewer json={object} on:select topBrackets={false} />
{:else}
<div class="text-xs text-gray-500 px-4">No outputs</div>
{/if}
@@ -1,12 +1,12 @@
<script lang="ts">
import Button from '$lib/components/common/button/Button.svelte'
import { classNames } from '$lib/utils'
import { getContext } from 'svelte'
import type { AppEditorContext } from '../../types'
import { displayData } from '../../utils'
import PanelSection from '../settingsPanel/common/PanelSection.svelte'
import ComponentOutputViewer from './ComponentOutputViewer.svelte'
const { connectingInput, staticOutputs, worldStore, selectedComponent } =
const { connectingInput, staticOutputs, worldStore, selectedComponent, app } =
getContext<AppEditorContext>('AppEditorContext')
function connectInput(componentId: string, path: string) {
Expand All @@ -23,21 +23,38 @@
}
}
}
function getComponentNameById(componentId: string) {
const component = $app.grid.find((c) => c.data.id === componentId)
if (component?.data.type) {
return displayData[component?.data.type].name
}
}
</script>

<PanelSection title="Outputs">
{#each Object.entries($staticOutputs) as [componentId, outputs], index}
{#if outputs.length > 0 && $worldStore?.outputsById[componentId]}
<Button size="xs" on:click={() => ($selectedComponent = componentId)} color="blue">
Component: {componentId}
</Button>
<button
on:click={() => ($selectedComponent = componentId)}
class={classNames(
'px-1 text-2xs py-0.5 font-bold rounded-t-sm w-fit -mb-2',
$selectedComponent === componentId
? ' bg-indigo-500 text-white'
: 'bg-gray-200 text-gray-500'
)}
>
{getComponentNameById(componentId)} -
{componentId}
</button>

<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
on:click={() => ($selectedComponent = componentId)}
class={classNames(
'w-full p-2 rounded-xs border',
$selectedComponent === componentId
? 'outline-1 outline outline-offset-2 outline-blue-500'
: ''
'w-full py-2 border',
$selectedComponent === componentId ? 'border border-blue-500' : 'cursor-pointer'
)}
>
<ComponentOutputViewer
Expand Down

0 comments on commit 0e871ca

Please sign in to comment.