mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-25 08:05:51 +00:00
129bf5c350
- Keep double-dash class name for cached HTML. - Update instances of renamed class in less + js. Bug: T253671 Change-Id: Ieb1ce630e8fa84167e2ca8497f66a20183fdaf90
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
import mustache from 'mustache';
|
|
import '../resources/skins.vector.styles/LanguageButton.less';
|
|
import { vectorMenuTemplate } from './MenuDropdown.stories.data';
|
|
import { languageData } from './LanguageButton.stories.data';
|
|
|
|
export default {
|
|
title: 'LanguageButton'
|
|
};
|
|
|
|
// mw-page-container is needed to enable the 20x20 icon
|
|
// mw-body-header can be removed when VectorLanguageInHeader is true and
|
|
// old language inside portal in modern Vector is no longer supported.
|
|
const CONTAINER_CLASS_MODERN_VECTOR = 'mw-body-header mw-page-container';
|
|
|
|
/**
|
|
* It allows us to support old and new renderings.
|
|
*
|
|
* @param {string|HTMLElement} htmlOrElement
|
|
* @param {string} className of containing element
|
|
* @return {HTMLElement}
|
|
*/
|
|
const wrapLanguageButton = ( htmlOrElement, className ) => {
|
|
const node = document.createElement( 'div' );
|
|
node.setAttribute( 'class', className );
|
|
if ( typeof htmlOrElement === 'string' ) {
|
|
node.innerHTML = htmlOrElement;
|
|
} else {
|
|
node.appendChild( htmlOrElement );
|
|
}
|
|
return node;
|
|
};
|
|
|
|
export const languageButton = () => mustache.render( vectorMenuTemplate, languageData );
|
|
|
|
export const languageButtonWhenULSEnabled = () => wrapLanguageButton(
|
|
wrapLanguageButton(
|
|
wrapLanguageButton(
|
|
mustache.render( vectorMenuTemplate, languageData ),
|
|
'vector-menu-hide-dropdown'
|
|
),
|
|
CONTAINER_CLASS_MODERN_VECTOR
|
|
),
|
|
'client-js'
|
|
);
|