feat: allow id and class attributes to be set on Tabber

Closes: #183, #193

Co-Authored-By: Thomas-programmiert <Thomas-programmiert@users.noreply.github.com>
This commit is contained in:
alistair3149 2024-11-19 16:20:05 -05:00
parent 0e136945cc
commit d5f9e03d47
No known key found for this signature in database
3 changed files with 11 additions and 7 deletions

View file

@ -56,7 +56,7 @@ class Tabber {
$count = count( $parserOutput->getExtensionData( 'tabber-count' ) ?? [] );
$html = self::render( $input, $count, $parser, $frame );
$html = self::render( $input, $count, $args, $parser, $frame );
$parserOutput->appendExtensionData( 'tabber-count', ++$count );
@ -72,15 +72,17 @@ class Tabber {
*
* @param string $input The input URL between the beginning and ending tags.
* @param int $count Current Tabber count
* @param array $args
* @param Parser $parser Mediawiki Parser Object
* @param PPFrame $frame Mediawiki PPFrame Object
*
* @return string HTML
*/
public static function render( string $input, int $count, Parser $parser, PPFrame $frame ): string {
public static function render( string $input, int $count, array $args = [], Parser $parser, PPFrame $frame ): string {
$arr = explode( '|-|', $input );
$data = [
'count' => $count,
'id' => isset( $args['id'] ) ? $args['id'] : "tabber-$count",
'class' => isset( $args['class'] ) ? $args['class'] : '',
'array-tabs' => []
];

View file

@ -49,7 +49,7 @@ class TabberTransclude {
$count = count( $parserOutput->getExtensionData( 'tabber-count' ) ?? [] );
$html = self::render( $input, $count, $parser, $frame );
$html = self::render( $input, $count, $args, $parser, $frame );
$parser->getOutput()->addModuleStyles( [ 'ext.tabberNeue.init.styles' ] );
$parser->getOutput()->addModules( [ 'ext.tabberNeue' ] );
@ -63,16 +63,18 @@ class TabberTransclude {
*
* @param string $input The input URL between the beginning and ending tags.
* @param int $count Current Tabber count
* @param array $args
* @param Parser $parser Mediawiki Parser Object
* @param PPFrame $frame Mediawiki PPFrame Object
*
* @return string HTML
*/
public static function render( string $input, int $count, Parser $parser, PPFrame $frame ): string {
public static function render( string $input, int $count, array $args = [], Parser $parser, PPFrame $frame ): string {
$selected = true;
$arr = explode( "\n", $input );
$data = [
'count' => $count,
'id' => isset( $args['id'] ) ? $args['id'] : "tabber-$count",
'class' => isset( $args['class'] ) ? $args['class'] : '',
'array-tabs' => []
];

View file

@ -1,4 +1,4 @@
<div id="tabber-{{count}}" class='tabber tabber--init'>{{!
<div id="{{id}}" class='tabber tabber--init {{class}}'>{{!
}}<header class="tabber__header">{{!
}}<button class="tabber__header__prev" aria-hidden="true"></button>{{!
}}<nav class="tabber__tabs" role="tablist">{{!