Skip to content
Snippets Groups Projects
Text.js 1.2 KiB
Newer Older
import { has, get } from 'lodash'
import { th } from '@pubsweet/ui-toolkit'
import styled, { css } from 'styled-components'

import { paddingHelper, marginHelper } from './styledHelpers'

const textHelper = props => {
  if (has(props, 'secondary')) {
    return css`
      color: ${th('colorSecondary')};
      font-family: ${th('fontReading')};
    `
  }
  if (has(props, 'error')) {
    return css`
      color: ${th('colorError')};
      font-family: ${th('fontReading')};
    `
  }
  if (has(props, 'customId')) {
    return css`
      color: ${th('colorPrimary')};
      font-family: ${th('fontInterface')};
    `
  }
  return css`
    color: ${th('colorText')};
    font-family: ${th('fontReading')};
  `
}

const fontSize = css`
  font-size: ${props =>
    props.small ? th('fontSizeBaseSmall') : th('fontSizeBase')};
  line-height: ${props =>
    props.small ? th('lineHeightBaseSmall') : th('lineHeightBase')};
`

export default styled.span`
  align-items: center;
  display: ${props => get(props, 'display', 'inline-block')};
  font-style: ${props => props.fontStyle || 'normal'};
  text-align: ${props => props.align || 'start'};
  ${fontSize};
  ${marginHelper};
  ${paddingHelper};