@wordpress/components
Version:
UI components for WordPress.
45 lines (44 loc) • 1 kB
JavaScript
// packages/components/src/animate/index.tsx
import clsx from "clsx";
function getDefaultOrigin(type) {
return type === "appear" ? "top" : "left";
}
function getAnimateClassName(options) {
if (options.type === "loading") {
return "components-animate__loading";
}
const {
type,
origin = getDefaultOrigin(type)
} = options;
if (type === "appear") {
const [yAxis, xAxis = "center"] = origin.split(" ");
return clsx("components-animate__appear", {
["is-from-" + xAxis]: xAxis !== "center",
["is-from-" + yAxis]: yAxis !== "middle"
});
}
if (type === "slide-in") {
return clsx("components-animate__slide-in", "is-from-" + origin);
}
return void 0;
}
function Animate({
type,
options = {},
children
}) {
return children({
className: getAnimateClassName({
type,
...options
})
});
}
var animate_default = Animate;
export {
Animate,
animate_default as default,
getAnimateClassName
};
//# sourceMappingURL=index.js.map