ui-keyboard: horsin around
This commit is contained in:
parent
327d461aab
commit
0a147189d4
2 changed files with 98 additions and 20 deletions
|
|
@ -9,7 +9,8 @@ const numericLayout = [
|
|||
'{sep} + 7 8 9',
|
||||
'{sep} - 4 5 6',
|
||||
'{sep} * 1 2 3',
|
||||
'{sep} / 0 . {enter}'
|
||||
'{sep} / {up} 0 .',
|
||||
'{sep} {left} {down} {right} {enter}'
|
||||
]
|
||||
const keysDisplay = {
|
||||
'{esc}': locales('keyboard_escape'),
|
||||
|
|
@ -19,6 +20,11 @@ const keysDisplay = {
|
|||
'{shift}': icon('arrow-up'),
|
||||
'{tab}': icon('arrow-right-arrow-left'),
|
||||
'{space}': ' ',
|
||||
'{left}': icon('arrow-left'),
|
||||
'{right}': icon('arrow-right'),
|
||||
'{up}': icon('arrow-up'),
|
||||
'{down}': icon('arrow-down'),
|
||||
|
||||
}
|
||||
|
||||
class OscKeybard extends UiWidget {
|
||||
|
|
@ -33,6 +39,10 @@ class OscKeybard extends UiWidget {
|
|||
this.shift = false
|
||||
this.input = null
|
||||
this.value = null
|
||||
this.visible = false
|
||||
|
||||
this.display = html`<textarea></textarea>`
|
||||
this.container.appendChild(html`<div class="row">${this.display}</div>`)
|
||||
|
||||
|
||||
for (var k in layout) {
|
||||
|
|
@ -128,6 +138,7 @@ class OscKeybard extends UiWidget {
|
|||
this.input = e.target
|
||||
this.value = this.input.value
|
||||
this.input.scrollIntoView()
|
||||
this.updateDisplay()
|
||||
}
|
||||
}, {capture: true})
|
||||
|
||||
|
|
@ -138,10 +149,27 @@ class OscKeybard extends UiWidget {
|
|||
this.hide()
|
||||
this.input = null
|
||||
this.value = null
|
||||
this.updateDisplay()
|
||||
|
||||
}
|
||||
}, {capture: true})
|
||||
|
||||
document.addEventListener('input', (e)=>{
|
||||
// hide keyboard when leaving input focus
|
||||
if (e.target === this.input) {
|
||||
setTimeout(()=>{ // deffered for code editor
|
||||
this.updateDisplay()
|
||||
})
|
||||
}
|
||||
}, {capture: true})
|
||||
|
||||
document.addEventListener('change', (e)=>{
|
||||
// hide keyboard when leaving input focus
|
||||
if (e.target === this.input) {
|
||||
this.updateDisplay()
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
keyDown(key) {
|
||||
|
|
@ -223,14 +251,23 @@ class OscKeybard extends UiWidget {
|
|||
|
||||
}
|
||||
|
||||
updateDisplay() {
|
||||
if (this.input) {
|
||||
this.display.value = this.input.osc_input ? this.input.osc_input.value :this.input.value
|
||||
|
||||
} else {
|
||||
this.display.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
show(){
|
||||
this.visible = true
|
||||
this.container.style.display = 'flex'
|
||||
DOM.dispatchEvent(window, 'resize')
|
||||
}
|
||||
|
||||
hide(){
|
||||
this.visible = false
|
||||
this.container.style.display = 'none'
|
||||
DOM.dispatchEvent(window, 'resize')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,28 +1,71 @@
|
|||
osc-keyboard {
|
||||
--spacing: 1rem;
|
||||
height:33%;
|
||||
--spacing: 2rem;
|
||||
--max-height: 300rem;
|
||||
--max-width: 1200rem;
|
||||
|
||||
height:calc(33% + 40rem);
|
||||
z-index: 100;
|
||||
position: relative;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left:0;
|
||||
right: 0;
|
||||
backdrop-filter: blur(12px);
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
padding: calc(var(--spacing) / 2);
|
||||
padding: var(--spacing);
|
||||
align-items: center;
|
||||
background: rgba(black, 0.25);
|
||||
max-height: var(--max-height);
|
||||
border-top: 1rem solid var(--color-background);
|
||||
|
||||
background: var(--color-ui-background);
|
||||
// border-top: 1rem solid var(--color-ui-background);
|
||||
@keyframes keyboard-in {
|
||||
from {opacity: 0}
|
||||
to {opacity: 1}
|
||||
}
|
||||
animation: keyboard-in 0.25s forwards;
|
||||
|
||||
textarea {
|
||||
height: auto;
|
||||
width: 100%;
|
||||
background: transparent;
|
||||
padding: 14rem 20rem 4rem;
|
||||
resize: none;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
font: inherit;
|
||||
margin-top:var(---spacing);
|
||||
}
|
||||
|
||||
.row {
|
||||
flex-direction: row;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
max-width: var(--max-width);
|
||||
width: 100%;
|
||||
&:last-child .key {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
&:first-child {
|
||||
height: 40rem;
|
||||
}
|
||||
}
|
||||
.key {
|
||||
background: var(--color-ui-button);
|
||||
background: rgba(white, 0.05);
|
||||
border-color: var(--color-ui-background);
|
||||
flex: 1;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: calc(var(--spacing) / 2);
|
||||
position: relative;
|
||||
--alpha-fill: 0.1;
|
||||
--color-fill: var(--color-accent);
|
||||
--widget-padding: -1rem;
|
||||
@include pseudo-fill($z: 1);
|
||||
margin-right: var(--spacing);
|
||||
margin-bottom: var(--spacing);
|
||||
&:last-child{
|
||||
margin-right: 0;
|
||||
}
|
||||
span {
|
||||
pointer-events: none;
|
||||
align-items: center;
|
||||
|
|
@ -36,16 +79,12 @@ osc-keyboard {
|
|||
}
|
||||
|
||||
&.active {
|
||||
background: var(--color-ui-background);
|
||||
--alpha-fill: 0.3;
|
||||
}
|
||||
}
|
||||
|
||||
.enter {
|
||||
position: relative;
|
||||
--alpha-fill: 0.1;
|
||||
--color-fill: var(--color-accent);
|
||||
@include pseudo-fill($z: 1);
|
||||
|
||||
--alpha-fill: 0.15;
|
||||
}
|
||||
|
||||
.tab, .shift {
|
||||
|
|
@ -63,7 +102,8 @@ osc-keyboard {
|
|||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
min-width: 5%;
|
||||
opacity: 0.9;
|
||||
--alpha-fill: 0.15;
|
||||
|
||||
}
|
||||
|
||||
&.shift {
|
||||
|
|
@ -76,9 +116,10 @@ osc-keyboard {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
font-size: 80%
|
||||
.key {
|
||||
font-size: 80%
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue