UNPKG

@gfazioli/mantine-text-animate

Version:

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

90 lines (87 loc) 1.82 kB
'use client'; import { createVarsResolver, polymorphicFactory, useProps, useStyles, Box } from '@mantine/core'; import React from 'react'; import { useNumberTicker } from './use-number-ticker.mjs'; import classes from './NumberTicker.module.css.mjs'; const defaultProps = { startValue: 0, delay: 0, decimalPlaces: 0, speed: 1, easing: "ease-out", animate: true }; const varsResolver = createVarsResolver((_, { delay, speed }) => ({ root: { "--number-ticker-animation-duration": `${1 / (speed || 1)}s`, "--number-ticker-animation-delay": `${delay || 0}s` } })); const NumberTicker = polymorphicFactory((_props) => { const props = useProps("NumberTicker", defaultProps, _props); const { value, startValue, delay, decimalPlaces, speed, easing, animate, onCompleted, formatValue, prefix, suffix, classNames, style, styles, unstyled, vars, className, ...others } = props; const { text } = useNumberTicker({ value, startValue, delay, decimalPlaces, speed, easing, animate, onCompleted, formatValue }); const getStyles = useStyles({ name: "NumberTicker", props, classes, className, style, classNames, styles, unstyled, vars, varsResolver }); return /* @__PURE__ */ React.createElement( Box, { ...getStyles("root", { style: { display: "inline-block", fontVariantNumeric: "tabular-nums", letterSpacing: "0.05em" } }), component: "p", "aria-live": "polite", ...others }, prefix, text, suffix ); }); NumberTicker.classes = classes; NumberTicker.displayName = "NumberTicker"; export { NumberTicker }; //# sourceMappingURL=NumberTicker.mjs.map