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

100% Statements 25/25
92.85% Branches 26/28
100% Functions 5/5
100% Lines 23/23

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
    130
    131
    132
    133
    13430x
    30x

    30x

    30x
    30x

    30x

    30x

    30x

    30x
    11x

    30x
    264x
    264x

    264x

    30x

    30x

    28x

    30x

    28x

    30x
    144x

    30x

    30x
     import styled, { css } from 'styled-components'
    import { StyledRequiredContainer } from '../Required/Required.styles'
    import { TypographyProps } from '../Typography'
    import {
      getTypographyIntent,
      semiboldRules,
      StyledTypography,
    } from '../Typography/Typography.styles'
    import { colors } from '../_styles/colors'
    import { spacing } from '../_styles/spacing'

    export const StyledH1 = styled.h1`
      color: ${colors.gray15};
      ${getTypographyIntent('h1')}
      margin: 0;
    `
    export const StyledH2 = styled.h2`
      color: ${colors.gray15};
      ${getTypographyIntent('h2')}
      margin: 0;
    `
    export const StyledH3 = styled.h3`
      color: ${colors.gray15};
      ${getTypographyIntent('h3')}
      margin: 0;
    `

    const topMarginRules = () => {
      return css`
        & + &,
        p + &,
        ul + & {
          margin-top: ${spacing.lg}px;
        }
      `
    }

    // Should this be on Typography? body | label
    /** Small icons align with font and line height */
    export function getSmallIconBodyTextRules() {
      const space = spacing.xs
      const spaceWhenTouch = spacing.sm

      return css`
        & > [data-qa^='ci'] {
          height: 16px;
          width: 16px;
          vertical-align: middle;
          margin-left: ${space}px;

          &[tabindex='0'] {
            margin-left: ${spaceWhenTouch}px;
          }

          &:first-child {
            margin-left: 0;
            margin-right: ${space}px;
            vertical-align: sub;

            &[tabindex='0'] {
              margin-right: ${spaceWhenTouch}px;
            }
          }
        }
      `
    }

    export const StyledP = styled.p`
      color: ${colors.gray15};
      ${getTypographyIntent('body')}
      ${topMarginRules}
      ${semiboldRules}
    `
    export const StyledUL = styled.ul`
      color: ${colors.gray15};
      margin: 0;
      padding: 0;
      ${getTypographyIntent('body')}
      ${topMarginRules}

      padding-left: ${spacing.lg}px;

      & > li {
        list-style-type: disc;
      }
    `

    function enforceLabelTypography(props: TypographyProps) {
      return {
        as: props.as || 'label',
        intent: 'label',
      }
    }

    export const StyledLabel = styled(StyledTypography).attrs(
      enforceLabelTypography
    )`
      ${({ block = false }) => block && `display: block;`}
      ${getSmallIconBodyTextRules}

      > ${StyledRequiredContainer} {
        margin-left: ${spacing.xs}px;
        vertical-align: top;
      }
    `

    /**
     * An unstyled `button`, browser reset
     */
    export function getUnstyledButton() {
      return css`
        border: none;
        background: none;
        font-family: inherit;
        font-size: 100%;
        line-height: 1.15;
        margin: 0;
        padding: 0;
        text-transform: none;
        -webkit-appearance: button;
      `
    }
    /**
     * An unstyled `button`, browser reset
     */
    export const StyledUnstyledButton = styled.button`
      ${getUnstyledButton}
    `

    /**
     * An a styled component a
     */
    export const StyledAnchor = styled.a``