/**
 * Component for render every info text
 *
 * @author Brauer Ilya
 * @date 2021-05-13
 */
import * as React from 'react';
import * as styles from './infoText.m.scss';
import {ALIGN} from '../../constants';
import {joinClassNames} from '../../utils/joinClassNames';

interface IProps {
    text: string;
    textAlign: ALIGN;
}

export class InfoText extends React.PureComponent<IProps> {
    static defaultProps = {
        textAlign: ALIGN.CENTER
    }

    override render () {
        const textAlign = this.props.textAlign;

        const classNames = joinClassNames(
            styles.infoText,
            [styles.alignLeft, textAlign === ALIGN.LEFT],
            [styles.alignCenter, textAlign === ALIGN.CENTER],
            [styles.alignRight, textAlign === ALIGN.RIGHT],
        );

        return (
            <div className={classNames}>{this.props.text}</div>
        );
    }
}
