UNPKG

@gfazioli/mantine-text-animate

Version:

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

76 lines (73 loc) 1.87 kB
'use client'; import { createVarsResolver, parseThemeColor, polymorphicFactory, useProps, useStyles, Box } from '@mantine/core'; import React from 'react'; import classes from './Highlight.module.css.mjs'; const defaultProps = { color: "#ffeb3b", animate: true, speed: 1, highlightHeight: "40%", highlightOffset: "60%" }; const varsResolver = createVarsResolver( (theme, { speed, highlightHeight, highlightOffset, color }) => { const resolvedColor = color ? parseThemeColor({ color, theme }).value : "#ffeb3b"; return { root: { "--text-animate-highlight-speed": `${1 / (speed || 1)}s`, "--text-animate-highlight-height": highlightHeight || "40%", "--text-animate-highlight-offset": highlightOffset || "60%", "--text-animate-highlight-color": resolvedColor } }; } ); const Highlight = polymorphicFactory((_props) => { const props = useProps("Highlight", defaultProps, _props); const { children, color, animate, speed, highlightHeight, highlightOffset, classNames, style, styles, unstyled, vars, className, ...others } = props; const getStyles = useStyles({ name: "Highlight", props, classes, className, style, classNames, styles, unstyled, vars, varsResolver }); return /* @__PURE__ */ React.createElement( Box, { ...getStyles("root", { style: { backgroundImage: `linear-gradient(to right, var(--text-animate-highlight-color), var(--text-animate-highlight-color))` } }), component: "span", "data-text-animate-highlight-animate": animate, "aria-live": "polite", ...others }, children ); }); Highlight.classes = classes; Highlight.displayName = "Highlight"; export { Highlight }; //# sourceMappingURL=Highlight.mjs.map