Support

functions

[private] pos-parse-offsets

@function pos-parse-offsets($args) { ... }
View source

Description

This is the workhorse function, taking a list of offset keywords and values and parsing them to an object of offset values.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$args

A list of offset keywords and values

List none

Returns

A map of offsets to be rendered as CSS properties

Map

Throws

  • $pos-unsupported-value-error

  • $pos-invalid-value-error

  • $pos-missing-value-error

  • $pos-invalid-keyword-error

Author

  • Pedr Browne

[private] pos-parse-value

@function pos-parse-value($value) { ... }
View source

Description

Determine whether to use default or user-supplied parsing

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

Value to use for $position.

String none

Returns

Was the position valid?

Bool

Author

  • Pedr Browne

[private] pos-position-is-valid

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

Description

Determine if the value is a valid value for position

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

Value to use for $position.

String none

Returns

Was the position valid?

Bool

Author

  • Pedr Browne

[private] pos-is-keyword

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

Description

Determine if the value is a supported keyword.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

Item to be checked

String none

Returns

Was the item a supported keyword?

Bool

Author

  • Pedr Browne

[private] pos-parse-offsets-for-always-valueless

@function pos-parse-offsets-for-always-valueless($offsets, $item) { ... }
View source

Description

Parse keyword that is always valueless to offset values.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$offsets

Map of offsets to adjust for the given keyword.

Map none
$item

Offset keyword.

String none

Returns

Adjusted Offsets

Map

Author

  • Pedr Browne

[private] pos-parse-offsets-for-always-value

@function pos-parse-offsets-for-always-value($offsets, $item, $item) { ... }
View source

Description

Parse keyword that always has a value and its value to offset values.

Parameters

parameter Name parameter Description parameter Type parameter Default value
$offsets

Map of offsets to adjust for the given keyword and value.

Map none
$item

Offset keyword.

String none
$item

Offset value.

String none

Returns

Adjusted Offsets

Map

Author

  • Pedr Browne

[private] pos-orientation-for-support-valueless

@function pos-orientation-for-support-valueless($item) { ... }
View source

Description

Get the orientation for a valueless keyword

Parameters

parameter Name parameter Description parameter Type parameter Default value
$item

An item from $pos-support-valueless list

String none

Returns

The keyword's orientation (vertical | horizontal)

String

Author

  • Pedr Browne

[private] pos-throw-error

@function pos-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 $pos-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] pos-default-parse-value-filter

@function pos-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

Throws

  • $pos-unsupported-value-error

Author

  • Pedr Browne

[private] pos-is-valid-value

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

Description

Was the value a valid one; either united, supported unitless or calc

Parameters

parameter Name parameter Description parameter Type parameter Default value
$value

The value to be checked

String none

Returns

Was the value valid?

Bool

Author

  • Pedr Browne

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

@function pos-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] pos-is-valid-unitless

@function pos-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] pos-is-calc

@function pos-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

mixins

[private] pos-render

@mixin pos-render() { ... }
View source

Description

Render offsets to CSS properties.

@param {String} $position The position - One of absolute | fixed | relative | static . @param {List} $args A map of offset keywords and values.

Parameters

None.

Author

  • Pedr Browne

variables

[private] pos-accepted-position-values

$pos-accepted-position-values: fixed absolute relative static;
View source

Description

Values accepted for position.

Author

  • Pedr Browne

[private] pos-always-valueless

$pos-always-valueless: fill fill-h fill-v;
View source

Description

Keywords that are never followed by a value

Author

  • Pedr Browne

[private] pos-always-value

$pos-always-value: offset offset-h offset-v all;
View source

Description

Keywords that are always followed by a value

Author

  • Pedr Browne

[private] pos-support-valueless

$pos-support-valueless: left right top bottom;
View source

Description

Keywords that are sometimes followed by a value

Author

  • Pedr Browne

[private] pos-keywords

$pos-keywords: join($pos-support-valueless, join($pos-always-valueless, $pos-always-value));
View source

Description

All Keywords

Author

  • Pedr Browne

[private] pos-valid-unitless-values

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

Description

Values without a unit that are accepted without being parsed

Author

  • Pedr Browne

[private] pos-missing-value-error

$pos-missing-value-error: "Missing Value Error";
View source

Description

Error thrown when an item that needs a value has no following value

Author

  • Pedr Browne

[private] pos-unsupported-value-error

$pos-unsupported-value-error: "Unsupported Value Error";
View source

Description

Error thrown when an item which doesn't support a value has a value following it

Author

  • Pedr Browne

[private] pos-invalid-keyword-error

$pos-invalid-keyword-error: "Invalid Keyword Error";
View source

Description

Error thrown when an unsupported keyword is used

Author

  • Pedr Browne

[private] pos-invalid-value-error

$pos-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

position

@mixin position($position, $args: ()) { ... }
View source

Parameters

parameter Name parameter Description parameter Type parameter Default value
$position

One of absolute | relative | fixed

String none
$args

A list of offset keywords and values. Some keywords require a following value, some do not accept a following value, and for some the value is optional. The possible values are:

  • top, bottom, left, and right If one of these keywords is followed by a value, the offset will be set to that value. If no value follows, the offset will be set to zero.
  • offset | all | offset-h | offset-v All these values require a value. offset and all (which is just an alias of offset) will set all four offsets ('top', 'bottom', 'left' and right) to the following value. offset-h will set the left and right offsets to the following value, and offset-v will set the top and bottom offsets to the following value.
  • fill, fill-h and fill-v do not take a following value. fill will set all offsets to zero. fill-h will set the left and right offsets to zero, and fill-v will set the top and bottom offsets to zero.

    Values are evaluated LTR with later values overriding earlier values.

List ()

Example

Usage

 .element {
   @include position(absolute, left top 10px);
 }

CSS Output

 .element {
   position: absolute;
   left: 0;
   top: 10px;
 }

Throws

  • Argument Error

Author

  • Pedr Browne

absolute

@mixin absolute($args) { ... }
View source

Description

Shorthand for @include position(absolute, args).

Parameters

parameter Name parameter Description parameter Type parameter Default value
$args

A list of offset keywords and values.

List none

See

Author

  • Pedr Browne

fixed

@mixin fixed($args) { ... }
View source

Description

Shorthand for @include position(absolute, args).

Parameters

parameter Name parameter Description parameter Type parameter Default value
$args

A list of offset keywords and values.

List none

See

Author

  • Pedr Browne

relative

@mixin relative($args) { ... }
View source

Description

Shorthand for @include position(absolute, args).

Parameters

parameter Name parameter Description parameter Type parameter Default value
$args

A list of offset keywords and values.

List none

See

Author

  • Pedr Browne

static

@mixin static() { ... }
View source

Description

Shorthand for @include position(static).

Parameters

None.

See

Author

  • Pedr Browne