From 4e8c6f9a17539661567204a4d1da4b7d56b34eb8 Mon Sep 17 00:00:00 2001 From: bordun Date: Sat, 12 Sep 2020 17:39:20 +0200 Subject: [PATCH] button: add `wrap` and `vertical` properties --- CHANGELOG.md | 4 ++++ src/client/widgets/basics/button.js | 9 +++++++++ src/client/widgets/indicators/text.js | 1 - src/scss/widgets/basics.scss | 15 +++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c10cfe34..794030d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,13 @@ - scripting - expose toolbar menu actions + - remote control - optimise small changes made with /EDIT +- widgets + - button: add `wrap` and `vertical` properties + ## 1.2.0 - bug fixes diff --git a/src/client/widgets/basics/button.js b/src/client/widgets/basics/button.js index eadf5825..bac856f5 100644 --- a/src/client/widgets/basics/button.js +++ b/src/client/widgets/basics/button.js @@ -24,6 +24,10 @@ class Button extends Widget { '- Insert icons using the prefix ^ followed by the icon\'s name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)', '- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal`', ]}, + vertical: {type: 'boolean', value: false, help: 'Set to `true` to display the text vertically'}, + wrap: {type: 'boolean', value: false, help: [ + 'Set to `true` to wrap long lines automatically.', + ]}, on: {type: '*', value: 1, help: [ 'Set to `null` to send send no argument in the osc message', ]}, @@ -128,9 +132,14 @@ class Button extends Widget { } + this.value = this.getProp('off') this.label = html`` + + if (this.getProp('wrap')) this.label.classList.add('wrap') + if (this.getProp('vertical')) this.label.classList.add('vertical') + this.updateLabel() } diff --git a/src/client/widgets/indicators/text.js b/src/client/widgets/indicators/text.js index 174a8195..f3b4dbe6 100644 --- a/src/client/widgets/indicators/text.js +++ b/src/client/widgets/indicators/text.js @@ -20,7 +20,6 @@ module.exports = class Text extends StaticProperties(Widget, {bypass: true, inte vertical: {type: 'boolean', value: false, help: 'Set to `true` to display the text vertically'}, wrap: {type: 'boolean', value: false, help: [ 'Set to `true` to wrap long lines automatically.', - 'This will not break overflowing words by default, word-breaking can be enabled by adding `word-break: break-all;` to the `css` property', ]}, align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Css text-align property.'}, diff --git a/src/scss/widgets/basics.scss b/src/scss/widgets/basics.scss index 4b6cb4f0..0e8985b9 100644 --- a/src/scss/widgets/basics.scss +++ b/src/scss/widgets/basics.scss @@ -50,6 +50,21 @@ height: 100%; width: 100%; border: 2rem solid transparent; + + &.wrap { + white-space: pre-wrap; + word-break: break-all; + } + &.vertical { + transform: rotate(180deg); + text-overflow: ellipsis; + -webkit-writing-mode:vertical-rl; + writing-mode:vertical-rl; + i { + transform: rotate(180deg); + writing-mode: initial; + } + } } &.on {