Browse Source

Renamed ButtonView#style to #labelStyle.

Aleksander Nowodzinski 7 years ago
parent
commit
06d8a735c2

+ 1 - 1
packages/ckeditor5-ui/src/button/button.jsdoc

@@ -131,7 +131,7 @@
  * (Optional) The value of the `style` attribute of the label.
  *
  * @observable
- * @member {String} #style
+ * @member {String} #labelStyle
  */
 
 /**

+ 2 - 2
packages/ckeditor5-ui/src/button/buttonview.js

@@ -47,7 +47,7 @@ export default class ButtonView extends View {
 
 		// Implement the Button interface.
 		this.set( 'class' );
-		this.set( 'style' );
+		this.set( 'labelStyle' );
 		this.set( 'icon' );
 		this.set( 'isEnabled', true );
 		this.set( 'isOn', false );
@@ -214,7 +214,7 @@ export default class ButtonView extends View {
 					'ck',
 					'ck-button__label'
 				],
-				style: bind.to( 'style' ),
+				style: bind.to( 'labelStyle' ),
 				id: `ck-editor__aria-label_${ ariaLabelUid }`,
 			},
 

+ 9 - 2
packages/ckeditor5-ui/src/dropdown/utils.js

@@ -148,8 +148,15 @@ export function addToolbarToDropdown( dropdownView, buttons ) {
  *
  *		const items = new Collection();
  *
- *		items.add( new Model( { label: 'First item', style: 'color: red' } ) );
- *		items.add( new Model( { label: 'Second item', style: 'color: green', class: 'foo' } ) );
+ *		items.add( {
+ *			type: 'button',
+ *			model: new Model( { label: 'First item', labelStyle: 'color: red' } )
+ *		} );
+ *
+ *		items.add( {
+ *			 type: 'button',
+ *			 model: new Model( { label: 'Second item', labelStyle: 'color: green', class: 'foo' } )
+ * 		} );
  *
  *		const dropdown = createDropdown( locale );
  *

+ 3 - 3
packages/ckeditor5-ui/tests/button/buttonview.js

@@ -105,11 +105,11 @@ describe( 'ButtonView', () => {
 			} );
 		} );
 
-		describe( 'label', () => {
-			it( 'reacts on view#style', () => {
+		describe( 'labelView', () => {
+			it( 'reacts on view#labelStyle', () => {
 				expect( view.labelView.element.attributes.getNamedItem( 'style' ) ).to.be.null;
 
-				view.style = 'color: red';
+				view.labelStyle = 'color: red';
 
 				expect( view.labelView.element.attributes.getNamedItem( 'style' ).value ).to.equal( 'color: red' );
 			} );

+ 10 - 10
packages/ckeditor5-ui/tests/dropdown/utils.js

@@ -339,12 +339,12 @@ describe( 'utils', () => {
 				it( 'is populated using item definitions', () => {
 					definitions.add( {
 						type: 'button',
-						model: new Model( { label: 'a', style: 'b' } )
+						model: new Model( { label: 'a', labelStyle: 'b' } )
 					} );
 
 					definitions.add( {
 						type: 'button',
-						model: new Model( { label: 'c', style: 'd' } )
+						model: new Model( { label: 'c', labelStyle: 'd' } )
 					} );
 
 					expect( listItems ).to.have.length( 2 );
@@ -352,18 +352,18 @@ describe( 'utils', () => {
 					expect( listItems.first.children.first ).to.be.instanceOf( ButtonView );
 
 					expect( listItems.get( 1 ).children.first.label ).to.equal( 'c' );
-					expect( listItems.get( 1 ).children.first.style ).to.equal( 'd' );
+					expect( listItems.get( 1 ).children.first.labelStyle ).to.equal( 'd' );
 
 					definitions.remove( 1 );
 					expect( listItems ).to.have.length( 1 );
 					expect( listItems.first.children.first.label ).to.equal( 'a' );
-					expect( listItems.first.children.first.style ).to.equal( 'b' );
+					expect( listItems.first.children.first.labelStyle ).to.equal( 'b' );
 				} );
 
 				it( 'binds all button properties', () => {
 					const def = {
 						type: 'button',
-						model: new Model( { label: 'a', style: 'b', foo: 'bar', baz: 'qux' } )
+						model: new Model( { label: 'a', labelStyle: 'b', foo: 'bar', baz: 'qux' } )
 					};
 
 					definitions.add( def );
@@ -380,7 +380,7 @@ describe( 'utils', () => {
 				it( 'delegates ButtonView#execute to the ListItemView', done => {
 					definitions.add( {
 						type: 'button',
-						model: new Model( { label: 'a', style: 'b' } )
+						model: new Model( { label: 'a', labelStyle: 'b' } )
 					} );
 
 					const listItem = listItems.first;
@@ -401,7 +401,7 @@ describe( 'utils', () => {
 				it( 'is populated using item definitions', () => {
 					definitions.add( {
 						type: 'switchbutton',
-						model: new Model( { label: 'a', style: 'b' } )
+						model: new Model( { label: 'a', labelStyle: 'b' } )
 					} );
 
 					expect( listItems ).to.have.length( 1 );
@@ -410,13 +410,13 @@ describe( 'utils', () => {
 
 					expect( listItems ).to.have.length( 1 );
 					expect( listItems.first.children.first.label ).to.equal( 'a' );
-					expect( listItems.first.children.first.style ).to.equal( 'b' );
+					expect( listItems.first.children.first.labelStyle ).to.equal( 'b' );
 				} );
 
 				it( 'binds all button properties', () => {
 					const def = {
 						type: 'switchbutton',
-						model: new Model( { label: 'a', style: 'b', foo: 'bar', baz: 'qux' } )
+						model: new Model( { label: 'a', labelStyle: 'b', foo: 'bar', baz: 'qux' } )
 					};
 
 					definitions.add( def );
@@ -433,7 +433,7 @@ describe( 'utils', () => {
 				it( 'delegates SwitchButtonView#execute to the ListItemView', done => {
 					definitions.add( {
 						type: 'switchbutton',
-						model: new Model( { label: 'a', style: 'b' } )
+						model: new Model( { label: 'a', labelStyle: 'b' } )
 					} );
 
 					const listItem = listItems.first;