Skip to content

Commit d909b02

Browse files
committed
refactor(TextAnimate): align component with Mantine Text API and update demos
- Extend TextAnimateProps with TextProps (excluding styling props) for better type safety - Change default component from <div> to <p> and update defaultRef accordingly - Add TextVariant support and include TextStylesNames in stylesNames - Update demos to use new `c` and `gradient` props and adjust animation settings - Ensure gradient variant works consistently across examples
1 parent a08b560 commit d909b02

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

docs/demos/TextAnimate.demo.events.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function Demo() {
1919
<TextAnimate
2020
fz={48}
2121
fw={600}
22-
color="violet"
22+
c="violet"
2323
animate={animated ? 'in' : 'out'}
2424
by="character"
2525
animation="slideRight"
@@ -56,7 +56,7 @@ function Demo() {
5656
<TextAnimate
5757
fz={48}
5858
fw={600}
59-
color="violet"
59+
c="violet"
6060
animate={started ? 'in' : 'out'}
6161
by="character"
6262
animation="slideRight"

docs/demos/TextAnimate.demo.styles.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ function Demo() {
1212
<TextAnimate
1313
fz={48}
1414
fw={600}
15-
color="violet"
15+
gradient={{ from: 'violet', to: 'yellow' }}
16+
variant="gradient"
1617
animate={animated ? 'in' : 'none'}
17-
by="character"
18+
by="word"
1819
animation="blur"
1920
duration={0.5}
2021
animateProps={{
@@ -41,9 +42,10 @@ function Demo() {
4142
<TextAnimate
4243
fz={48}
4344
fw={600}
44-
color="violet"
45+
gradient={{ from: 'violet', to: 'yellow' }}
46+
variant="gradient"
4547
animate={animated ? 'in' : 'none'}
46-
by="character"
48+
by="word"
4749
animation="blur"
4850
duration={0.5}
4951
animateProps={{

package/src/TextAnimate.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import {
1111
type MantineSize,
1212
type PolymorphicFactory,
1313
type StylesApiProps,
14+
type TextProps,
15+
type TextStylesNames,
16+
type TextVariant,
1417
} from '@mantine/core';
1518
import { NumberTicker } from './NumberTicker/NumberTicker';
1619
import { Spinner } from './Spinner/Spinner';
@@ -73,7 +76,7 @@ interface TextAnimateAnimateProps {
7376
blurAmount?: MantineSize;
7477
}
7578

76-
export type TextAnimateStylesNames = 'root' | 'segment';
79+
export type TextAnimateStylesNames = 'root' | 'segment' | TextStylesNames;
7780

7881
export type TextAnimateCssVariables = {
7982
root:
@@ -160,14 +163,19 @@ export interface TextAnimateBaseProps {
160163
}
161164

162165
export interface TextAnimateProps
163-
extends BoxProps, TextAnimateBaseProps, StylesApiProps<TextAnimateFactory> {}
166+
extends
167+
BoxProps,
168+
Omit<TextProps, 'classNames' | 'styles' | 'unstyled' | 'vars' | 'attributes'>,
169+
TextAnimateBaseProps,
170+
StylesApiProps<TextAnimateFactory> {}
164171

165172
export type TextAnimateFactory = PolymorphicFactory<{
166173
props: TextAnimateProps;
167-
defaultComponent: 'div';
168-
defaultRef: HTMLDivElement;
174+
defaultComponent: 'p';
175+
defaultRef: HTMLParagraphElement;
169176
stylesNames: TextAnimateStylesNames;
170177
vars: TextAnimateCssVariables;
178+
variant: TextVariant;
171179
staticComponents: {
172180
Typewriter: typeof Typewriter;
173181
Spinner: typeof Spinner;

0 commit comments

Comments
 (0)