# All files / src/DateInput DateInput.styles.tsx

100% Statements 24/24
80.76% Branches 21/26
100% Functions 5/5
100% Lines 22/22

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    1219x
    9x
    9x
    9x
    9x
    9x
    9x

    9x

    9x

    9x

    9x

    9x

    120x

    9x
    80x

    9x

    9x

    40x
    40x

    40x

    40x
    40x

     import { Calendar } from '@procore/core-icons/dist'
    import styled, { css } from 'styled-components'
    import { dataQa } from '../Input/Input.styles'
    import { getTypographyIntent } from '../Typography/Typography.styles'
    import { colors } from '../_styles/colors'
    import { getFocus } from '../_styles/mixins'
    import { spacing } from '../_styles/spacing'

    interface StyledDateInputSegmentProps {
      disabled: boolean
      isYear: boolean
    }

    const inputHeight = 36 // TODO one-off

    const disabledCss = css`
      background-color: ${colors.gray94};
      color: ${colors.gray45};
      border-width: 1px;
      border-style: solid;
      border-color: ${colors.gray70};
      pointer-events: none;

      svg {
        color: ${colors.gray45};
      }
    `

    export const StyledCalendar = styled(Calendar)`
      color: ${colors.gray45};
    `

    export const StyledDateSegmentsContainer = styled.div`
      min-width: 104px;
      display: flex;
      gap: ${spacing.xs}px;
    `

    export const StyledDateInputSegment = styled.div<StyledDateInputSegmentProps>`
      ${getTypographyIntent('body')}
      outline: none;
      text-align: center;

      &:focus {
        background-color: ${colors.blue96};
      }

      &::selection {
        background-color: transparent;
      }

      &[data-placeholder='true'] {
        color: ${({ disabled }) => (disabled ? colors.gray70 : colors.gray45)};
      }
    `

    export const StyledDateInputDelimiter = styled.span.attrs<{ visible: boolean }>(
      (props) => ({
        ['data-qa-table-visible']: props.visible,
      })
    )<{ visible: boolean }>`
      ${getTypographyIntent('body')}
      user-select: none;
    `

    export const StyledDateInputIconContainer = styled.div`
      display: inline-flex;
      flex: 0 0 auto;
      align-items: center;
      justify-content: center;
      margin: 0 0 0 ${spacing.xs}px;
      height: 24px;
      width: 24px;
    `

    export const StyledDateInput = styled.div<{
      disabled: boolean
      error: boolean
    }>`
      align-items: center;
      border-color: ${colors.gray70};
      border-radius: 4px;
      border-style: solid;
      border-width: 1px;
      display: inline-flex;
      flex-direction: row;
      height: ${inputHeight}px;
      justify-content: center;
      padding: 0 ${spacing.xs}px 0 ${spacing.sm}px;

      &::placeholder {
        color: ${colors.gray45};
      }

      ${({ error }) =>
        !error &&
        css`
          &:hover,
          &[data-qa=${dataQa.hovered}] {
            border-color: ${colors.gray45};
          }
        `}

      &:focus-within,
      &[data-qa=${dataQa.focused}] {
        ${getFocus()};
      }

      &:disabled {
        ${disabledCss}
      }

      ${({ disabled }) => disabled && disabledCss}

      ${({ error }) =>
        error &&
        css`
          border-color: ${colors.red50};
        `}
    `