Support

functions

[private] box-process-arbitrary-value

@function box-process-arbitrary-value($property, $value) { ... }
View source

Description

Process a property and value, discovering if the property is supported and whether it accepts singular or multiple values.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$property

The box property

String — none
$value

The box property value

String — none

Returns

The processed value

String

Throws

  • $box-argument-count-error

  • $box-invalid-property-error

Author

  • Pedr Browne

[private] box-process-single-value

@function box-process-single-value($value) { ... }
View source

Description

Check if the $value is already valid and process it if not

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The value to process

@param {String} $value The orientation of that value (horizontal | vertical)

String — none

Author

  • Pedr Browne

[private] box-process-multiple-values

@function box-process-multiple-values($values) { ... }
View source

Description

Check if multiple $values are already valid and process any that are not.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$values

The values to process

String — none

Returns

The processed values

Map

Author

  • Pedr Browne

[private] box-process-to-four-values

@function box-process-to-four-values($values) { ... }
View source

Description

Expand values to 4 separate values to streamline processing.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$values

The values to process

String — none

Returns

The expanded values

String

Author

  • Pedr Browne

[private] box-optimise-four-values

@function box-optimise-four-values($values) { ... }
View source

Description

Optimise four values down to as few values as possible.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$values

The values to process

String — none

Returns

The optimised values

String

Author

  • Pedr Browne

[private] box-is-valid-property

@function box-is-valid-property($property) { ... }
View source

Description

Is the supplied property a property that is supported?

Parameters

parameter Name parameter Description parameter Type parameter Default value
$property

The property

String — none

Returns

Is the property valid?

Bool

Author

  • Pedr Browne

[private] box-is-single-property

@function box-is-single-property($property) { ... }
View source

Description

Does the supplied property take a single value?

Parameters

parameter Name parameter Description parameter Type parameter Default value
$property

The property

String — none

Returns

Does the property accept a single value?

Bool

Author

  • Pedr Browne

[private] box-orientation-of-property

@function box-orientation-of-property($property) { ... }
View source

Description

Is the property related to the horizontal or vertical axis?

Parameters

parameter Name parameter Description parameter Type parameter Default value
$property

The property

String — none

Returns

The orientation of the property (horizontal | vertical)

String

Author

  • Pedr Browne

[private] box-sides-for-orientation

@function box-sides-for-orientation($orientation) { ... }
View source

Description

Which sides comprise this orientation?

Parameters

parameter Name parameter Description parameter Type parameter Default value
$orientation

The orientation vertical | horizontal

String — none

Returns

The sides.

List

Author

  • Pedr Browne

[private] box-throw-error

@function box-throw-error($error, $message) { ... }
View source

Description

By default, this function will throw a Sass error, but allows errors to be stopped during testing, with the error saved to $box-last-error instead so tests can check it was thrown.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$error

The name of the error

String — none
$message

The error message

String — none

Returns

A map of offsets to be rendered as CSS properties

Map

Author

  • Pedr Browne

[private] box-default-parse-value-filter

@function box-default-parse-value-filter($value, $The) { ... }
View source

Description

Overridable hook to handle unrecognised values. By default it will throw an error.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

An unrecognised value

String — none
$The

orientation of the value's keyword (horizontal | vertical)

Orientation — none

Returns

Null

Throws

  • $box-unsupported-value-error

Author

  • Pedr Browne

[private] box-is-valid-value

@function box-is-valid-value($value) { ... }
View source

Description

Is this valid already valid or does it need to be parsed?

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The value to be checked

String — none

Returns

Does the value need to be pa

Bool

Author

  • Pedr Browne

[private] box-is-number-with-unit

@function box-is-number-with-unit($value) { ... }
View source

Description

Determine if the value is a valid number with a unit

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

Value to be checked

String — none

Returns

Was the value number with a unit?

Bool

Author

  • Pedr Browne

[private] box-is-valid-unitless

@function box-is-valid-unitless($value) { ... }
View source

Description

Determine if the value is a valid unitless value.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

Value to be checked

String — none

Returns

Was the value unitless?

Bool

Author

  • Pedr Browne

[private] box-is-calc

@function box-is-calc($value) { ... }
View source

Description

Determine if the value is a calc() expression.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

Value to be checked

String — none

Returns

Was the value a calc expression?

Bool

Author

  • Pedr Browne

[private] is-even

@function is-even($value) { ... }
View source

Description

Check a number to see if it is even.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The value to check.

Number — none

Returns

Is the number even?

Bool

Author

  • Pedr Browne

variables

[private] box-orientations

$box-orientations: horizontal vertical;
View source

Description

Possible orientations for each box property

Author

  • Pedr Browne

[private] box-valid-unitless-values

$box-valid-unitless-values: auto initial inherit 0;
View source

Description

Values without a unit that are accepted without being parsed

Author

  • Pedr Browne

[private] box-valid-multiple-properties

$box-valid-multiple-properties: margin padding border;
View source

Description

Valid properties that accept multiple values

Author

  • Pedr Browne

[private] box-valid-single-properties

$box-valid-single-properties: margin-top
                              margin-right
                              margin-bottom
                              margin-left
                              padding-top
                              padding-right
                              padding-bottom
                              padding-left
                              border-top
                              border-right
                              border-bottom
                              border-left;
View source

Description

Valid properties that accept a single value

Author

  • Pedr Browne

