mediawiki-extensions-Popups/.storybook/helpers/createPopup.js
WMDE-Fisch 5f602c985c Fixed typo
Change-Id: I9c61f3dcf059884ec7ea16f601009d72b26e0cda
2019-02-04 12:37:16 +00:00

37 lines
889 B
JavaScript

import { SIZES } from '../../src/ui/thumbnail';
import { createPreviewWithType, layoutPreview, getClasses } from '../../src/ui/renderer.js';
import scaleDownThumbnail from './scaleDownThumbnail';
const POINTER_SIZE = 8;
/**
* Creates a static/stateless Popup and returns its HTML as DOM.
*
* @param {ext.popups.PreviewModel} model
* @param {object} layout
*
* @returns {Element} Popup DOM structure
*/
function createPopup( model, layout ) {
if ( model.thumbnail ) {
model.thumbnail = scaleDownThumbnail( model.thumbnail );
}
const preview = createPreviewWithType( model );
Object.assign( layout, { dir: model.languageDirection } );
layoutPreview(
preview,
layout,
getClasses( preview, {
flippedX: layout.flippedX,
flippedY: layout.flippedY
} ),
SIZES.landscapeImage.h,
POINTER_SIZE
);
return preview.el[ 0 ].outerHTML;
}
export default createPopup;