@gfazioli/mantine-text-animate
Version:
The TextAnimate component allows you to animate text with various effects.
94 lines (90 loc) • 1.93 kB
JavaScript
'use client';
;
var React = require('react');
var core = require('@mantine/core');
var useTextTicker = require('./use-text-ticker.cjs');
var TextTicker_module = require('./TextTicker.module.css.cjs');
const defaultProps = {
characterSet: "alphanumeric",
customCharacters: "",
delay: 0,
speed: 1,
easing: "ease-out",
randomChangeSpeed: 1,
revealDirection: "left-to-right",
initialText: "random",
animate: true
};
const varsResolver = core.createVarsResolver((_, { delay, speed }) => ({
root: {
"--text-ticker-animation-duration": `${1 / (speed || 1)}s`,
"--text-ticker-animation-delay": `${delay || 0}s`
}
}));
const TextTicker = core.polymorphicFactory((_props, ref) => {
const props = core.useProps("TextTicker", defaultProps, _props);
const {
value,
initialText,
animate,
characterSet,
customCharacters,
delay,
speed,
easing,
randomChangeSpeed,
revealDirection,
onCompleted,
classNames,
style,
styles,
unstyled,
vars,
className,
...others
} = props;
const { text } = useTextTicker.useTextTicker({
value,
initialText,
animate,
characterSet,
customCharacters,
delay,
speed,
easing,
randomChangeSpeed,
revealDirection,
onCompleted
});
const getStyles = core.useStyles({
name: "TextTicker",
props,
classes: TextTicker_module,
className,
style,
classNames,
styles,
unstyled,
vars,
varsResolver
});
return /* @__PURE__ */ React.createElement(
core.Box,
{
ref,
...getStyles("root", {
style: {
display: "inline-block",
fontFamily: "monospace",
whiteSpace: "pre"
}
}),
component: "p",
...others
},
text
);
});
TextTicker.displayName = "TextTicker";
exports.TextTicker = TextTicker;
//# sourceMappingURL=TextTicker.cjs.map