@matt-dunn/react-wireframes
Version:
React component to annotate your components — useful for prototypes and proof of concepts
38 lines (27 loc) • 1.25 kB
JavaScript
;
require("core-js/modules/es.array.find");
require("core-js/modules/es.array.map");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useIsomorphicLayoutEffect = exports.updateWireframeAnnotation = exports.getWireframeAnnotation = void 0;
var _react = require("react");
var getWireframeAnnotation = function getWireframeAnnotation(annotations, Component) {
return Component && annotations.find(function (c) {
return c.Component === Component;
});
};
exports.getWireframeAnnotation = getWireframeAnnotation;
var updateWireframeAnnotation = function updateWireframeAnnotation(annotations, wireFrameAnnotation, updatedWireframeAnnotation) {
var currentAnnotation = getWireframeAnnotation(annotations, wireFrameAnnotation.Component);
if (currentAnnotation) {
return annotations.map(function (annotation) {
return annotation === wireFrameAnnotation ? updatedWireframeAnnotation : annotation;
});
}
return annotations;
};
/* istanbul ignore next */
exports.updateWireframeAnnotation = updateWireframeAnnotation;
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? _react.useLayoutEffect : _react.useEffect;
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;