import mustache from 'mustache'; import portalTemplate from '!!raw-loader!../includes/templates/Portal.mustache'; import '../resources/skins.vector.styles/Portal.less'; import '../.storybook/common.less'; import { placeholder, htmluserlangattributes } from './utils'; /** * @param {PortletContext} data * @return {HTMLElement} */ export const wrapPortlet = ( data ) => { const node = document.createElement( 'div' ); node.setAttribute( 'id', 'mw-panel' ); node.innerHTML = mustache.render( portalTemplate, data ); return node; }; /** * @param {string} html * @return {string} */ const portletAfter = ( html ) => { return `
${html}
`; }; export const PORTALS = { example: { 'portal-id': 'p-example', class: 'portal', 'html-tooltip': 'Message tooltip-p-example acts as tooltip', 'msg-label': 'Portal title', 'msg-label-id': 'p-example-label', 'html-userlangattributes': htmluserlangattributes, 'html-portal-content': ``, 'html-after-portal': portletAfter( placeholder( `

Beware: The BaseTemplateAfterPortlet hook can be used to inject arbitary HTML here for any portlet.

`, 60 ) ) }, navigation: { 'portal-id': 'p-navigation', class: 'portal portal-first', 'html-tooltip': 'A message tooltip-p-navigation must exist for this to appear', 'msg-label': 'Navigation', 'msg-label-id': 'p-navigation-label', 'html-userlangattributes': htmluserlangattributes, 'html-portal-content': ``, 'html-after-portal': portletAfter( placeholder( 'Possible hook output (navigation)', 50 ) ) }, toolbox: { 'portal-id': 'p-tb', class: 'portal', 'html-tooltip': 'A message tooltip-p-tb must exist for this to appear', 'msg-label': 'Tools', 'msg-label-id': 'p-tb-label', 'html-userlangattributes': htmluserlangattributes, 'html-portal-content': ``, 'html-after-portal': portletAfter( placeholder( 'Possible hook output (tb)', 50 ) ) }, langlinks: { 'portal-id': 'p-lang', class: 'portal', 'html-tooltip': 'A message tooltip-p-lang must exist for this to appear', 'msg-label': 'In other languages', 'msg-label-id': 'p-lang-label', 'html-userlangattributes': htmluserlangattributes, 'html-portal-content': ``, 'html-after-portal': portletAfter( `Edit links ${placeholder( `

Further hook output possible (lang)

`, 60 )}` ) }, otherProjects: { 'portal-id': 'p-wikibase-otherprojects', class: 'portal', 'html-tooltip': 'A message tooltip-p-wikibase-otherprojects must exist for this to appear', 'msg-label': 'In other projects', 'msg-label-id': 'p-wikibase-otherprojects-label', 'html-userlangattributes': htmluserlangattributes, 'html-portal-content': ``, 'html-after-portal': '' } };