helpers
functions
strip-units
@function strip-units($var) { ... }
View sourceDescription
Get unitless value of $var
.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | —none | Measure | —none |
Returns
Number
Example
strip-units(100px) // 100
strip-units(18em) // 18
Used by
- [function]
is-measure-negative
- [function]
is-measure-positive
General
functions
is-bool
@function is-bool($var) { ... }
View sourceDescription
Tests whether $var
is bool.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | possible bool type variable | Any | —none |
Returns
Bool
Example
is-bool(true) //returns true
is-bool(false) //returns true
is-bool(test) //returns false
is-bool(1) //returns false
is-bool(null) //returns false
is-color
@function is-color($var) { ... }
View sourceDescription
Tests whether $var
is color.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | possible color type variable | Any | —none |
Returns
Bool
Example
is-color(#333) //returns true
is-color(black) //returns true
is-color(test) //returns false
is-empty
@function is-empty($var) { ... }
View sourceDescription
Tests whether $var
is empty.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | possible empty variable | Any | —none |
Returns
Bool
Example
is-empty('') //returns true
is-empty(()) //returns true
is-empty('test') //returns false
is-float
@function is-float($var) { ... }
View sourceDescription
Tests whether $var
is float.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | possible float number type variable | Any | —none |
Returns
Bool
Example
is-float(-1.5) //returns true
is-float(1.5) //returns true
is-float(1) //returns false
is-float(1em) //returns false
is-float(0) //returns false
Requires
- [function]
is-number
- [function]
is-integer
is-integer
@function is-integer($var) { ... }
View sourceDescription
Tests whether $var
is integer.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | possible integer type variable | Any | —none |
Returns
Bool
Example
is-integer(1) //returns true
is-integer(0) //returns true
is-integer(-50) //returns true
is-integer(1.5) //returns false
is-integer(1em) //returns false
Requires
- [function]
is-number
Used by
- [function]
is-float
is-list
@function is-list($var) { ... }
View sourceDescription
Tests whether $var
is list.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | possible list type variable | Any | —none |
Returns
Bool
Example
is-list(a b) //returns true
is-list(1 2 3) //returns true
is-list((test, test)) //returns true
is-list(test) //returns false
is-list(1) //returns false
is-map
@function is-map($var) { ... }
View sourceDescription
Tests whether $var
is map.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | possible map type variable | Any | —none |
Returns
Bool
Example
is-map(a: 1, b: 2) //returns true
is-map(1 2 3) //returns false
is-map((test, test)) //returns false
is-map(test) //returns false
is-map(1) //returns false
is-measure-negative
@function is-measure-negative($var) { ... }
View sourceDescription
Tests whether $var
is a negative measure.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | possible negative measure type variable | Any | —none |
Returns
Bool
Example
is-measure-negative(-10em) //returns true
is-measure-negative(0px) //returns false
is-measure-negative(0) //returns false
is-measure-negative(777rem) //returns false
Requires
- [function]
is-measure
- [function]
is-negative
- [function]
strip-units
is-measure-positive
@function is-measure-positive($var) { ... }
View sourceDescription
Tests whether $var
is a positive measure.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | possible positive measure type variable | Any | —none |
Returns
Bool
Example
is-measure-positive(10px) //returns true
is-measure-positive(0px) //returns false
is-measure-positive(0) //returns false
is-measure-positive(-777px) //returns false
Requires
- [function]
is-measure
- [function]
is-positive
- [function]
strip-units
is-measure
@function is-measure($var) { ... }
View sourceDescription
Tests whether $var
is measure.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | possible measure type variable | Any | —none |
Returns
Bool
Example
is-measure(1px) //returns true
is-measure(5em) //returns true
is-measure(5) //returns false
is-measure(test) //returns false
is-measure(em) //returns false
Requires
- [variable]
sv-units
Used by
- [function]
is-measure-negative
- [function]
is-measure-positive
is-negative
@function is-negative($value) { ... }
View sourceDescription
Tests whether $var
is negative.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$value | possible negative type variable | Any | —none |
Returns
Bool
Example
is-negative(-5) //returns true
is-negative(-10px) //returns false
is-negative(300) //returns false
is-negative('test') //returns false
is-negative(0) //returns false
Requires
- [function]
is-number
Used by
- [function]
is-measure-negative
is-null
@function is-null($var) { ... }
View sourceDescription
Tests whether $var
is bool.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | possible null type variable | Any | —none |
Returns
Bool
Example
is-null(null) //returns true
is-null(false) //returns false
is-null(0) //returns false
is-null('hello') //returns false
is-null(113) //returns false
is-number
@function is-number($var) { ... }
View sourceDescription
Tests whether $var
is number.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | possible number type variable | Any | —none |
Returns
Bool
Example
is-number(1) //returns true
is-number('1') //returns false
is-number(1em) //returns false
is-number('sassy-validation') //returns false
Used by
- [function]
is-float
- [function]
is-integer
- [function]
is-negative
- [function]
is-positive
is-positive
@function is-positive($var) { ... }
View sourceDescription
Tests whether $var
is positive.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | possible positive type variable | Any | —none |
Returns
Bool
Example
is-positive(1) //returns true
is-positive(0) //returns false
is-positive(-1) //returns false
is-positive('hello') //returns false
Requires
- [function]
is-number
Used by
- [function]
is-measure-positive
is-string
@function is-string($var) { ... }
View sourceDescription
Tests whether $var
is string.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | possible string type variable | Any | —none |
Returns
Bool
Example
is-string('sassy-validation') //returns true
is-string(1) //returns false
is-string(18px) //returns false
is-unit
@function is-unit($value) { ... }
View sourceDescription
Tests whether $var
is unit.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$value | possible unit type variable | Any | —none |
Returns
Bool
Example
is-unit(rem) //returns true
is-unit(-1000px) //returns false
is-unit('sassy-validation') //returns false
is-unit(777) //returns false
Requires
- [variable]
sv-units
validate
@function validate($var, $validations) { ... }
View sourceDescription
Validates input against various tests
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$var | a variable to be tested | Any | —none |
$validations | list of validation tests to run against | Bool or Color or Empty or Float or Integer or List or Map or Measure-negative or Measure-positive or Measure or Negative or Positive or Null or Number or String or Unit | —none |
Returns
Bool
Example
validate(1em, measure) // returns true
validate(100, number positive) // returns true
validate(1, number) // returns true
validate(1, string) // returns false
Throws
{$validation} is not a known validation type.
variables
sv-units
$sv-units: ('px', 'cm', 'mm', '%', 'ch', 'pc', 'in', 'em', 'rem', 'pt', 'pc', 'ex', 'vw', 'vh', 'vmin', 'vmax');
View sourceDescription
List of all possible unit types
Type
List
Used by
- [function]
is-measure
- [function]
is-unit