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

Commit

Permalink
Merge pull request #539 from ckeditor/i/6112
Browse files Browse the repository at this point in the history
Feature: Implemented the `Toolbar#isCompact` property to turn regular toolbars into compact ones (with less spacing) (see ckeditor/ckeditor5#6112).
  • Loading branch information
jodator authored Feb 3, 2020
2 parents ec39406 + 17da50c commit a6b9c09
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/toolbar/toolbarview.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ export default class ToolbarView extends View {
*/
this.set( 'class' );

/**
* When set true, makes the toolbar look compact with {@link #element}.
*
* @observable
* @default false
* @member {String} #isCompact
*/
this.set( 'isCompact', false );

/**
* A (child) view containing {@link #items toolbar items}.
*
Expand Down Expand Up @@ -168,7 +177,8 @@ export default class ToolbarView extends View {
class: [
'ck',
'ck-toolbar',
bind.to( 'class' )
bind.to( 'class' ),
bind.if( 'isCompact', 'ck-toolbar_compact' ),
],
role: 'toolbar',
'aria-label': bind.to( 'ariaLabel' )
Expand Down
12 changes: 12 additions & 0 deletions tests/toolbar/toolbarview.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ describe( 'ToolbarView', () => {
expect( view.locale ).to.equal( locale );
} );

it( 'should set view#isCompact', () => {
expect( view.isCompact ).to.be.false;
} );

describe( '#options', () => {
it( 'should be an empty object if none were passed', () => {
expect( view.options ).to.deep.equal( {} );
Expand Down Expand Up @@ -166,6 +170,14 @@ describe( 'ToolbarView', () => {
expect( view.element.classList.contains( 'foo' ) ).to.be.false;
expect( view.element.classList.contains( 'bar' ) ).to.be.false;
} );

it( 'reacts on view#isCompact', () => {
view.isCompact = false;
expect( view.element.classList.contains( 'ck-toolbar_compact' ) ).to.be.false;

view.isCompact = true;
expect( view.element.classList.contains( 'ck-toolbar_compact' ) ).to.be.true;
} );
} );
} );

Expand Down

0 comments on commit a6b9c09

Please sign in to comment.