Highlighted child components of selected component
This commit is contained in:
parent
0133aabc46
commit
a2d8f143e9
|
@ -15,6 +15,7 @@
|
||||||
export let iconColor
|
export let iconColor
|
||||||
export let scrollable = false
|
export let scrollable = false
|
||||||
export let color
|
export let color
|
||||||
|
export let highlighted = false
|
||||||
|
|
||||||
const scrollApi = getContext("scroll")
|
const scrollApi = getContext("scroll")
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
@ -46,6 +47,8 @@
|
||||||
class:border
|
class:border
|
||||||
class:selected
|
class:selected
|
||||||
class:withActions
|
class:withActions
|
||||||
|
class:scrollable
|
||||||
|
class:highlighted
|
||||||
style={`padding-left: calc(${indentLevel * 14}px)`}
|
style={`padding-left: calc(${indentLevel * 14}px)`}
|
||||||
{draggable}
|
{draggable}
|
||||||
on:dragend
|
on:dragend
|
||||||
|
@ -55,7 +58,6 @@
|
||||||
on:click={onClick}
|
on:click={onClick}
|
||||||
ondragover="return false"
|
ondragover="return false"
|
||||||
ondragenter="return false"
|
ondragenter="return false"
|
||||||
class:scrollable
|
|
||||||
>
|
>
|
||||||
<div class="nav-item-content" bind:this={contentRef}>
|
<div class="nav-item-content" bind:this={contentRef}>
|
||||||
{#if withArrow}
|
{#if withArrow}
|
||||||
|
@ -112,12 +114,15 @@
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
}
|
}
|
||||||
|
.nav-item.highlighted {
|
||||||
|
background-color: var(--spectrum-global-color-gray-200);
|
||||||
|
}
|
||||||
.nav-item.selected {
|
.nav-item.selected {
|
||||||
background-color: var(--grey-2);
|
background-color: var(--spectrum-global-color-gray-300);
|
||||||
color: var(--ink);
|
color: var(--ink);
|
||||||
}
|
}
|
||||||
.nav-item:hover {
|
.nav-item:hover {
|
||||||
background-color: var(--grey-3);
|
background-color: var(--spectrum-global-color-gray-300);
|
||||||
}
|
}
|
||||||
.nav-item:hover .actions {
|
.nav-item:hover .actions {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
|
|
|
@ -5,7 +5,13 @@
|
||||||
import NavItem from "components/common/NavItem.svelte"
|
import NavItem from "components/common/NavItem.svelte"
|
||||||
import { capitalise } from "helpers"
|
import { capitalise } from "helpers"
|
||||||
import { notifications } from "@budibase/bbui"
|
import { notifications } from "@budibase/bbui"
|
||||||
import { selectedComponentPath } from "builderStore"
|
import {
|
||||||
|
selectedComponentPath,
|
||||||
|
selectedComponent,
|
||||||
|
selectedScreen,
|
||||||
|
} from "builderStore"
|
||||||
|
import { findComponentPath } from "builderStore/componentUtils"
|
||||||
|
import { get } from "svelte/store"
|
||||||
|
|
||||||
export let components = []
|
export let components = []
|
||||||
export let currentComponent
|
export let currentComponent
|
||||||
|
@ -87,6 +93,15 @@
|
||||||
}
|
}
|
||||||
return !closedNodes[component._id]
|
return !closedNodes[component._id]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isChildOfSelectedComponent = component => {
|
||||||
|
const selectedComponentId = get(selectedComponent)?._id
|
||||||
|
const selectedScreenId = get(selectedScreen)?.props._id
|
||||||
|
if (!selectedComponentId || selectedComponentId === selectedScreenId) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return findComponentPath($selectedComponent, component._id)?.length > 0
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -120,6 +135,7 @@
|
||||||
indentLevel={level + 1}
|
indentLevel={level + 1}
|
||||||
selected={$store.selectedComponentId === component._id}
|
selected={$store.selectedComponentId === component._id}
|
||||||
opened={isOpen(component, $selectedComponentPath, closedNodes)}
|
opened={isOpen(component, $selectedComponentPath, closedNodes)}
|
||||||
|
highlighted={isChildOfSelectedComponent(component)}
|
||||||
>
|
>
|
||||||
<ComponentDropdownMenu {component} />
|
<ComponentDropdownMenu {component} />
|
||||||
</NavItem>
|
</NavItem>
|
||||||
|
|
Loading…
Reference in New Issue