# All files / components/Alert/styles AlertIcon.js

0% Statements 0/38
0% Branches 0/15
0% Functions 0/6
0% Lines 0/26

    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

     import styled from 'styled-components';
    import get from 'extensions/themeGet';
    import icons from 'components/Icon/icons';
    import AlertContent from './AlertContent';

    export const SIZE = '31px';
    const SMALL_SIZE = '18px';

    const getAlertIcon = size => styled.i`
      width: ${size};
      height: ${size};
      display: inline-block;
      border-color: inherit;

      &::before {
        content: ${({ type }) => {
          switch (type) {
            case 'success':
              return `"${icons('checkmark')}"`;
            case 'error':
              return '"!"';
            default:
              return '"i"';
          }
        }};

        box-sizing: border-box;
        border-width: ${get('thicknesses.normal')};
        border-style: solid;
        border-color: inherit;

        background: ${get('colors.background.default')};
        width: ${size};
        height: ${size};
        display: inline-block;
        line-height: ${size};
        font-family: ${props => {
          switch (props.type) {
            case 'success':
              return get('fonts.icon');
            case 'error':
            default:
              return get('fonts.brand');
          }
        }};
        font-weight: ${props => {
          switch (props.type) {
            case 'success':
              return 'normal';
            default:
              return 500;
          }
        }};
        border-color: ${({ theme, type }) => {
          switch (type) {
            case 'success':
              return get('colors.positive.border');
            case 'error':
              return get('colors.negative.border');
            default:
              return get('colors.primary.border');
          }
        }};
        text-align: center;
        border-radius: 100%;
        font-size: 22px;
        position: absolute;
        font-style: normal;
      }
    `;

    const AlertIcon = getAlertIcon(SIZE);
    AlertIcon.Small = getAlertIcon(SMALL_SIZE).extend`
      &::before {
        font-size: 14px;
      }

      ${AlertContent.Small} > & {
        margin: 0 5px auto 0;
      }
    `;

    export default AlertIcon;