# All files / src/Calendar Calendar.styles.ts

96.87% Statements 31/32
66.66% Branches 38/57
100% Functions 1/1
96.15% Lines 25/26

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
    121
    122
    123
    124
    125
    126
    127
    128
    129
    13010x
    10x
    10x

    10x
    10x
    10x

    10x

    10x

    10x

    10x

    10x

    10x

    10x

    10x

    631x
    631x
    631x
    631x
    631x
    631x

    631x

    631x
    2x

    629x

    10x

     import styled, { css } from 'styled-components'
    import { Button } from '../Button/Button'
    import {
      getTypographyIntent,
      typographyWeights,
    } from '../Typography/Typography.styles'
    import { borderRadius } from '../_styles/borderRadius'
    import { colors } from '../_styles/colors'
    import { spacing } from '../_styles/spacing'

    const cellSize = 36 // TODO one-off size

    export const StyledContainer = styled.div`
      ${getTypographyIntent('small')};

      display: inline-flex;
      flex-direction: column;
      padding: ${spacing.lg}px ${spacing.md}px ${spacing.md}px;
    `

    export const StyledPaginator = styled(Button)`
      flex: 0 0 auto;
    `

    export const StyledSelect = styled.div`
      display: inline-flex;
      flex: 1 1 0;
      margin-left: ${spacing.sm}px;

      // TODO hack to ensure labels don't get cut off in narrow selects
      > div {
        font-size: 12px;
      }
    `

    export const StyledNavigation = styled.div`
      display: inline-flex;
      margin-bottom: ${spacing.sm}px;

      ${StyledPaginator} + ${StyledSelect}, ${StyledSelect} + ${StyledPaginator} {
        margin-left: ${spacing.sm}px;
      }
    `

    export const StyledCell = styled.div`
      align-items: center;
      display: inline-flex;
      height: ${cellSize}px;
      justify-content: center;
      width: ${cellSize}px;
    `

    export const StyledDayHeaderCell = styled(StyledCell)`
      cursor: default;
      font-weight: ${typographyWeights.semibold};
    `

    export const StyledDayCell = styled(StyledCell)<{
      $disabled: boolean
      $selected: boolean
      $isCurrentMonth: boolean
      $isToday: boolean
      $isRangeStart: boolean
      $isRangeEnd: boolean
    }>`
      ${({
        $disabled = false,
        $selected = false,
        $isCurrentMonth = true,
        $isToday = false,
        $isRangeStart = false,
        $isRangeEnd = false,
      }) => {
        Iif ($disabled) {
          return css`
            background-color: ${colors.gray94};
            color: ${$isCurrentMonth ? colors.gray45 : colors.gray70};
            font-weight: ${$isToday && typographyWeights.bold};
            pointer-events: none;
          `
        } else if ($selected) {
          return css`
            background-color: ${$isRangeStart || $isRangeEnd
              ? colors.blue40
              : colors.blue50};
            border-top-left-radius: ${$isRangeStart ? borderRadius.md : 0}px;
            border-bottom-left-radius: ${$isRangeStart ? borderRadius.md : 0}px;
            border-top-right-radius: ${$isRangeEnd ? borderRadius.md : 0}px;
            border-bottom-right-radius: ${$isRangeEnd ? borderRadius.md : 0}px;
            color: ${colors.white};
            font-weight: ${typographyWeights.semibold};
            cursor: pointer;
          `
        }

        return css`
          color: ${!$isCurrentMonth && colors.gray45};
          cursor: pointer;
          font-weight: ${$isToday && typographyWeights.bold};

          &:hover {
            background-color: ${colors.blue96};
            border-radius: ${borderRadius.md}px;
          }
        `
      }}
    `

    export const StyledWeekRow = styled.div`
      display: inline-flex;
      padding-bottom: 2px; // TODO one-off size
      user-select: none;

      &:last-child {
        padding-bottom: 0;
      }

      ${StyledCell} {
        &:first-child {
          border-top-left-radius: ${borderRadius.md}px;
          border-bottom-left-radius: ${borderRadius.md}px;
        }

        &:last-child {
          border-top-right-radius: ${borderRadius.md}px;
          border-bottom-right-radius: ${borderRadius.md}px;
        }
      }
    `