// @flow
import styled from 'styled-components';
import type { TextProps } from './text.proptypes';
import { textPropTypes } from './text.proptypes';
import type { PatchworkComponent } from '../../../types';
import { getSpacingRules } from '../../../mixins/spacing';
import { getForegroundColor } from './text.css-rules';
import {
  getTextAlign,
  getFontSize,
  getFontStyle,
  getFontFamily,
  getTextDecoration,
  getTextTransform,
  getFontWeight,
  getTabularStyles,
} from '../../../mixins/typography';

export const Text: PatchworkComponent<TextProps> = styled.p.attrs(props => ({
  style: getSpacingRules(props),
}))`
  line-height: 1.4;
  margin: 0 0 1em 0;
  color: ${getForegroundColor};
  text-align: ${getTextAlign};
  font-size: ${getFontSize};
  font-style: ${getFontStyle};
  font-family: ${getFontFamily};
  font-weight: ${getFontWeight};
  text-decoration: ${getTextDecoration};
  text-transform: ${getTextTransform};
  ${getTabularStyles}
`;

Text.displayName = 'Text';
Text.propTypes = textPropTypes;
