inspector: commit color picker changes on dragend and remove action buttons (#771)
This commit is contained in:
parent
e4846688c8
commit
795142adfe
4 changed files with 10 additions and 52 deletions
|
|
@ -3,7 +3,7 @@
|
|||
## 1.14.4
|
||||
|
||||
- inspector
|
||||
- the color picker is no longer in a modal and now shows changes on the fly (the new color is not saved unless "confirm" is clicked)
|
||||
- color picker: inline picker widget (no longer in a modal); show color changes on the fly
|
||||
|
||||
## 1.14.3
|
||||
|
||||
|
|
|
|||
|
|
@ -30,27 +30,25 @@ class ColorPicker extends UiWidget {
|
|||
this.container = html`
|
||||
<div class="color-picker">
|
||||
${this.rgb.container}
|
||||
<div class="actions">
|
||||
<div class="btn color-confirm">${locales('inspector_color_confirm')}</div>
|
||||
<div class="btn color-cancel">${locales('inspector_color_cancel')}</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
|
||||
DOM.get(this.container, '.color-confirm')[0].addEventListener('click', this.confirm.bind(this))
|
||||
DOM.get(this.container, '.color-cancel')[0].addEventListener('click', this.cancel.bind(this))
|
||||
|
||||
this.rgb.on('change', (e)=>{
|
||||
e.stopPropagation = true
|
||||
this.value = chroma(this.rgb.value).hex()
|
||||
this.trigger('change', {preventHistory: true})
|
||||
})
|
||||
|
||||
this.rgb.on('dragend', (e)=>{
|
||||
this.value = chroma(this.rgb.value).hex()
|
||||
this.trigger('change')
|
||||
})
|
||||
|
||||
|
||||
this.opened = 0
|
||||
|
||||
this.cancelValue = '#00000000'
|
||||
|
||||
this.escKeyHandler = ((e)=>{
|
||||
if (e.keyCode==27) this.cancel()
|
||||
if (e.keyCode==27) this.close()
|
||||
}).bind(this)
|
||||
|
||||
this.enterKeyHandler = ((e)=>{
|
||||
|
|
@ -89,16 +87,6 @@ class ColorPicker extends UiWidget {
|
|||
|
||||
}
|
||||
|
||||
cancel() {
|
||||
|
||||
if (this.value !== this.cancelValue) {
|
||||
this.value = this.cancelValue
|
||||
this.trigger('change', {preventHistory: true})
|
||||
}
|
||||
this.close()
|
||||
|
||||
}
|
||||
|
||||
isVisible() {
|
||||
|
||||
return true
|
||||
|
|
@ -119,12 +107,6 @@ class ColorPicker extends UiWidget {
|
|||
|
||||
}
|
||||
|
||||
setCancelValue(v) {
|
||||
|
||||
this.cancelValue = v
|
||||
|
||||
}
|
||||
|
||||
setParent(node) {
|
||||
|
||||
if (this.opened && node !== this.parentNode) this.close()
|
||||
|
|
|
|||
|
|
@ -68,13 +68,11 @@ class UiInspector extends UiWidget {
|
|||
textarea = DOM.get(this.container, `textarea[name="${name}"]`)
|
||||
|
||||
if (this.colorPicker.name === name) {
|
||||
this.colorPicker.cancel()
|
||||
this.colorPicker.close()
|
||||
} else {
|
||||
if (this.colorPicker.opened) this.colorPicker.cancel()
|
||||
this.colorPicker.setParent(node.parentNode)
|
||||
this.colorPicker.setName(name)
|
||||
this.colorPicker.setValue(node.getAttribute('value'))
|
||||
this.colorPicker.setCancelValue(textarea[0].value)
|
||||
this.colorPicker.open()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -638,28 +638,6 @@ osc-inspector-color {
|
|||
}
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-end;
|
||||
justify-content: stretch;
|
||||
// height: 24rem + $padding * 2;
|
||||
line-height: $field-height;
|
||||
flex-shrink: 0;
|
||||
background: var(--color-ui-foreground);
|
||||
// padding: $padding;
|
||||
.btn {
|
||||
flex: 1;
|
||||
text-overflow: clip;
|
||||
min-width: 0;
|
||||
background: var(--color-ui-button);
|
||||
margin-right: 1rem;
|
||||
&:last-child {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.inspector-help {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue