Skip to content

Commit

Permalink
Add a rel attribute to the main button of DropdownIconSplitButton
Browse files Browse the repository at this point in the history
ERM30832
  • Loading branch information
DvogelHallowelt committed Feb 3, 2023
1 parent 93e832c commit a84b845
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
5 changes: 4 additions & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@
'dropdown' => 'MWStake\\MediaWiki\\Component\\CommonUserInterface\\Renderer\\Dropdown',
'dropdown-button' => 'MWStake\\MediaWiki\\Component\\CommonUserInterface\\Renderer\\DropdownButton',
'dropdown-icon' => 'MWStake\\MediaWiki\\Component\\CommonUserInterface\\Renderer\\DropdownIcon',
'dropdown-icon-split-button' => 'MWStake\\MediaWiki\\Component\\CommonUserInterface\\Renderer\\DropdownIconSplitButton',
'dropdown-icon-split-button' => [
'class' => 'MWStake\\MediaWiki\\Component\\CommonUserInterface\\Renderer\\DropdownIconSplitButton',
'services' => [ 'MainConfig' ]
],
'dropdown-split-button' => 'MWStake\\MediaWiki\\Component\\CommonUserInterface\\Renderer\\DropdownSplitButton',
'dropdown-split-link' => 'MWStake\\MediaWiki\\Component\\CommonUserInterface\\Renderer\\DropdownSplitLink',
'dropdown-itemlist' => 'MWStake\\MediaWiki\\Component\\CommonUserInterface\\Renderer\\DropdownItemlist',
Expand Down
4 changes: 2 additions & 2 deletions resources/templates/dropdown-icon-split-button.mustache
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<div class="dropdown{{#cnt-class}} {{.}}{{/cnt-class}}">
<div class="btn-group{{#btn-group-class}} {{.}}{{/btn-group-class}}">
<a role="button" href="{{href}}" {{#btn-class}}class="{{.}}"{{/btn-class}}{{#id}} id={{.}}{{/id}} title="{{btn-title}}"{{#btn-data}} {{{.}}}{{/btn-data}} aria-haspopup="true" aria-label="{{btn-aria-label}}"{{#btn-disabled}} disabled{{/btn-disabled}}>
<a role="button" href="{{href}}" {{#btn-class}}class="{{.}}"{{/btn-class}}{{#id}} id={{.}}{{/id}} title="{{btn-title}}" aria-haspopup="true" aria-label="{{btn-aria-label}}"{{#btn-rel}} rel="{{.}}"{{/btn-rel}}{{#btn-disabled}} disabled{{/btn-disabled}}>
<i{{#icon-class}} class="{{.}}"{{/icon-class}}></i>
</a>
<button class="dropdown-toggle{{#split-btn-class}} {{.}}{{/split-btn-class}}"{{#id}} id="{{.}}-menu-btn"{{/id}} title="{{split-btn-title}}"{{#split-btn-data}} {{{.}}}{{/split-btn-data}} data-bs-toggle="dropdown" aria-haspopup="true" aria-label="{{split-btn-aria-label}}" aria-expanded="false" aria-controls="{{id}}-menu"{{#split-btn-disabled}} disabled{{/split-btn-disabled}}>
<button class="dropdown-toggle{{#split-btn-class}} {{.}}{{/split-btn-class}}"{{#id}} id="{{.}}-menu-btn"{{/id}} title="{{split-btn-title}}" data-bs-toggle="dropdown" aria-haspopup="true" aria-label="{{split-btn-aria-label}}" aria-expanded="false" aria-controls="{{id}}-menu"{{#split-btn-disabled}} disabled{{/split-btn-disabled}}>
</button>
<div id="{{id}}-menu" class="dropdown-menu{{#menu-class}} {{.}}{{/menu-class}}" aria-labelledby="{{id}}-menu-btn">
{{{body}}}
Expand Down
16 changes: 12 additions & 4 deletions src/Component/SimpleDropdownIconSplitButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __construct( $options ) {
'split-button-title' => new RawMessage( 'SimpleSplitButton' ),
'split-button-aria-label' => new RawMessage( 'SimpleSplitButton' ),
'button-href' => '',
'button-rel' => '',
'button-disabled' => false,
'split-button-disabled' => false,
'items' => [],
Expand Down Expand Up @@ -134,11 +135,18 @@ public function buttonIsDisabled() : bool {
return $this->options['button-disabled'];
}

/**
*
* @return bool
*/
/**
*
* @return bool
*/
public function splitButtonIsDisabled() : bool {
return $this->options['split-button-disabled'];
}

/**
* @inheritDoc
*/
public function getButtonRel() : string {
return $this->options['button-rel'];
}
}
5 changes: 5 additions & 0 deletions src/IDropdownIconSplitButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,9 @@ public function buttonIsDisabled() : bool;
* @return bool
*/
public function splitButtonIsDisabled() : bool;

/**
* @return string
*/
public function getButtonRel() : string;
}
8 changes: 8 additions & 0 deletions src/Renderer/DropdownIconSplitButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ public function getRendererDataTreeNode( $component, $subComponentNodes ) : arra
]
);
}
if ( $component->getButtonRel() !== '' ) {
$templateData = array_merge(
$templateData,
[
'btn-rel' => $component->getButtonRel()
]
);
}
if ( $component->buttonIsDisabled() ) {
$templateData = array_merge(
$templateData,
Expand Down

0 comments on commit a84b845

Please sign in to comment.