[private] box-valid-properties

$box-valid-properties: join($box-valid-multiple-properties, $box-valid-single-properties);
View source

Description

All valid properties

Author

  • Pedr Browne

[private] box-argument-count-error

$box-argument-count-error: "Argument Count Error";
View source

Description

Error thrown when too many arguments are supplied to a property

Author

  • Pedr Browne

[private] box-invalid-property-error

$box-invalid-property-error: "Invalid Property Error";
View source

Description

Error thrown when a property is unsupported

Author

  • Pedr Browne

[private] box-invalid-value-error

$box-invalid-value-error: "Invalid Value Error";
View source

Description

Error thrown when an item is followed by an invalid value

Author

  • Pedr Browne

API

mixins

box

@mixin box($map) { ... }
View source

Description

Render the supplied box-properties.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$map

Map of box properties. The following properties / keys are supported:

  • margin
  • margin-top
  • margin-right
  • margin-bottom
  • margin-left
  • border
  • border-top
  • border-right
  • border-bottom
  • border-left
  • padding
  • padding-top
  • padding-right
  • padding-bottom
  • padding-left
Map — none

Example

Usage

 .element {
   @include box(
     (
       margin: 5px,
       padding: 20px,
       padding-left: 2px,
       border: 2px 3px 2px
     )
   );
 }

CSS Output

 .element {
   margin: 5px;
   padding: 20px;
   padding-left: 2px;
   border: 2px 3px 2px;
 }

Author

  • Pedr Browne

h-margins

@mixin h-margins($value) { ... }
View source

Description

Render left and right margins with the supplied value.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The value(s) for the margins.

String — none

Author

  • Pedr Browne

v-margins

@mixin v-margins($values) { ... }
View source

Description

Render top and bottom margins with the supplied value.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$values

The value(s) for the margins.

String — none

Author

  • Pedr Browne

h-borders

@mixin h-borders($values) { ... }
View source

Description

Render left and right borders with the supplied value.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$values

The value(s) for the borders.

String — none

Author

  • Pedr Browne

v-borders

@mixin v-borders($values) { ... }
View source

Description

Render top and bottom borders with the supplied value.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$values

The value(s) for the borders.

String — none

Author

  • Pedr Browne

h-padding

@mixin h-padding($values) { ... }
View source

Description

Render top and bottom padding with the supplied value.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$values

The value(s) for the padding.

String — none

Author

  • Pedr Browne

v-padding

@mixin v-padding($values) { ... }
View source

Description

Render left and right padding with the supplied value.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$values

The value(s) for the padding.

String — none

Author

  • Pedr Browne

margin

@mixin margin($value) { ... }
View source

Description

Render the supplied margin.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The margin value.

String — none

Author

  • Pedr Browne

margin-top

@mixin margin-top($value) { ... }
View source

Description

Render the supplied margin-top.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The margin-top value.

String — none

Author

  • Pedr Browne

margin-right

@mixin margin-right($value) { ... }
View source

Description

Render the supplied margin-right.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The margin-right value.

String — none

Author

  • Pedr Browne

margin-bottom

@mixin margin-bottom($value) { ... }
View source

Description

Render the supplied margin-bottom.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The margin-bottom value.

String — none

Author

  • Pedr Browne

margin-left

@mixin margin-left($value) { ... }
View source

Description

Render the supplied margin-left.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The margin-left value.

String — none

Author

  • Pedr Browne

padding

@mixin padding($value) { ... }
View source

Description

Render the supplied padding.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The padding value.

String — none

Author

  • Pedr Browne

padding-top

@mixin padding-top($value) { ... }
View source

Description

Render the supplied padding-top.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The padding-top value.

String — none

Author

  • Pedr Browne

padding-right

@mixin padding-right($value) { ... }
View source

Description

Render the supplied padding-right.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The padding-right value.

String — none

Author

  • Pedr Browne

padding-bottom

@mixin padding-bottom($value) { ... }
View source

Description

Render the supplied padding-bottom.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The padding-bottom value.

String — none

Author

  • Pedr Browne

padding-left

@mixin padding-left($value) { ... }
View source

Description

Render the supplied padding-left.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The padding-left value.

String — none

Author

  • Pedr Browne

border

@mixin border($value) { ... }
View source

Description

Render the supplied border.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The border value.

String — none

Author

  • Pedr Browne

border-top

@mixin border-top($value) { ... }
View source

Description

Render the supplied border-top.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The border-top value.

String — none

Author

  • Pedr Browne

border-right

@mixin border-right($value) { ... }
View source

Description

Render the supplied border-right.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The border-right value.

String — none

Author

  • Pedr Browne

border-bottom

@mixin border-bottom($value) { ... }
View source

Description

Render the supplied border-bottom.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The border-bottom value.

String — none

Author

  • Pedr Browne

border-left

@mixin border-left($value) { ... }
View source

Description

Render the supplied border-left.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The border-left value.

String — none

Author

  • Pedr Browne

opposing-properties

@mixin opposing-properties($property, $orientation, $values) { ... }
View source

Description

Render a pair of box properties for the supplied orientation.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$property

The name of the box-property ( margin | padding | border )

String — none
$orientation

The orientation of the property-pair ( horizontal | vertical )

String — none
$values

The values for the property-pair

String — none

Throws

  • $box-argument-count-error

Author

  • Pedr Browne