input/text: add align & wrap props (feature request #176)

This commit is contained in:
jean-emmanuel 2018-03-03 10:16:52 +01:00
parent a0bf06f8e9
commit 8292aa788d
7 changed files with 49 additions and 5 deletions

View file

@ -28,6 +28,7 @@ module.exports = class Input extends Canvas {
_input:'input',
vertical:false,
align: '',
unit: '',
editable:true,
@ -59,9 +60,10 @@ module.exports = class Input extends Canvas {
this.stringValue = ''
this.focused = false
if (this.getProp('vertical')) {
this.widget.classList.add('vertical')
}
if (this.getProp('vertical')) this.widget.classList.add('vertical')
if (this.getProp('align') === 'left') this.widget.classList.add('left')
if (this.getProp('align') === 'right') this.widget.classList.add('right')
if (this.getProp('editable')) {
this.canvas.setAttribute('tabindex', 0)

View file

@ -27,6 +27,8 @@ module.exports = class Text extends Widget {
_text: 'text',
vertical:false,
wrap:false,
align:'',
_value: 'value',
default: '',
@ -50,6 +52,9 @@ module.exports = class Text extends Widget {
super({...options, html: '<div class="text"></div>'})
if (this.getProp('vertical')) this.widget.classList.add('vertical')
if (this.getProp('align') === 'left') this.widget.classList.add('left')
if (this.getProp('align') === 'right') this.widget.classList.add('right')
if (this.getProp('wrap')) this.widget.classList.add('wrap')
this.defaultValue = this.getProp('value') || ( this.getProp('label')===false ?
this.getProp('id'):

View file

@ -30,6 +30,12 @@
padding:1rem;
border: 1rem solid var(--color-bg);
background: var(--color-track);
&.right {
text-align: right;
}
&.left {
text-align: left;
}
input {
display: block;
flex:1;

View file

@ -70,9 +70,19 @@
display: flex;
align-items: center;
white-space: pre;
word-break: break-all;
background: var(--color-track);
color:var(--color-custom);
border: 1rem solid var(--color-bg);
&.right {
justify-content: flex-end;
}
&.left {
justify-content: flex-start;
}
&.wrap {
white-space: pre-wrap;
}
&.vertical {
transform: rotate(180deg);
text-overflow: ellipsis;
@ -155,11 +165,15 @@
--color-border:transparent;
padding: 0rem;
.plot, .text, .led, .image, .svg {
padding: 0rem;
margin: 1rem;
background-clip: content-box;
box-shadow: 0 0 0 1rem var(--color-fg);
outline:1rem solid var(--color-light);
border: 1rem solid var(--color-bg);
}
}
.panel:not(.tab) > .image-container {
.image {
background-clip: content-box;
}
}