diff --git a/src/client/widgets/basics/button.js b/src/client/widgets/basics/button.js index 31791031..24963709 100644 --- a/src/client/widgets/basics/button.js +++ b/src/client/widgets/basics/button.js @@ -24,8 +24,8 @@ class Button extends Widget { '- 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.', + wrap: {type: 'boolean|string', value: false, choices: [false, true, 'soft'], help: [ + 'Set to `true` to wrap long lines automatically. Set to `soft` to avoid breaking words.', ]}, }, class_specific: { @@ -139,6 +139,7 @@ class Button extends Widget { this.label = html`` if (this.getProp('wrap')) this.label.classList.add('wrap') + if (this.getProp('wrap') === 'soft') this.label.classList.add('wrap-soft') if (this.getProp('vertical')) this.label.classList.add('vertical') this.updateLabel() diff --git a/src/client/widgets/basics/switch.js b/src/client/widgets/basics/switch.js index c0282c6d..e082c138 100644 --- a/src/client/widgets/basics/switch.js +++ b/src/client/widgets/basics/switch.js @@ -19,6 +19,9 @@ class Switch extends MenuBase { colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s text color when active.'}, layout: {type: 'string', value: 'vertical', choices: ['vertical', 'horizontal', 'grid'], help:'Defines how items should be laid out'}, gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns or a valid value for the css property "grid-template".'}, + wrap: {type: 'boolean|string', value: false, choices: [false, true, 'soft'], help: [ + 'Set to `true` to wrap long lines automatically. Set to `soft` to avoid breaking words.', + ]}, }, class_specific: { values: {type: 'array|object', value: {'Value 1':1,'Value 2':2}, help: [ @@ -42,6 +45,8 @@ class Switch extends MenuBase { super({...options, html: html``}) this.container.classList.add('layout-' + this.getProp('layout')) + if (this.getProp('wrap')) this.container.classList.add('wrap') + if (this.getProp('wrap') === 'soft') this.container.classList.add('wrap-soft') if (this.getProp('layout') === 'grid') { var template = this.getProp('gridTemplate') || 2 diff --git a/src/scss/widgets/basics.scss b/src/scss/widgets/basics.scss index 05c797df..1ef2d586 100644 --- a/src/scss/widgets/basics.scss +++ b/src/scss/widgets/basics.scss @@ -56,6 +56,9 @@ white-space: pre-wrap; word-break: break-all; } + &.wrap-soft { + word-break: normal + } &.vertical { transform: rotate(180deg); text-overflow: ellipsis; @@ -139,6 +142,12 @@ justify-content: center; text-overflow: clip; overflow: hidden; + + white-space: pre; + text-align: center; + word-wrap: break-word; + + @include pseudo-fill($z: -1); &:after { --line-width: 1rem; @@ -153,6 +162,15 @@ } + &.wrap value { + white-space: pre-wrap; + word-break: break-all; + } + + &.wrap-soft value { + word-break: normal + } + } // @keyframes menu-widget-fade {