ui: widget tree tweaks

This commit is contained in:
jean-emmanuel 2021-12-15 11:28:28 +01:00
parent 21982b6bc7
commit ac74d28d0e
2 changed files with 33 additions and 17 deletions

View file

@ -59,12 +59,14 @@ class UiTree extends UiWidget {
super(options)
this.mounted = false
this.container.appendChild(html`<div class="fragment-mode-warning" title="${locales('fragment_mode_explanation')}">${raw(icon('exclamation-triangle'))} ${locales('fragment_mode_warning')}</div>`)
this.filter = this.container.appendChild(html`<input class="filter" type="text" placeholder="${locales('tree_filter')}..."/>`)
this.list = this.container.appendChild(html`<ol style="--depth: 1"></ol`)
this.fragment = this.container.appendChild(html`<div class="fragment-mode-warning" title="${locales('fragment_mode_explanation')}">${raw(icon('exclamation-triangle'))} ${locales('fragment_mode_warning')}</div>`)
this.wrapper = this.container.appendChild(html`<div class="tree"></div>`)
this.list = this.wrapper.appendChild(html`<ol style="--depth: 1"></ol`)
this.dragDummy = html`<span></span>`
this.deferredUpdateTimeout = null
this.expanded = {}
this.init = false
@ -217,6 +219,7 @@ class UiTree extends UiWidget {
parent = parent.parentNode
}
node[0].scrollIntoView({block: 'center'})
this.wrapper.scrollLeft = (node[0].depth - 1) * 20
}
if (this.parent.minimized) this.parent.restore()
@ -228,6 +231,7 @@ class UiTree extends UiWidget {
DOM.each(this.list, '.editing', (el)=>{
el.classList.add('editor-blink')
el.scrollIntoView({block: 'center'})
this.wrapper.scrollLeft = (el.depth - 1) * 20
setTimeout(()=>{
el.classList.remove('editor-blink')
}, 800)
@ -263,6 +267,9 @@ class UiTree extends UiWidget {
data-widget="${widget.hash}" data-type="${widget.getProp('type')}">
${raw(icon(widgetIcons[widget.getProp('type')] || 'root'))}${id}</li>`
node.depth = depth
if (widget instanceof Panel && !(widget instanceof Matrix || widget instanceof Keyboard)) {
node.insertBefore(html`<span class="toggle no-widget-select"></span>`, node.childNodes[0])
node.classList.add('container')

View file

@ -5,14 +5,28 @@
$padding: 16rem;
$line-height: 28rem;
padding: 0 $padding;
$field-height: 30rem;
padding-right: 0;
text-transform: none;
line-height: $line-height;
display: flex;
flex-direction: column;
overflow: hidden;
.tree {
width: 100%;
flex: 1;
position: relative;
overflow: auto;
padding-left:$padding;
padding-right:$padding;
}
ol {
list-style: none;
position: relative;
padding-left: 16rem;
@ -123,7 +137,7 @@
@include pseudo-fill($z: -1);
&:after {
left: calc(-1 * var(--depth) * 16rem - #{$padding});
right: 1rem;
right: 1rem - $padding;
bottom: auto;
height: $line-height;
top: 0;
@ -143,7 +157,7 @@
@include pseudo-fill($z: -1);
&:after {
left: calc(-1 * var(--depth) * 16rem - #{$padding});
right: 1rem;
right: 1rem - $padding;
bottom: auto;
height: $line-height;
opacity: 0.1;
@ -152,17 +166,14 @@
.filter {
margin-left: #{-$padding * 2};
width: calc(100% + #{$padding * 2});
display: block;
background: linear-gradient(to right, var(--color-background), var(--color-ui-background));
font-family: $font;
line-height: $field-height - 4rem;
padding: 4rem $padding;
padding-left: #{$padding * 2};
position: sticky;
line-height: $field-height;
padding: 0 $padding;
top: 0;
z-index: 2;
background: var(--color-ui-background-active);
border-bottom: 1rem solid var(--color-background);
}
.filter-active .filter-hide {
@ -170,12 +181,10 @@
}
.fragment-mode-warning {
margin-left: #{-$padding * 2};
width: calc(100% + #{$padding * 2});
color: var(--color-warning);
padding: 8rem $padding;
padding-left: #{$padding * 2};
line-height: $field-height - 4rem;
padding: 0 $padding;
line-height: $field-height;
border-bottom: 1rem solid var(--color-background);
display: none;
}