UNPKG

@googleforcreators/units

Version:

A collection of utility functions as well as a React context provider for dealing with "data" and "editor" pixels in the Web Stories editor.

3 lines (2 loc) 711 B
"use strict";var e=require("react"),t=require("@googleforcreators/react"),o=require("./context.js"),r=require("./dimensions.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=i(e);module.exports=function UnitsProvider({pageSize:e,children:i}){const{width:d,height:n}=e,u=t.useMemo((()=>({state:{pageSize:{width:d,height:n}},actions:{dataToEditorX:e=>r.dataToEditorX(e,d),dataToEditorY:e=>r.dataToEditorY(e,n),editorToDataX:(e,t)=>r.editorToDataX(e,d,t),editorToDataY:(e,t)=>r.editorToDataY(e,n,t),getBox:e=>r.getBox(e,d,n),getBoxWithBorder:e=>r.getBoxWithBorder(e,d,n)}})),[d,n]);return a.default.createElement(o.Provider,{value:u},i)}; //# sourceMappingURL=unitsProvider.js.map