editor: allow folding props categories (#378)
This commit is contained in:
parent
f706917684
commit
38e4163a00
4 changed files with 61 additions and 7 deletions
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
- editor
|
||||
- removed widget deletion confirmation popup
|
||||
- properties categories can now be folded
|
||||
|
||||
## 0.37.4
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,11 @@ module.exports = function editField(editor, widget, propName, defaultValue){
|
|||
|
||||
if (propName == 'type') {
|
||||
|
||||
if (widget.props.type == 'tab' || widget.props.type == 'root') return
|
||||
if (widget.props.type == 'tab' || widget.props.type == 'root') {
|
||||
field.classList.add('disabled')
|
||||
field.appendChild(DOM.create(`<textarea class="input no-keybinding" title="${propName}" rows="1" disabled>${widget.props[propName]}</textarea>`))
|
||||
return field
|
||||
}
|
||||
|
||||
input = DOM.create(`<select class="input no-keybinding" title="${propName}"/>`)
|
||||
var innerHTML = ''
|
||||
|
|
|
|||
|
|
@ -21,7 +21,22 @@ var Editor = class Editor {
|
|||
</div>
|
||||
</div>
|
||||
`)
|
||||
|
||||
this.form = DOM.get(this.wrapper, '#editor-form')[0]
|
||||
this.form.addEventListener('fast-click', (e)=>{
|
||||
if (e.target.classList.contains('separator')) {
|
||||
var name = e.target.getAttribute('data-name'),
|
||||
foldedIndex = this.foldedCategories.indexOf(name)
|
||||
e.target.parentNode.classList.toggle('folded', foldedIndex < 0)
|
||||
if (foldedIndex > -1) {
|
||||
this.foldedCategories.splice(foldedIndex, 1)
|
||||
} else {
|
||||
this.foldedCategories.push(name)
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
this.defaults = {}
|
||||
for (var k in widgets) {
|
||||
|
|
@ -44,7 +59,7 @@ var Editor = class Editor {
|
|||
this.historyState = -1
|
||||
this.historySession = null
|
||||
|
||||
this.deleting = false
|
||||
this.foldedCategories = []
|
||||
|
||||
this.mousePosition = {x:0, y:0}
|
||||
this.mouveMoveHandler = this.mouseMove.bind(this)
|
||||
|
|
@ -254,12 +269,14 @@ var Editor = class Editor {
|
|||
this.form.appendChild(DOM.create(`
|
||||
<div class="separator">
|
||||
${this.selectedWidgets.length > 1 ?
|
||||
'<span class="accent">Multiple Widgets</span>' :
|
||||
'<span>Widget</span>'
|
||||
}
|
||||
'<span class="accent">Multiple Widgets</span>' :
|
||||
'<span>Widget</span>'
|
||||
}
|
||||
</div>
|
||||
`))
|
||||
|
||||
let category
|
||||
|
||||
for (let propName in props) {
|
||||
|
||||
let field,
|
||||
|
|
@ -275,7 +292,10 @@ var Editor = class Editor {
|
|||
|
||||
if (propName.indexOf('_') === 0 && propName !== '_props') {
|
||||
|
||||
field = DOM.create(`<div class="separator"><span>${props[propName]}</span></div>`)
|
||||
if (category) this.form.appendChild(category)
|
||||
category = DOM.create(`<div class="category ${this.foldedCategories.indexOf(props[propName]) > -1 ? "folded" : ""}"></div>`)
|
||||
|
||||
field = DOM.create(`<div class="separator" data-name="${props[propName]}"><span>${props[propName]}</span></div>`)
|
||||
|
||||
} else if (widget.props[propName] === undefined) {
|
||||
|
||||
|
|
@ -288,10 +308,16 @@ var Editor = class Editor {
|
|||
|
||||
}
|
||||
|
||||
this.form.appendChild(field)
|
||||
if (category) {
|
||||
category.appendChild(field)
|
||||
} else {
|
||||
this.form.appendChild(field)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (category) this.form.appendChild(category)
|
||||
|
||||
this.wrapper.appendChild(this.form)
|
||||
DOM.get('#editor')[0].appendChild(this.wrapper)
|
||||
|
||||
|
|
|
|||
|
|
@ -228,6 +228,7 @@
|
|||
display: block;
|
||||
width:100%;
|
||||
text-align:center;
|
||||
pointer-events: none;
|
||||
&.accent {
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
|
@ -236,6 +237,28 @@
|
|||
.separator + .input-wrapper .input {
|
||||
border-top-color:transparent;
|
||||
}
|
||||
.category {
|
||||
.separator {
|
||||
cursor: pointer;
|
||||
}
|
||||
.separator:before {
|
||||
font-family: FontAwesome;
|
||||
content: "\f0d7";
|
||||
line-height: 30rem;
|
||||
width:30rem;
|
||||
text-align: center;
|
||||
position: absolute;
|
||||
opacity: 0.6;
|
||||
}
|
||||
&.folded {
|
||||
.separator:before {
|
||||
content: "\f0da";
|
||||
}
|
||||
.input-wrapper {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue