colors
functions
cmyk
@function cmyk($cyan, $magenta, $yellow, $key: 0) { ... }
Description
Convert CMYK to RGB
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$cyan | 0 to 1 | Number | —none |
$magenta | 0 to 1 | Number | —none |
$yellow | 0 to 1 | Number | —none |
$key | 0 to 1 | Number | 0 |
Returns
Color
Example
cmyk(0, 1, 1, 0)
// #f00
Throws
All parameters must be a unitless number
Requires
hsv
@function hsv($hue, $saturation, $value) { ... }
Description
Convert HSV to RGB
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$hue | 0 to 360 | Number | —none |
$saturation | 0% to 100% | Number | —none |
$value | 0% to 100% | Number | —none |
Returns
Color
Example
hsv(240, 100%, 100%)
// #00f
Requires
- [function]
strip-unit
random-color
@function random-color() { ... }
Description
Return a random color
Parameters
None.
Returns
Color
shade
@function shade($color, $percent) { ... }
Description
Darken a color
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$color | —none | Color | —none |
$percent | 0% to 100% | Number | —none |
Returns
Color
Example
shade(#fff, 40%)
// #999
tint
@function tint($color, $percent) { ... }
Description
Lighten a color
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$color | —none | Color | —none |
$percent | 0% to 100% | Number | —none |
Returns
Color
Example
tint(#000, 40%)
// #666
lists
functions
contains
@function contains($list, $value) { ... }
Description
Returns true if the value is present in the list.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$list | —none | List | —none |
$value | —none | Anything | —none |
Returns
Boolean
Example
contains(('a', 'b', 'c'), 'b')
// true
Used by
- [function]
cmyk
TODO's
Add optional recursive search
each
@function each($list, $function, $args...) { ... }
Description
Creates a new list with the results of calling a provided function on every element in this list.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$list | —none | List | —none |
$function | —none | String | —none |
$args... | —none | Arguments | —none |
Returns
List
Example
$list: ('a', 'b', 'c');
each($list, 'str-insert', 'x', 1)
// ('xa', 'xb', 'xc')
Throws
#{$list} is not a list
Function #{$function}() does not exist!
Used by
- [function]
cmyk
str-join
@function str-join($list, $separator: ',') { ... }
Description
Join all items of a list into a string
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$list | —none | List | —none |
$separator | —none | String | ',' |
Returns
String
Example
$list: ('a', 'b', 'c', 'd');
str-join($list, '+')
// a+b+c+d
Used by
- [function]
str-concat
without
@function without($list, $values...) { ... }
Description
Returns a copy of a list with values removed
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$list | —none | List | —none |
$values... | —none | Anything | —none |
Returns
List
Example
$list: ('a', 'b', 'c', 'd');
without($list, 'b', 'a')
// ('c', 'd')
Used by
- [function]
compact
compact
@function compact($list) { ... }
Description
Returns a copy of a list with falsy values removed ('' and false)
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$list | —none | List | —none |
Returns
List
Example
$list: ('a', 'b', '', 'c', false, 'd');
compact($list)
// ('a', 'b', 'c', 'd')
Requires
- [function]
without
numbers
functions
add-unit
@function add-unit($number, $unit) { ... }
Description
Add unit to a number
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$number | —none | Number | —none |
$unit | —none | String | —none |
Returns
Number
Example
add-unit(1, 'px')
// 1px
Throws
$number must be unitless
Used by
- [function]
polar-to-cartesian
- [function]
replace-unit
polar-to-cartesian
@function polar-to-cartesian($distance, $angle) { ... }
Description
Return cartesian coordinates
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$distance | —none | Number | —none |
$angle | —none | Number | —none |
Returns
List
Example
polar-to-cartesian(5px, 90deg)
// 0 5px
Throws
Could not find sin()! Please make sure all dependencies are met. See https://github.com/devatrox/Sunglass/ for more info.
Could not find cos()! Please make sure all dependencies are met. See https://github.com/devatrox/Sunglass/ for more info.
$angle NaN
$distance NaN
Could not find deg-to-rad()! Please make sure all dependencies are met. See https://github.com/devatrox/Sunglass/ for more info.
$angle unit must be
Requires
- [function]
strip-unit
- [function]
add-unit
- [external]
Math::deg-to-rad
- [external]
Math::cos
- [external]
Math::sin
Used by
- [function]
coordinates
Links
coordinates
@function coordinates($distance, $angle) { ... }
Description
Return cartesian coordinates in CSS-format (by inverting the Y-axis)
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$distance | —none | Number | —none |
$angle | —none | Number | —none |
Returns
List
Example
coordinates(5px, 90deg)
// 0 -5px
Requires
- [function]
polar-to-cartesian
- [function]
inverse
inverse
@function inverse($number) { ... }
Description
Invert the sign of a number
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$number | —none | Number | —none |
Returns
Number
Example
inverse(3px)
// -3px
Throws
#{$numbers} NaN
Used by
- [function]
coordinates
replace-unit
@function replace-unit($number, $unit) { ... }
Description
Replace unit with another unit
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$number | —none | Number | —none |
$unit | —none | String | —none |
Returns
Number
Example
replace-unit(1px, 'em')
// 1em
Requires
- [function]
add-unit
- [function]
strip-unit
strip-unit
@function strip-unit($number) { ... }
Description
Remove the unit of a number
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$number | —none | Number | —none |
Returns
Number
Example
strip-unit(1px)
// 1
Used by
- [function]
hsv
- [function]
polar-to-cartesian
- [function]
replace-unit
Author
Jason Nickel
settings
variables
[private] sg-version
$sg-version: '4.0.0';
Description
The App version
Type
String
sunglass
$sunglass: () !default;
Description
Global settings map
Type
Map
[private] sg-settings
$sg-settings: ();
Description
Private settings map
Type
Map
valid-units
$valid-units: (
'em': 0em,
'ex': 0ex,
'ch': 0ch,
'rem': 0rem,
'vh': 0vh,
'vw': 0vw,
'vmin': 0vmin,
'vmax': 0vmax,
'px': 0px,
'mm': 0mm,
'cm': 0cm,
'in': 0in,
'pt': 0pt,
'pc': 0pc,
'%': 0%,
'deg': 0deg,
'grad': 0grad,
'rad': 0rad,
'turn': 0turn,
'Hz': 0Hz,
'kHz': 0kHz,
'dpi': 0dpi,
'dpcm': 0dpcm,
'dppx': 0dppx,
's': 0s,
'ms': 0ms
);
Description
Global units map
Type
Map
strings
functions
str-concat
@function str-concat($strings...) { ... }
Description
Combines the text of two or more strings and returns a new string.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$strings... | —none | Strings | —none |
Returns
Boolean
Example
str-concat('a', 'b', 'c')
// abc
Requires
- [function]
str-join
str-contains
@function str-contains($string, $substr, $start: 0) { ... }
Description
Returns true if the value is present in the string.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$string | —none | String | —none |
$substr | —none | String | —none |
$start | —none | Number | 0 |
Returns
Boolean
Example
str-contains('abc', 'b')
// true
TODO's
Add optional recursive search
str-count
@function str-count($string, $substr) { ... }
Description
Returns the number of substrings in the string.
Parameters
parameterName | parameterDescription | parameterType | parameterDefault value |
---|---|---|---|
$string | —none | String | —none |
$substr | —none | String | —none |
Returns
Number
Example
str-count('abcabc', 'b')
// 2