import * as stylex from '@stylexjs/stylex';

import type { TextProps } from './types';

import {
  textAlignments,
  textColors,
  textStyles,
  textVariants,
  textWeights,
} from './styles';

export const Text = ({
  variant = 'body',
  color = 'primary',
  align = 'left',
  weight,
  truncate = false,
  noWrap = false,
  children,
}: TextProps) => {
  return (
    <div
      {...stylex.props(
        textStyles.base,
        truncate && textStyles.truncate,
        noWrap && textStyles.noWrap,
        textVariants[variant],
        textColors[color],
        textAlignments[align],
        weight && textWeights[weight]
      )}
    >
      {children}
    </div>
  );
};
