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

Feature: Initial implementation of ButtonDropdown View. #339

Merged
merged 29 commits into from
Dec 14, 2017
Merged

Feature: Initial implementation of ButtonDropdown View. #339

merged 29 commits into from
Dec 14, 2017

Conversation

jodator
Copy link
Contributor

@jodator jodator commented Nov 13, 2017

Suggested merge commit message (convention)

Feature: Initial implementation of ButtonGroupView and ButtonDropdown View. Closes ckeditor/ckeditor5#5428.


Additional information

Other: Make ButtonDropdown's toolbar button present as normal button.

@jodator jodator requested a review from oleq November 13, 2017 12:12
Copy link
Member

@oleq oleq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of questions ;-)

*
* @extends module:ui/view~View
*/
export default class ButtonGroupView extends View {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this class could be replaced by the ToolbarView? It almost replicates its functionality 1:1. The only feature that ToolbarView would need is isVertical, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it is a 1:1 copy with additional isVertical property behavior. It would only need some minor CSS adjustments for paddings:

selection_047

The other things is (probably minor) the name of this thing as I don't feel too comfortable with placing Toolbar inside dropdown. But as it works and does not create bloat code I can live with this :)

*
* const buttons = [];
*
* buttons.push( new ButtonView() );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent.

return dropdownView;
}

function getBindingTargets( buttons, attribute ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docs.


/* global document */

export function openDropdownOnArrows( dropdownView, buttonGroupView ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docs.

} );
}

export function closeDropdownOnExecute( dropdownView, items ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docs.

@@ -0,0 +1,11 @@
// Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
Copy link
Member

@oleq oleq Dec 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file, if ButtonGroupView becomes a component (my comment in the class definition), should have its own folder.


dropdownView.buttonView.extendTemplate( {
attributes: {
class: [ 'ck-button-dropdown' ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think classes are set on wrong DOM elements. ATM it's

<div class="ck-dropdown">
    <button class="ck-button ck-enabled ck-off ck-dropdown__button ck-button-dropdown" type="button" tabindex="-1">...</button>
    <div class="ck-reset ck-dropdown__panel">
        <div class="ck-reset ck-button-group ">...</div>
    </div>
</div>

but I think it should be

<div class="ck-dropdown ck-button-dropdown">
    <button class="ck-button ck-enabled ck-off ck-dropdown__button" type="button" tabindex="-1">...</button>
    <div class="ck-reset ck-dropdown__panel">
        <div class="ck-reset ck-button-group ">...</div>
    </div>
</div>

instead. WDYT?

/**
* @inheritDoc
*/
constructor( options = {} ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs for options? View does not accept such argument, so @inheritDoc won't work.

* @inheritDoc
*/
constructor( options = {} ) {
super();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's safe to pass locale to the parent here. If it's needed in the future, it will require changes in many places that use this component because the order of constructor() arguments will change (locale should be first).

import '../../theme/components/buttongroup.css';

/**
* The button group view class.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing some simple example.

@jodator
Copy link
Contributor Author

jodator commented Dec 13, 2017

@oleq I've updated this PR with:

  • I've used ToolbarView directly with only one addition of focusLast() method.
  • I've updated some docs.
  • I've created a docs for DropdownPanelFocusable as I saw that one method from dropdown/utils required a view with focus() and focusLast() methods.
  • Manual tests for button dropdown has now it's own section.

@oleq oleq changed the title Feature: Initial implementation of ButtonGroupView and ButtonDropdown View. Feature: Initial implementation of ButtonDropdown View. Dec 14, 2017
@oleq oleq merged commit 6e9c6e4 into master Dec 14, 2017
@oleq oleq deleted the t/333 branch December 14, 2017 11:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the toolbar dropdown that groups other buttons
2 participants