import wvui from '@wikimedia/wvui'; import Vue from 'vue'; import buttonTemplate from '!!raw-loader!../includes/templates/Button.mustache'; import '@wikimedia/wvui/dist/wvui.css'; import mustache from 'mustache'; const wvuiIconAdd = 'M11 9V4H9v5H4v2h5v5h2v-5h5V9z'; export default { title: 'Icon and Buttons' }; /** * * @typedef {Object} ButtonProps * @property {string} type * @property {string} action */ /** * @param {ButtonProps} props * @param {string} label * @return {string} */ function makeButtonLegacy( props, label ) { let typeClass = ''; let iconClass = 'mw-ui-icon-add'; switch ( props.action ) { case 'progressive': typeClass += ' mw-ui-progressive'; iconClass += '-progressive'; break; case 'destructive': typeClass += ' mw-ui-destructive'; iconClass += '-destructive'; break; } if ( props.type === 'primary' ) { iconClass = 'mw-ui-icon-add-invert'; } return mustache.render( buttonTemplate, { label, class: typeClass, 'is-quiet': props.type === 'quiet', 'html-vector-button-icon': `` } ); } /** * @param {ButtonProps} props * @param {string} text * @param {string} icon * @return {string} */ function makeButton( props, text, icon ) { const el = document.createElement( 'div' ); const vm = new Vue( { el, render: function ( createElement ) { return createElement( wvui.WvuiButton, { props }, [ createElement( wvui.WvuiIcon, { props: { icon } } ), text ] ); } } ); return `
Legacy | WVUI |
---|