Skip to content

Commit 0040e85

Browse files
authoredJun 19, 2019
refactor(ui5-switch): rename type property to graphical (#506)
BREAKING CHANGE: type property is renamed to boolean property graphical
1 parent 9d81d32 commit 0040e85

File tree

4 files changed

+21
-53
lines changed

4 files changed

+21
-53
lines changed
 

‎packages/main/src/Switch.js

+9-15
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import getEffectiveRTL from "@ui5/webcomponents-base/src/util/getEffectiveRTL.js
88

99
// Template
1010
import SwitchTemplate from "./build/compiled/SwitchTemplate.lit.js";
11-
import SwitchType from "./types/SwitchType.js";
11+
1212

1313
// Styles
1414
import switchCss from "./themes/Switch.css.js";
@@ -77,18 +77,15 @@ const metadata = {
7777
/**
7878
* Defines the <code>ui5-switch</code> type.
7979
* <br>
80-
* Available options are <code>Textual</code> and <code>Graphical</code>.
8180
*
82-
* <br><br>
83-
* <b>Note:</b> If <code>Graphical</code> type is set,
81+
* <b>Note:</b> If <code>graphical</code> type is set,
8482
* positive and negative icons will replace the <code>textOn</code> and <code>textOff</code>.
8583
* @type {string}
86-
* @defaultvalue "Textual"
84+
* @defaultvalue false
8785
* @public
8886
*/
89-
type: {
90-
type: String,
91-
defaultValue: SwitchType.Textual,
87+
graphical: {
88+
type: Boolean,
9289
},
9390
},
9491
events: /** @lends sap.ui.webcomponents.main.Switch.prototype */ {
@@ -176,30 +173,27 @@ class Switch extends UI5Element {
176173
}
177174

178175
get textOn() {
179-
const graphical = this.type === SwitchType.Graphical;
180-
return graphical ? "" : this.textOn;
176+
return this.graphical ? "" : this.textOn;
181177
}
182178

183179
get textOff() {
184-
const graphical = this.type === SwitchType.Graphical;
185-
return graphical ? "" : this.textOff;
180+
return this.graphical ? "" : this.textOff;
186181
}
187182

188183
get tabIndex() {
189184
return this.disabled ? undefined : "0";
190185
}
191186

192187
get classes() {
193-
const graphical = this.type === SwitchType.Graphical;
194-
const hasLabel = graphical || this.textOn || this.textOff;
188+
const hasLabel = this.graphical || this.textOn || this.textOff;
195189

196190
return {
197191
main: {
198192
"ui5-switch-wrapper": true,
199193
"ui5-switch-desktop": isDesktop(),
200194
"ui5-switch--disabled": this.disabled,
201195
"ui5-switch--checked": this.checked,
202-
"ui5-switch--semantic": graphical,
196+
"ui5-switch--semantic": this.graphical,
203197
"ui5-switch--no-label": !hasLabel,
204198
"sapUiSizeCompact": getCompactSize(),
205199
},

‎packages/main/src/types/SwitchType.js

-26
This file was deleted.

‎packages/main/test/sap/ui/webcomponents/main/pages/Switch.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ <h3>Default Switch</h3>
4848

4949
<h3>Graphical Switch</h3>
5050
<div style="display: flex">
51-
<ui5-switch type="Graphical" text-on="On" text-off="Off"></ui5-switch>
52-
<ui5-switch type="Graphical" checked text-on="Yes" text-off="No"></ui5-switch>
53-
<ui5-switch type="Graphical" text-on="On" text-off="Off" disabled></ui5-switch>
54-
<ui5-switch type="Graphical" checked text-on="Yes" text-off="No" disabled></ui5-switch>
51+
<ui5-switch graphical text-on="On" text-off="Off"></ui5-switch>
52+
<ui5-switch graphical checked text-on="Yes" text-off="No"></ui5-switch>
53+
<ui5-switch graphical text-on="On" text-off="Off" disabled></ui5-switch>
54+
<ui5-switch graphical checked text-on="Yes" text-off="No" disabled></ui5-switch>
5555
</div>
5656

5757
<h3>Custom Switch</h3>

‎packages/main/test/sap/ui/webcomponents/main/samples/Switch.sample.html

+8-8
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@ <h3>Basic Switch</h3>
7171
<section>
7272
<h3>Graphical Switch</h3>
7373
<div class="snippet">
74-
<ui5-switch type="Graphical"></ui5-switch>
75-
<ui5-switch type="Graphical" checked></ui5-switch>
76-
<ui5-switch type="Graphical" disabled></ui5-switch>
77-
<ui5-switch type="Graphical" checked disabled></ui5-switch>
74+
<ui5-switch graphical></ui5-switch>
75+
<ui5-switch graphical checked></ui5-switch>
76+
<ui5-switch graphical disabled></ui5-switch>
77+
<ui5-switch graphical checked disabled></ui5-switch>
7878
</div>
7979
<pre class="prettyprint lang-html"><xmp>
80-
<ui5-switch type="Graphical"></ui5-switch>
81-
<ui5-switch type="Graphical" checked></ui5-switch>
82-
<ui5-switch type="Graphical" disabled></ui5-switch>
83-
<ui5-switch type="Graphical" checked disabled></ui5-switch>
80+
<ui5-switch graphical></ui5-switch>
81+
<ui5-switch graphical checked></ui5-switch>
82+
<ui5-switch graphical disabled></ui5-switch>
83+
<ui5-switch graphical checked disabled></ui5-switch>
8484
</xmp></pre>
8585
</section>
8686

0 commit comments

Comments
 (0)
Please sign in to comment.