UNPKG

@gfazioli/mantine-text-animate

Version:

The TextAnimate component allows you to animate text with various effects.

97 lines (94 loc) 2.01 kB
'use client'; import { createVarsResolver, polymorphicFactory, useProps, useStyles, Box } from '@mantine/core'; import React from 'react'; import { useTextTicker } from './use-text-ticker.mjs'; import classes from './TextTicker.module.css.mjs'; const defaultProps = { characterSet: "alphanumeric", customCharacters: "", delay: 0, speed: 1, easing: "ease-out", randomChangeSpeed: 1, revealDirection: "left-to-right", initialText: "random", animate: true }; const varsResolver = createVarsResolver((_, { delay, speed }) => ({ root: { "--text-ticker-animation-duration": `${1 / (speed || 1)}s`, "--text-ticker-animation-delay": `${delay || 0}s` } })); const TextTicker = polymorphicFactory((_props) => { const props = useProps("TextTicker", defaultProps, _props); const { value, initialText, animate, characterSet, customCharacters, delay, speed, easing, randomChangeSpeed, revealDirection, scrambleDuration, staggerDelay, onCompleted, classNames, style, styles, unstyled, vars, className, ...others } = props; const { text } = useTextTicker({ value, initialText, animate, characterSet, customCharacters, delay, speed, easing, randomChangeSpeed, revealDirection, scrambleDuration, staggerDelay, onCompleted }); const getStyles = useStyles({ name: "TextTicker", props, classes, className, style, classNames, styles, unstyled, vars, varsResolver }); return /* @__PURE__ */ React.createElement( Box, { ...getStyles("root", { style: { display: "inline-block", fontFamily: "monospace", whiteSpace: "pre" } }), component: "p", "aria-live": "polite", ...others }, text ); }); TextTicker.classes = classes; TextTicker.displayName = "TextTicker"; export { TextTicker }; //# sourceMappingURL=TextTicker.mjs.map