All files / src/components/StyledText StyledText.tsx

100% Statements 6/6
100% Branches 4/4
100% Functions 1/1
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 261x             1x           26x       26x 9x     17x        
'use client';
 
import { Text, type TextProps, Title, type TitleProps } from '@mantine/core';
import clsx from 'clsx';
import classes from './StyledText.module.css';
import type { StyledTextProps } from './types';
 
export const StyledText = <C extends 'title' | 'text' = 'text'>({
  componentType = 'text' as C,
  gradient = false,
  className,
  ...props
}: StyledTextProps<C>) => {
  const combinedClassName = clsx(className, {
    [classes.gradientText]: gradient,
  });
 
  if (componentType === 'title') {
    return <Title className={combinedClassName} {...(props as TitleProps)} />;
  }
 
  return <Text className={combinedClassName} {...(props as TextProps)} />;
};
 
export default StyledText;