text: add vertical alignment choices to align

This commit is contained in:
bordun 2021-04-24 10:25:50 +02:00
parent cbcbfab3d1
commit 39a156c898
4 changed files with 14 additions and 5 deletions

View file

@ -9,6 +9,7 @@
- widgets
- image: add pre defined values for `size`, `position` and `repeat` properties
- text: add vertical alignment choices to `align`
- editor
- tree: activate tab when selecting it in the project tree

View file

@ -17,7 +17,7 @@ module.exports = class Image extends StaticProperties(Widget, {bypass: true}) {
style: {
_separator_image_style: 'Image style',
size: {type: 'string', value: 'cover', choices: ['cover', 'contain', 'auto'], help: 'CSS background-size'},
position: {type: 'string', value: 'center', choices: ['center', 'center top', 'center bottom', 'left center', 'left top', 'left bottom', 'right center', 'right top', 'right bottom'], help: 'CSS background-position'},
position: {type: 'string', value: 'center', choices: ['center', 'left', 'right', 'top', 'bottom', 'left top', 'left bottom', 'right top', 'right bottom'], help: 'CSS background-position'},
repeat: {type: 'string', value: 'no-repeat', choices: ['no-repeat', 'repeat', 'repeat-x', 'repeat-y', 'space', 'round'], help: 'CSS background-repeat'},
},
class_specific: {

View file

@ -23,7 +23,7 @@ module.exports = class Text extends StaticProperties(Widget, {bypass: true, inte
wrap: {type: 'boolean', value: false, help: [
'Set to `true` to wrap long lines automatically.',
]},
align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Css text-align property.'},
align: {type: 'string', value: 'center', choices: ['center', 'left', 'right', 'top', 'bottom', 'left top', 'left bottom', 'right top', 'right bottom'], help: 'Text alignment.'},
},
osc: {
typeTags: null,
@ -41,8 +41,10 @@ module.exports = class Text extends StaticProperties(Widget, {bypass: true, inte
this.text = this.widget.appendChild(html`<label></label>`)
if (this.getProp('vertical')) this.text.classList.add('vertical')
if (this.getProp('align') === 'left') this.text.classList.add('left')
if (this.getProp('align') === 'right') this.text.classList.add('right')
if (this.getProp('align').includes('left')) this.text.classList.add('left')
if (this.getProp('align').includes('right')) this.text.classList.add('right')
if (this.getProp('align').includes('top')) this.text.classList.add('top')
if (this.getProp('align').includes('bottom')) this.text.classList.add('bottom')
if (this.getProp('wrap')) this.text.classList.add('wrap')

View file

@ -65,7 +65,7 @@
overflow: hidden;
text-align: center;
word-wrap: break-word;
padding: 0 var(--text-padding);
padding: var(--text-padding);
&.right {
text-align: right;
@ -75,6 +75,12 @@
text-align: left;
justify-content: flex-start;
}
&.top {
align-items: flex-start;
}
&.bottom {
align-items: flex-end;
}
&.wrap {
white-space: pre-wrap;
word-break: break-all;