Przeglądaj źródła

Aligned lark MT to the new View API. Added some sugar to Dropdown rendering.

Aleksander Nowodzinski 9 lat temu
rodzic
commit
189dd2059e
1 zmienionych plików z 20 dodań i 10 usunięć
  1. 20 10
      packages/ckeditor5-theme-lark/tests/manual/theme.js

+ 20 - 10
packages/ckeditor5-theme-lark/tests/manual/theme.js

@@ -226,22 +226,19 @@ function renderDropdown( ui ) {
 		items: collection
 	} );
 
-	const enabledModel = new Model( {
+	ui.add( 'dropdown', dropdown( {
 		label: 'Normal state',
 		isEnabled: true,
 		isOn: false,
 		content: itemListModel
-	} );
+	} ) );
 
-	const disabledModel = new Model( {
+	ui.add( 'dropdown', dropdown( {
 		label: 'Disabled',
 		isEnabled: false,
 		isOn: false,
 		content: itemListModel
-	} );
-
-	ui.add( 'dropdown', new ListDropdown( enabledModel, new ListDropdownView( enabledModel ) ) );
-	ui.add( 'dropdown', new ListDropdown( disabledModel, new ListDropdownView( disabledModel ) ) );
+	} ) );
 }
 
 function renderToolbar( ui ) {
@@ -261,7 +258,9 @@ function renderToolbar( ui ) {
 			label: 'Button with icon',
 			icon: 'bold',
 			iconAlign: 'LEFT'
-		} )
+		} ),
+		dropdown(),
+		button()
 	] ) );
 
 	// --- Rounded ------------------------------------------------------------
@@ -360,8 +359,7 @@ function button( { label = 'Button', noText = false, isEnabled = true, isOn = fa
 }
 
 function toolbar( children = [] ) {
-	const model = new Model( { isActive: false } );
-	const toolbar = new Toolbar( model, new ToolbarView() );
+	const toolbar = new Toolbar( new ToolbarView() );
 
 	children.forEach( c => {
 		toolbar.add( 'buttons', c );
@@ -370,6 +368,18 @@ function toolbar( children = [] ) {
 	return toolbar;
 }
 
+function dropdown( {
+	label = 'Dropdown',
+	isEnabled = true,
+	isOn = false,
+	content = new Model( { items: new Collection( { idProperty: 'label' } ) } )
+} = {} ) {
+	const model = new Model( { label, isEnabled, isOn, content } );
+	const dropdown = new ListDropdown( model, new ListDropdownView() );
+
+	return dropdown;
+}
+
 const ToolbarSeparatorView = class extends View {
 	constructor() {
 		super();