Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit a6b9c09

Browse files
authored
Merge pull request #539 from ckeditor/i/6112
Feature: Implemented the `Toolbar#isCompact` property to turn regular toolbars into compact ones (with less spacing) (see ckeditor/ckeditor5#6112).
2 parents ec39406 + 17da50c commit a6b9c09

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/toolbar/toolbarview.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ export default class ToolbarView extends View {
9494
*/
9595
this.set( 'class' );
9696

97+
/**
98+
* When set true, makes the toolbar look compact with {@link #element}.
99+
*
100+
* @observable
101+
* @default false
102+
* @member {String} #isCompact
103+
*/
104+
this.set( 'isCompact', false );
105+
97106
/**
98107
* A (child) view containing {@link #items toolbar items}.
99108
*
@@ -168,7 +177,8 @@ export default class ToolbarView extends View {
168177
class: [
169178
'ck',
170179
'ck-toolbar',
171-
bind.to( 'class' )
180+
bind.to( 'class' ),
181+
bind.if( 'isCompact', 'ck-toolbar_compact' ),
172182
],
173183
role: 'toolbar',
174184
'aria-label': bind.to( 'ariaLabel' )

tests/toolbar/toolbarview.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ describe( 'ToolbarView', () => {
5454
expect( view.locale ).to.equal( locale );
5555
} );
5656

57+
it( 'should set view#isCompact', () => {
58+
expect( view.isCompact ).to.be.false;
59+
} );
60+
5761
describe( '#options', () => {
5862
it( 'should be an empty object if none were passed', () => {
5963
expect( view.options ).to.deep.equal( {} );
@@ -166,6 +170,14 @@ describe( 'ToolbarView', () => {
166170
expect( view.element.classList.contains( 'foo' ) ).to.be.false;
167171
expect( view.element.classList.contains( 'bar' ) ).to.be.false;
168172
} );
173+
174+
it( 'reacts on view#isCompact', () => {
175+
view.isCompact = false;
176+
expect( view.element.classList.contains( 'ck-toolbar_compact' ) ).to.be.false;
177+
178+
view.isCompact = true;
179+
expect( view.element.classList.contains( 'ck-toolbar_compact' ) ).to.be.true;
180+
} );
169181
} );
170182
} );
171183

0 commit comments

Comments
 (0)