Fix storybook instance display of footer and personal menu
* The classes provided on the personal menu are incorrect. Rectify these by creating a menu helper * Register the footer template partials Change-Id: I4b73be54c073f0dd350c107b18f10456c9ee1b17
This commit is contained in:
parent
55ad570315
commit
edb8872c95
|
@ -2,6 +2,12 @@
|
|||
|
||||
import { htmlUserLanguageAttributes } from './utils';
|
||||
import footerTemplate from '!!raw-loader!../includes/templates/Footer.mustache';
|
||||
import footerRowTemplate from '!!raw-loader!../includes/templates/Footer__row.mustache';
|
||||
|
||||
export const FOOTER_TEMPLATE_PARTIALS = {
|
||||
// eslint-disable-next-line camelcase
|
||||
Footer__row: footerRowTemplate
|
||||
};
|
||||
|
||||
const
|
||||
FOOTER_INFO = {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import mustache from 'mustache';
|
||||
import { FOOTER_TEMPLATE_DATA, footerTemplate } from './Footer.stories.data';
|
||||
import { FOOTER_TEMPLATE_DATA, FOOTER_TEMPLATE_PARTIALS,
|
||||
footerTemplate } from './Footer.stories.data';
|
||||
import '../resources/skins.vector.styles/Footer.less';
|
||||
import '../.storybook/common.less';
|
||||
|
||||
|
@ -7,4 +8,8 @@ export default {
|
|||
title: 'Footer'
|
||||
};
|
||||
|
||||
export const footer = () => mustache.render( footerTemplate, FOOTER_TEMPLATE_DATA );
|
||||
export const footer = () => mustache.render(
|
||||
footerTemplate,
|
||||
FOOTER_TEMPLATE_DATA,
|
||||
FOOTER_TEMPLATE_PARTIALS
|
||||
);
|
||||
|
|
|
@ -8,52 +8,65 @@ import menuTemplate from '!!raw-loader!../includes/templates/Menu.mustache';
|
|||
import { htmlUserLanguageAttributes } from './utils';
|
||||
|
||||
/**
|
||||
* @type {MenuDefinition}
|
||||
* @param {string} name of the menu
|
||||
* @param {string} htmlItems
|
||||
* @return {MenuDefinition}
|
||||
*/
|
||||
const loggedOut = {
|
||||
id: 'p-personal',
|
||||
class: 'vector-menu',
|
||||
label: 'Personal tools',
|
||||
'html-user-language-attributes': htmlUserLanguageAttributes,
|
||||
'html-items': `<li id="pt-anonuserpage">Not logged in</li><li id="pt-anontalk"><a href="/wiki/Special:MyTalk" title="Discussion about edits from this IP address [⌃⌥n]" accesskey="n">Talk</a></li><li id="pt-anoncontribs"><a href="/wiki/Special:MyContributions" title="A list of edits made from this IP address [⌃⌥y]" accesskey="y">Contributions</a></li><li id="pt-createaccount"><a href="/w/index.php?title=Special:CreateAccount&returnto=Main+Page" title="You are encouraged to create an account and log in; however, it is not mandatory">Create account</a></li><li id="pt-login"><a href="/w/index.php?title=Special:UserLogin&returnto=Main+Page" title="You're encouraged to log in; however, it's not mandatory. [⌃⌥o]" accesskey="o">Log in</a></li>`
|
||||
};
|
||||
function helperMakeMenuData( name, htmlItems ) {
|
||||
let label;
|
||||
switch ( name ) {
|
||||
case 'personal':
|
||||
label = 'Personal tools';
|
||||
break;
|
||||
default:
|
||||
label = 'Menu label';
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
id: `p-${name}`,
|
||||
class: `mw-portlet mw-portlet-${name} vector-menu`,
|
||||
label,
|
||||
'html-user-language-attributes': htmlUserLanguageAttributes,
|
||||
'html-items': htmlItems
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {MenuDefinition}
|
||||
*/
|
||||
const loggedInWithEcho = {
|
||||
id: 'p-personal',
|
||||
class: 'vector-menu',
|
||||
label: 'Personal tools',
|
||||
'html-user-language-attributes': htmlUserLanguageAttributes,
|
||||
'html-items': `<li id="pt-userpage"><a href="/wiki/User:Jdlrobson" dir="auto" title="Your user page [⌃⌥.]" accesskey=".">Jdlrobson</a></li><li id="pt-notifications-alert"><a href="/wiki/Special:Notifications" class="mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-icon-bell mw-echo-notifications-badge-all-read" data-counter-num="0" data-counter-text="0" title="Your alerts">Alerts (0)</a></li><li id="pt-notifications-notice"><a href="/wiki/Special:Notifications" class="mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-icon-tray" data-counter-num="3" data-counter-text="3" title="Your notices">Notices (3)</a></li><li id="pt-mytalk"><a href="/wiki/User_talk:Jdlrobson" title="Your talk page [⌃⌥n]" accesskey="n">Talk</a></li><li id="pt-sandbox"><a href="/wiki/User:Jdlrobson/sandbox" title="Your sandbox">Sandbox</a></li><li id="pt-preferences"><a href="/wiki/Special:Preferences" title="Your preferences">Preferences</a></li><li id="pt-betafeatures"><a href="/wiki/Special:Preferences#mw-prefsection-betafeatures" title="Beta features">Beta</a></li><li id="pt-watchlist"><a href="/wiki/Special:Watchlist" title="A list of pages you are monitoring for changes [⌃⌥l]" accesskey="l">Watchlist</a></li><li id="pt-mycontris"><a href="/wiki/Special:Contributions/Jdlrobson" title="A list of your contributions [⌃⌥y]" accesskey="y">Contributions</a></li><li id="pt-logout"><a href="/w/index.php?title=Special:UserLogout&returnto=Main+Page&returntoquery=useskin%3Dvector" title="Log out">Log out</a></li>`
|
||||
};
|
||||
const loggedOut = helperMakeMenuData(
|
||||
'personal',
|
||||
`<li id="pt-anonuserpage">Not logged in</li><li id="pt-anontalk"><a href="/wiki/Special:MyTalk" title="Discussion about edits from this IP address [⌃⌥n]" accesskey="n">Talk</a></li><li id="pt-anoncontribs"><a href="/wiki/Special:MyContributions" title="A list of edits made from this IP address [⌃⌥y]" accesskey="y">Contributions</a></li><li id="pt-createaccount"><a href="/w/index.php?title=Special:CreateAccount&returnto=Main+Page" title="You are encouraged to create an account and log in; however, it is not mandatory">Create account</a></li><li id="pt-login"><a href="/w/index.php?title=Special:UserLogin&returnto=Main+Page" title="You're encouraged to log in; however, it's not mandatory. [⌃⌥o]" accesskey="o">Log in</a></li>`
|
||||
);
|
||||
|
||||
/**
|
||||
* @type {MenuDefinition}
|
||||
*/
|
||||
const loggedInWithEcho = helperMakeMenuData(
|
||||
'personal',
|
||||
`<li id="pt-userpage"><a href="/wiki/User:Jdlrobson" dir="auto" title="Your user page [⌃⌥.]" accesskey=".">Jdlrobson</a></li><li id="pt-notifications-alert"><a href="/wiki/Special:Notifications" class="mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-icon-bell mw-echo-notifications-badge-all-read" data-counter-num="0" data-counter-text="0" title="Your alerts">Alerts (0)</a></li><li id="pt-notifications-notice"><a href="/wiki/Special:Notifications" class="mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-icon-tray" data-counter-num="3" data-counter-text="3" title="Your notices">Notices (3)</a></li><li id="pt-mytalk"><a href="/wiki/User_talk:Jdlrobson" title="Your talk page [⌃⌥n]" accesskey="n">Talk</a></li><li id="pt-sandbox"><a href="/wiki/User:Jdlrobson/sandbox" title="Your sandbox">Sandbox</a></li><li id="pt-preferences"><a href="/wiki/Special:Preferences" title="Your preferences">Preferences</a></li><li id="pt-betafeatures"><a href="/wiki/Special:Preferences#mw-prefsection-betafeatures" title="Beta features">Beta</a></li><li id="pt-watchlist"><a href="/wiki/Special:Watchlist" title="A list of pages you are monitoring for changes [⌃⌥l]" accesskey="l">Watchlist</a></li><li id="pt-mycontris"><a href="/wiki/Special:Contributions/Jdlrobson" title="A list of your contributions [⌃⌥y]" accesskey="y">Contributions</a></li><li id="pt-logout"><a href="/w/index.php?title=Special:UserLogout&returnto=Main+Page&returntoquery=useskin%3Dvector" title="Log out">Log out</a></li>`
|
||||
);
|
||||
|
||||
const ULS_LANGUAGE_SELECTOR = '<li class="uls-trigger active"><a href="#">English</a></li>';
|
||||
|
||||
/**
|
||||
* @type {MenuDefinition}
|
||||
*/
|
||||
const defaultMenu = {
|
||||
id: 'p-generic',
|
||||
class: 'vector-menu',
|
||||
label: 'Menu label',
|
||||
'html-user-language-attributes': htmlUserLanguageAttributes,
|
||||
'html-items': `<li><a href='#'>Item 1</a></li>
|
||||
const defaultMenu = helperMakeMenuData(
|
||||
'generic',
|
||||
`<li><a href='#'>Item 1</a></li>
|
||||
<li><a href='#'>Item 2</a></li>
|
||||
<li><a href='#'>Item 3</a></li>`
|
||||
};
|
||||
);
|
||||
|
||||
/**
|
||||
* @type {MenuDefinition}
|
||||
*/
|
||||
const loggedInWithULS = {
|
||||
id: 'p-personal',
|
||||
class: 'vector-menu',
|
||||
label: 'Personal tools',
|
||||
'html-user-language-attributes': htmlUserLanguageAttributes,
|
||||
'html-items': `${ULS_LANGUAGE_SELECTOR}<li id="pt-userpage"><a href="/wiki/User:Jdlrobson" dir="auto" title="Your user page [⌃⌥.]" accesskey=".">Jdlrobson</a></li><li id="pt-notifications-alert"><a href="/wiki/Special:Notifications" class="mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-icon-bell mw-echo-notifications-badge-all-read" data-counter-num="0" data-counter-text="0" title="Your alerts">Alerts (0)</a></li><li id="pt-notifications-notice"><a href="/wiki/Special:Notifications" class="mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-icon-tray" data-counter-num="3" data-counter-text="3" title="Your notices">Notices (3)</a></li><li id="pt-mytalk"><a href="/wiki/User_talk:Jdlrobson" title="Your talk page [⌃⌥n]" accesskey="n">Talk</a></li><li id="pt-sandbox"><a href="/wiki/User:Jdlrobson/sandbox" title="Your sandbox">Sandbox</a></li><li id="pt-preferences"><a href="/wiki/Special:Preferences" title="Your preferences">Preferences</a></li><li id="pt-betafeatures"><a href="/wiki/Special:Preferences#mw-prefsection-betafeatures" title="Beta features">Beta</a></li><li id="pt-watchlist"><a href="/wiki/Special:Watchlist" title="A list of pages you are monitoring for changes [⌃⌥l]" accesskey="l">Watchlist</a></li><li id="pt-mycontris"><a href="/wiki/Special:Contributions/Jdlrobson" title="A list of your contributions [⌃⌥y]" accesskey="y">Contributions</a></li><li id="pt-logout"><a href="/w/index.php?title=Special:UserLogout&returnto=Main+Page&returntoquery=useskin%3Dvector" title="Log out">Log out</a></li>`
|
||||
};
|
||||
const loggedInWithULS = helperMakeMenuData(
|
||||
'personal',
|
||||
`${ULS_LANGUAGE_SELECTOR}<li id="pt-userpage"><a href="/wiki/User:Jdlrobson" dir="auto" title="Your user page [⌃⌥.]" accesskey=".">Jdlrobson</a></li><li id="pt-notifications-alert"><a href="/wiki/Special:Notifications" class="mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-icon-bell mw-echo-notifications-badge-all-read" data-counter-num="0" data-counter-text="0" title="Your alerts">Alerts (0)</a></li><li id="pt-notifications-notice"><a href="/wiki/Special:Notifications" class="mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-icon-tray" data-counter-num="3" data-counter-text="3" title="Your notices">Notices (3)</a></li><li id="pt-mytalk"><a href="/wiki/User_talk:Jdlrobson" title="Your talk page [⌃⌥n]" accesskey="n">Talk</a></li><li id="pt-sandbox"><a href="/wiki/User:Jdlrobson/sandbox" title="Your sandbox">Sandbox</a></li><li id="pt-preferences"><a href="/wiki/Special:Preferences" title="Your preferences">Preferences</a></li><li id="pt-betafeatures"><a href="/wiki/Special:Preferences#mw-prefsection-betafeatures" title="Beta features">Beta</a></li><li id="pt-watchlist"><a href="/wiki/Special:Watchlist" title="A list of pages you are monitoring for changes [⌃⌥l]" accesskey="l">Watchlist</a></li><li id="pt-mycontris"><a href="/wiki/Special:Contributions/Jdlrobson" title="A list of your contributions [⌃⌥y]" accesskey="y">Contributions</a></li><li id="pt-logout"><a href="/w/index.php?title=Special:UserLogout&returnto=Main+Page&returntoquery=useskin%3Dvector" title="Log out">Log out</a></li>`
|
||||
);
|
||||
|
||||
/**
|
||||
* @type {Object.<string, MenuDefinition>}
|
||||
|
|
|
@ -13,7 +13,8 @@ import { vectorMenuTemplate, moreData, variantsData } from './MenuDropdown.stori
|
|||
import { searchBoxData, searchBoxTemplate } from './SearchBox.stories.data';
|
||||
import { SIDEBAR_DATA, SIDEBAR_TEMPLATE_PARTIALS,
|
||||
sidebarLegacyTemplate, sidebarTemplate } from './Sidebar.stories.data';
|
||||
import { FOOTER_TEMPLATE_DATA, footerTemplate } from './Footer.stories.data';
|
||||
import { FOOTER_TEMPLATE_DATA, FOOTER_TEMPLATE_PARTIALS,
|
||||
footerTemplate } from './Footer.stories.data';
|
||||
import { logoTemplate } from './Logo.stories.data';
|
||||
|
||||
export const NAVIGATION_TEMPLATE_DATA = {
|
||||
|
@ -57,7 +58,7 @@ export const TEMPLATE_PARTIALS = Object.assign( {}, SIDEBAR_TEMPLATE_PARTIALS, {
|
|||
VectorMenu: vectorMenuTemplate,
|
||||
Menu: menuTemplate,
|
||||
Footer: footerTemplate
|
||||
} );
|
||||
}, FOOTER_TEMPLATE_PARTIALS );
|
||||
|
||||
/**
|
||||
* @type {Indicator[]}
|
||||
|
|
Loading…
Reference in New Issue