# All files / layouts/Horizontal Horizontal.js

0% Statements 0/26
0% Branches 0/17
0% Functions 0/3
0% Lines 0/19

    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

     import React from 'react';
    import PropTypes from 'prop-types';
    import styled from 'styled-components';
    import themeGet from 'extensions/themeGet';

    const normalize = size => {
      if (!size) {
        return 'large';
      }

      switch (size) {
        case 'xs':
        case 'extraSmall':
          return themeGet('spacing.extraSmall');
        case 'sm':
        case 'small':
          return themeGet('spacing.small');
        case 'lg':
        case 'large':
          return themeGet('spacing.large');
        case 'xl':
        case 'extraLarge':
          return themeGet('spacing.extraLarge');
        case 'md':
        case 'medium':
          return themeGet('spacing.medium');
        default:
          return size;
      }
    };

    /**
     * Horizontal is a simple layout tool that lays items out horizontally left-aligned
     * with spacing. It uses `display: flexbox;` to lay items out.
     */
    const Horizontal = styled.div`
      display: flex;
      & > * {
        margin: 0;
      }
      & > * + * {
        margin-left: ${({ spacing }) => normalize(spacing)};
      }
    `;

    Horizontal.defaultProps = {
      spacing: 'lg',
    };

    Horizontal.propTypes = {
      /**
       * The amount of space to put between items. Use xs, sm, md, lg, or xl.
       */
      spacing: PropTypes.string,
    };
    //@component
    export default Horizontal;