<section class="usage-guides">

<section class="overview">

## Overview

Cardinal’s spacers are used to standardize margin and padding across components and layouts through numerical and visual alignment. Spacers are also used to communicate systemic spacing to developers.

</section>

<hr>

## Usage

### Installation

<hr class="ta-shortDivider">

Please consult the <a href="http://dds.us.aegon.com/implementation" target="_blank" rel="noopener noreferrer">Implementation</a> section before continuing with component specific instructions.

Install @cardinal/spacing with `$ npm install --save @cardinal/spacing`

The source files included are written in <a href="http://sass-lang.com/" target="_blank" rel="noopener noreferrer">Sass</a>. Point the sass include-path to the node_modules directory and import with:

```javascript
@import "node_modules/@cardinal/spacing/spacing";
```

<section class="usage-guides">

### Classes

<hr class="ta-shortDivider">

<div class="table cardinalTable">

Specify margin or padding with:

| attribute     | value     |
| :---          |     ---:  |
| `m`           | margin    |
| `p`           | padding   |

Specify specific sides with:

| attribute     | value                             |
| :---          |     ---:                          |
| `t`           | margin-top or padding-top         |
| `b`           | margin-bottom or padding-bottom   |
| `l`           | margin-left or padding-left       |
| `r`           | margin-right or padding-right     |
| `x`           | both *-left and *-right           |
| `y`           | both *-top and *-bottom           |

Specify sizes with (computes to rem):

| attribute     | REM value   | PX value  |
| :---          |     ---:    |     ---:  |
| `auto`        | auto        | auto      |
| `none`        | 0rem / 0    | 0px / 0   |
| `xs`          | 0.25rem     | 4px       |
| `sm`          | 0.5rem      | 8px       |
| `md`          | 1rem        | 16px      |
| `lg`          | 1.5rem      | 24px      |
| `xl`          | 2rem        | 32px      |
| `2xl`         | 3rem        | 48px      |
| `3xl`         | 4rem        | 64px      |
| `4xl`         | 4.5rem      | 72px      |
| `5xl`         | 5rem        | 96px      |
| `6xl`         | 6rem        | 112px     |

</div>

#### Example:

```css
.-mb-none {
  margin-bottom: 0 !important;
}

.-mx-auto {
  margin-left: auto !important;
  margin-right: auto !important;
}

.-mr-4xl {
  margin-right: 4.5rem !important;
}

.-pt-sm {
  padding-top: 0.25rem !important;
}

.-py-3xl {
  padding-top: 4rem !important;
  padding-bottom: 4rem !important;
}

.-m-xs {
  margin: 0.25rem !important;
}
```

<!-- begin code snippet -->
<section class="code-example -mb-none -p-none -displayBlock">
<div class="-py-6xl -px-3xl">
  <h1 class="ta-blue500Bg -centerText"> live well today worry less tomorrow. </h1>
</div>
</section>
<!-- end begin code snippet -->

<!-- begin code example -->

```html
<div class="-py-6xl -px-3xl">
  <h1 class="ta-blue500Bg -centerText"> live well today worry less tomorrow. </h1>
</div>
```
<!-- end begin code example -->

<div class="note">

  <p><span>Note:</span> Margin should never be declared outside of these utilities. This is meant to help create consistency and avoid magic numbers.</p>

</div>

</section>
</section>

<section class="usage-guides">

### Responsive Classes

<hr class="ta-shortDivider">

Responsive classes utilize -rsp:

<h4 class="-mt-md"> Example: </h4>

```scss
.-mr-rsp-4xl {
  margin-right: 4.5rem !important;
}

@media (min-width: 0) and (max-width: 599px) {
  .-mr-rsp-4xl {
    margin-right: 3.75rem !important;
  }
}

.-pt-rsp-sm {
  padding-top: 0.5rem !important;
}

@media (min-width: 0) and (max-width: 599px) {
  .-pt-rsp-sm {
    padding-top: 0.5rem !important;
  }
}

.-py-rsp-3xl {
  padding-top: 4rem !important;
  padding-bottom: 4rem !important;
}

@media (min-width: 0) and (max-width: 599px) {
  .-py-rsp-3xl {
    padding-top: 3.3333333333rem !important;
    padding-bottom: 3.3333333333rem !important;
  }
}

.-mt-rsp-xs {
  margin-top: 0.25rem !important;
}

@media (min-width: 0) and (max-width: 599px) {
  .-mt-rsp-xs {
    margin-top: 0.25rem !important;
  }
}
```
<!-- begin code example -->
<section class="code-example -mb-none -p-none -displayBlock">
<div class="ta-fullContainer -px-rsp-6xl -py-rsp-5xl">
    <h1 class="ta-blue100Bg -centerText"> celebrate every moment. </h1>
</div>
</section>
<!-- end begin code example -->

<!-- begin code snippet -->
```html
<div class="ta-fullContainer -px-rsp-6xl -py-rsp-3xl">
    <h1 class="ta-blue100Bg -centerText"> celebrate every moment. </h1>
</div>
```
<!-- begin code snippet -->

<div class="note">

  <p><span>Note:</span> Responsive classes do not exist with 0, none or auto. Use none responsive class to achieve desiried results.</p>

</div>

</section>

<section class="usage-guides">

### Sass Variables

<hr class="ta-shortDivider">

```scss
//Spacing Variables
$base-spacing:    1rem !default;
$spacing-none:    0 !default;

$spacing-xs:      ($base-spacing * 0.25) !default;
$spacing-sm:      ($base-spacing * 0.5) !default;
$spacing-md:      ($base-spacing * 1) !default;
$spacing-lg:      ($base-spacing * 1.5) !default;
$spacing-xl:      ($base-spacing * 2) !default;
$spacing-2xl:     ($base-spacing * 3) !default;
$spacing-3xl:     ($base-spacing * 4) !default;
$spacing-4xl:     ($base-spacing * 4.5) !default;
$spacing-5xl:     ($base-spacing * 5) !default;
$spacing-6xl:     ($base-spacing * 6) !default;

//Small Screen Spacing
$sm-screen-spacing-xs:   $spacing-xs !default;
$sm-screen-spacing-sm:   $spacing-sm !default;
$sm-screen-spacing-md:   ($spacing-md  / 1.2) !default;
$sm-screen-spacing-lg:   ($spacing-lg  / 1.2) !default;
$sm-screen-spacing-xl:   ($spacing-xl  / 1.2) !default;
$sm-screen-spacing-2xl:  ($spacing-2xl / 1.2) !default;
$sm-screen-spacing-3xl:  ($spacing-3xl / 1.2) !default;
$sm-screen-spacing-4xl:  ($spacing-4xl / 1.2) !default;
$sm-screen-spacing-5xl:  ($spacing-5xl / 1.2) !default;
$sm-screen-spacing-6xl:  ($spacing-6xl / 1.2) !default;
```

</section>
