Merge "Generate section edit links via SkinMustache"

This commit is contained in:
jenkins-bot 2023-10-24 01:12:49 +00:00 committed by Gerrit Code Review
commit 16eed12b1a
5 changed files with 22 additions and 43 deletions

View file

@ -0,0 +1,5 @@
<a role="button"
{{#array-attributes}}{{key}}="{{value}}"{{/array-attributes}}
class="cdx-button cdx-button--size-large cdx-button--fake-button cdx-button--fake-button--enabled{{#data-icon}} cdx-button--icon-only cdx-button--weight-quiet{{/data-icon}}{{#class}} {{.}}{{/class}}">
{{#data-icon}}{{>Icon}}{{/data-icon}}<span>{{ text }}</span>
</a>

View file

@ -0,0 +1,4 @@
<span class="{{class}}">
{{#array-links}}{{>IconButtonLink}}{{/array-links}}
</span>

View file

@ -549,51 +549,20 @@ class SkinMinerva extends SkinMustache {
}
/**
* Overrides Skin::doEditSectionLink
* @param Title $nt The title being linked to (may not be the same as
* the current page, if the section is included from a template)
* @param string $section
* @param string|null $tooltip
* @param Language $lang
* @return string
* Modifies the template data before parsing in SkinMustache.
*
* @inheritDoc
*/
public function doEditSectionLink( Title $nt, $section, $tooltip, Language $lang ) {
if ( $this->getPermissions()->isAllowed( IMinervaPagePermissions::EDIT_OR_CREATE ) &&
!$nt->isMainPage() ) {
$message = $this->msg( 'mobile-frontend-editor-edit' )->inLanguage( $lang )->text();
$html = Html::openElement( 'span', [ 'class' => 'mw-editsection' ] );
if ( !$this->templateParser ) {
$this->templateParser = new TemplateParser( __DIR__ );
}
$templateParser = $this->templateParser;
$html .= $templateParser->processTemplate( 'Button', [
'tag-name' => 'a',
final protected function doEditSectionLinksHTML( array $links, Language $lang ) {
$transformedLinks = [];
foreach ( $links as $key => $link ) {
$transformedLinks[] = $link + [
'data-icon' => [
'icon' => 'edit-base20'
'icon' => $link['icon'],
],
'array-attributes' => [
[
'key' => 'href',
'value' => $nt->getLocalURL( [ 'action' => 'edit', 'section' => $section ] ),
],
[
'key' => 'title',
'value' => $this->msg( 'editsectionhint', $tooltip )->inLanguage( $lang )->text(),
],
[
'key' => 'data-section',
'value' => $section,
],
],
'label' => $message,
// Note visibility of the edit section link button is controlled by .edit-page in ui.less so
// we default to enabled even though this may not be true.
'classes' => 'edit-page',
] );
$html .= Html::closeElement( 'span' );
return $html;
];
}
return '';
return parent::doEditSectionLinksHTML( $transformedLinks, $lang );
}
/**

View file

@ -176,9 +176,9 @@ main {
// Negative margins to prevent the edit icon from affecting the height of the heading
margin-top: -1em;
margin-bottom: -1em;
.cdx-mixin-button-layout-flush( 'end', true, 'large' );
.cdx-button:last-child {
.cdx-mixin-button-layout-flush( 'end', true, 'large' );
.cdx-button {
font-size: 1rem; // stylelint-disable-line unit-disallowed-list
}
}

View file

@ -103,6 +103,7 @@
"args": [ {
"name": "minerva",
"templateDirectory": "includes/Skins",
"templateSectionLinks": "SectionLinks",
"tempUserBanner": true,
"messages": [
"variants",