From 39a156c898384cafda892701dd22a49e8a95d88f Mon Sep 17 00:00:00 2001 From: bordun Date: Sat, 24 Apr 2021 10:25:50 +0200 Subject: [PATCH] text: add vertical alignment choices to `align` --- CHANGELOG.md | 1 + src/client/widgets/frames/image.js | 2 +- src/client/widgets/indicators/text.js | 8 +++++--- src/scss/widgets/indicators.scss | 8 +++++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c01dfc81..8f8e1039 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/client/widgets/frames/image.js b/src/client/widgets/frames/image.js index f4c31db3..284fe31a 100644 --- a/src/client/widgets/frames/image.js +++ b/src/client/widgets/frames/image.js @@ -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: { diff --git a/src/client/widgets/indicators/text.js b/src/client/widgets/indicators/text.js index 23c951c7..e10ad6da 100644 --- a/src/client/widgets/indicators/text.js +++ b/src/client/widgets/indicators/text.js @@ -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``) 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') diff --git a/src/scss/widgets/indicators.scss b/src/scss/widgets/indicators.scss index 4a931382..f88613ef 100644 --- a/src/scss/widgets/indicators.scss +++ b/src/scss/widgets/indicators.scss @@ -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;