Susy 3.0.8

Syntax Normalization

Susy is divided into two layers: “Su” provides the core math functions with a stripped-down syntax, while “Susy” adds global settings, shorthand syntax, and other helpers. Each setting (e.g. span, location, columns, spread, etc.) has a single canonical syntax in Su.

This normalization module helps translate between those layers, transforming parsed Susy input into values that Su will understand.

@function susy-normalize()

Normalize the values in a configuration map. In addition to the global $susy properties, this map can include local span-related information, like span and location.

Normalization does not check that values are valid, which will happen in the Su math layer. These functions merely look for known Susy syntax – returning a map with those shorthand values converted into low-level data for Su. For example span: all and location: first will be converted into specific numbers.

Parameters & Return

$config: (map)

Map of Susy configuration settings to normalize. See $susy and susy-parse() documentation for details.

$context: null (map | null)

Map of Susy configuration settings to use as global reference, or null to use global settings.

@return (map)

Map of Susy configuration settings, with all values normalized for Su math functions.

Related

@function susy-parse()

Used By

@function susy-compile()

@function susy-normalize-span()

Normalize span shorthand for Su. Su span syntax allows an explicit length (e.g. 3em), unitless column-span number (e.g. 3 columns), or an explicit list of columns (e.g. (3 5 8)).

Susy span syntax also allows the all keyword, which will be converted to a slice of the context in normalization.

Parameters & Return

$span: (number | list | 'all')

Span value to normalize.

$columns: (list)

Normalized list of columns in the grid

@return (number | list)

Number or list value for $span

Used By

@function susy-normalize()

@function susy-normalize-columns()

Normalize column shorthand for Su. Su column syntax only allows column lists (e.g. 120px 1 1 1 120px).

Susy span syntax also allows a unitless slice number (e.g of 5), which will be converted to a slice of the context in normalization.

Parameters & Return

$columns: (list | integer)

List of available columns, or unitless integer representing a slice of the available context.

$context: null (map | null)

Map of Susy configuration settings to use as global reference, or null to access global settings.

@return (list)

Columns list value, normalized for Su input.

@error

when attempting to access a slice of asymmetrical context

Requires

@function susy-settings()

@function _susy-flatten() [private]

@function susy-repeat()

@function _susy-error() [private]

Used By

@function susy-normalize()

@function susy-normalize-spread()

Normalize spread shorthand for Su. Su spread syntax only allows the numbers -1, 0, or 1 – representing the number of gutters covered in relation to columns spanned.

Susy spread syntax also allows keywords for each value – narrow for -1, wide for 0, or wider for 1 – which will be converted to their respective integers in normalization.

Parameters & Return

$spread: (0 | 1 | -1 | 'narrow' | 'wide' | 'wider')

Spread across adjacent gutters, relative to a column-count — either narrow (-1), wide (0), or wider (1)

@return (number)

Numeric value for $spread

Used By

@function susy-normalize()

@function susy-normalize-location()

Normalize location shorthand for Su. Su location syntax requires the (1-indexed) number for a column.

Susy also allows the first and last keywords, where first is always 1, and last is calculated based on span and column values. Both keywords are normalized into an integer index in normalization.

Parameters & Return

$span: (number)

Number of grid-columns to be spanned

$location: (integer | 'first' | 'last')

Starting (1-indexed) column position of a span, or a named location keyword.

$columns: (list)

Already-normalized list of columns in the grid.

@return (integer)

Numeric value for $location

Used By

@function susy-normalize()