import { RtTextProps } from './rt-text.types';
import {
ElementRef,
ElementType,
ForwardedRef,
forwardRef,
ReactNode,
useMemo,
} from 'react';
// eslint-disable-next-line @nx/enforce-module-boundaries
import { _V_PREFIX_ } from '../../../../../tools/constants';
import cn from 'classnames';
import { CSSProperties } from 'react';
/**
* Необходимо использовать везде, где по дизайну мы видим текст, в сочетании с ``.
* Текст наследует свой цвет от поверхности на которой он расположен, поэтому указать цвет вручную нельзя.
*/
export const RtText: (
props: RtTextProps & { ref?: ForwardedRef> }
) => ReactNode = forwardRef((props, ref) => {
const {
typography,
specification = 'main',
as: renderAs,
children,
className,
lineClamp,
style,
...rest
} = props;
const Component: ElementType = renderAs || 'p';
const lineClampStyle: CSSProperties = useMemo(
() => ({
display: '-webkit-box',
WebkitLineClamp: lineClamp,
WebkitBoxOrient: 'vertical',
overflow: 'hidden',
}),
[lineClamp]
);
return (
{children}
);
});