diff options
author | HombreLaser <sebastian-440@live.com> | 2024-02-08 16:36:31 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2024-02-08 16:36:31 -0600 |
commit | e182245d3205d929881f51da9b48d6c4ed97a682 (patch) | |
tree | d390e8754dec70a9c9293afb801321b96f043c15 /_sass/bourbon/functions |
Diffstat (limited to '_sass/bourbon/functions')
-rw-r--r-- | _sass/bourbon/functions/_assign-inputs.scss | 11 | ||||
-rw-r--r-- | _sass/bourbon/functions/_contains-falsy.scss | 20 | ||||
-rw-r--r-- | _sass/bourbon/functions/_contains.scss | 26 | ||||
-rw-r--r-- | _sass/bourbon/functions/_is-length.scss | 11 | ||||
-rw-r--r-- | _sass/bourbon/functions/_is-light.scss | 21 | ||||
-rw-r--r-- | _sass/bourbon/functions/_is-number.scss | 11 | ||||
-rw-r--r-- | _sass/bourbon/functions/_is-size.scss | 13 | ||||
-rw-r--r-- | _sass/bourbon/functions/_modular-scale.scss | 69 | ||||
-rw-r--r-- | _sass/bourbon/functions/_px-to-em.scss | 13 | ||||
-rw-r--r-- | _sass/bourbon/functions/_px-to-rem.scss | 15 | ||||
-rw-r--r-- | _sass/bourbon/functions/_shade.scss | 24 | ||||
-rw-r--r-- | _sass/bourbon/functions/_strip-units.scss | 17 | ||||
-rw-r--r-- | _sass/bourbon/functions/_tint.scss | 24 | ||||
-rw-r--r-- | _sass/bourbon/functions/_transition-property-name.scss | 22 | ||||
-rw-r--r-- | _sass/bourbon/functions/_unpack.scss | 27 |
15 files changed, 324 insertions, 0 deletions
diff --git a/_sass/bourbon/functions/_assign-inputs.scss b/_sass/bourbon/functions/_assign-inputs.scss new file mode 100644 index 0000000..f8aba96 --- /dev/null +++ b/_sass/bourbon/functions/_assign-inputs.scss @@ -0,0 +1,11 @@ +@function assign-inputs($inputs, $pseudo: null) { + $list: (); + + @each $input in $inputs { + $input: unquote($input); + $input: if($pseudo, $input + ":" + $pseudo, $input); + $list: append($list, $input, comma); + } + + @return $list; +} diff --git a/_sass/bourbon/functions/_contains-falsy.scss b/_sass/bourbon/functions/_contains-falsy.scss new file mode 100644 index 0000000..c096fdb --- /dev/null +++ b/_sass/bourbon/functions/_contains-falsy.scss @@ -0,0 +1,20 @@ +@charset "UTF-8"; + +/// Checks if a list does not contains a value. +/// +/// @access private +/// +/// @param {List} $list +/// The list to check against. +/// +/// @return {Bool} + +@function contains-falsy($list) { + @each $item in $list { + @if not $item { + @return true; + } + } + + @return false; +} diff --git a/_sass/bourbon/functions/_contains.scss b/_sass/bourbon/functions/_contains.scss new file mode 100644 index 0000000..3dec27d --- /dev/null +++ b/_sass/bourbon/functions/_contains.scss @@ -0,0 +1,26 @@ +@charset "UTF-8"; + +/// Checks if a list contains a value(s). +/// +/// @access private +/// +/// @param {List} $list +/// The list to check against. +/// +/// @param {List} $values +/// A single value or list of values to check for. +/// +/// @example scss - Usage +/// contains($list, $value) +/// +/// @return {Bool} + +@function contains($list, $values...) { + @each $value in $values { + @if type-of(index($list, $value)) != "number" { + @return false; + } + } + + @return true; +} diff --git a/_sass/bourbon/functions/_is-length.scss b/_sass/bourbon/functions/_is-length.scss new file mode 100644 index 0000000..5826e78 --- /dev/null +++ b/_sass/bourbon/functions/_is-length.scss @@ -0,0 +1,11 @@ +@charset "UTF-8"; + +/// Checks for a valid CSS length. +/// +/// @param {String} $value + +@function is-length($value) { + @return type-of($value) != "null" and (str-slice($value + "", 1, 4) == "calc" + or index(auto inherit initial 0, $value) + or (type-of($value) == "number" and not(unitless($value)))); +} diff --git a/_sass/bourbon/functions/_is-light.scss b/_sass/bourbon/functions/_is-light.scss new file mode 100644 index 0000000..92d90ac --- /dev/null +++ b/_sass/bourbon/functions/_is-light.scss @@ -0,0 +1,21 @@ +@charset "UTF-8"; + +/// Programatically determines whether a color is light or dark. +/// +/// @link http://robots.thoughtbot.com/closer-look-color-lightness +/// +/// @param {Color (Hex)} $color +/// +/// @example scss - Usage +/// is-light($color) +/// +/// @return {Bool} + +@function is-light($hex-color) { + $-local-red: red(rgba($hex-color, 1)); + $-local-green: green(rgba($hex-color, 1)); + $-local-blue: blue(rgba($hex-color, 1)); + $-local-lightness: ($-local-red * 0.2126 + $-local-green * 0.7152 + $-local-blue * 0.0722) / 255; + + @return $-local-lightness > 0.6; +} diff --git a/_sass/bourbon/functions/_is-number.scss b/_sass/bourbon/functions/_is-number.scss new file mode 100644 index 0000000..a64e0bf --- /dev/null +++ b/_sass/bourbon/functions/_is-number.scss @@ -0,0 +1,11 @@ +@charset "UTF-8"; + +/// Checks for a valid number. +/// +/// @param {Number} $value +/// +/// @require {function} contains + +@function is-number($value) { + @return contains("0" "1" "2" "3" "4" "5" "6" "7" "8" "9" 0 1 2 3 4 5 6 7 8 9, $value); +} diff --git a/_sass/bourbon/functions/_is-size.scss b/_sass/bourbon/functions/_is-size.scss new file mode 100644 index 0000000..661789a --- /dev/null +++ b/_sass/bourbon/functions/_is-size.scss @@ -0,0 +1,13 @@ +@charset "UTF-8"; + +/// Checks for a valid CSS size. +/// +/// @param {String} $value +/// +/// @require {function} contains +/// @require {function} is-length + +@function is-size($value) { + @return is-length($value) + or contains("fill" "fit-content" "min-content" "max-content", $value); +} diff --git a/_sass/bourbon/functions/_modular-scale.scss b/_sass/bourbon/functions/_modular-scale.scss new file mode 100644 index 0000000..20fa388 --- /dev/null +++ b/_sass/bourbon/functions/_modular-scale.scss @@ -0,0 +1,69 @@ +// Scaling Variables +$golden: 1.618; +$minor-second: 1.067; +$major-second: 1.125; +$minor-third: 1.2; +$major-third: 1.25; +$perfect-fourth: 1.333; +$augmented-fourth: 1.414; +$perfect-fifth: 1.5; +$minor-sixth: 1.6; +$major-sixth: 1.667; +$minor-seventh: 1.778; +$major-seventh: 1.875; +$octave: 2; +$major-tenth: 2.5; +$major-eleventh: 2.667; +$major-twelfth: 3; +$double-octave: 4; + +$modular-scale-ratio: $perfect-fourth !default; +$modular-scale-base: em($em-base) !default; + +@function modular-scale($increment, $value: $modular-scale-base, $ratio: $modular-scale-ratio) { + $v1: nth($value, 1); + $v2: nth($value, length($value)); + $value: $v1; + + // scale $v2 to just above $v1 + @while $v2 > $v1 { + $v2: ($v2 / $ratio); // will be off-by-1 + } + @while $v2 < $v1 { + $v2: ($v2 * $ratio); // will fix off-by-1 + } + + // check AFTER scaling $v2 to prevent double-counting corner-case + $double-stranded: $v2 > $v1; + + @if $increment > 0 { + @for $i from 1 through $increment { + @if $double-stranded and ($v1 * $ratio) > $v2 { + $value: $v2; + $v2: ($v2 * $ratio); + } @else { + $v1: ($v1 * $ratio); + $value: $v1; + } + } + } + + @if $increment < 0 { + // adjust $v2 to just below $v1 + @if $double-stranded { + $v2: ($v2 / $ratio); + } + + @for $i from $increment through -1 { + @if $double-stranded and ($v1 / $ratio) < $v2 { + $value: $v2; + $v2: ($v2 / $ratio); + } @else { + $v1: ($v1 / $ratio); + $value: $v1; + } + } + } + + @return $value; +} diff --git a/_sass/bourbon/functions/_px-to-em.scss b/_sass/bourbon/functions/_px-to-em.scss new file mode 100644 index 0000000..ae81a44 --- /dev/null +++ b/_sass/bourbon/functions/_px-to-em.scss @@ -0,0 +1,13 @@ +// Convert pixels to ems +// eg. for a relational value of 12px write em(12) when the parent is 16px +// if the parent is another value say 24px write em(12, 24) + +@function em($pxval, $base: $em-base) { + @if not unitless($pxval) { + $pxval: strip-units($pxval); + } + @if not unitless($base) { + $base: strip-units($base); + } + @return ($pxval / $base) * 1em; +} diff --git a/_sass/bourbon/functions/_px-to-rem.scss b/_sass/bourbon/functions/_px-to-rem.scss new file mode 100644 index 0000000..0ac941e --- /dev/null +++ b/_sass/bourbon/functions/_px-to-rem.scss @@ -0,0 +1,15 @@ +// Convert pixels to rems +// eg. for a relational value of 12px write rem(12) +// Assumes $em-base is the font-size of <html> + +@function rem($pxval) { + @if not unitless($pxval) { + $pxval: strip-units($pxval); + } + + $base: $em-base; + @if not unitless($base) { + $base: strip-units($base); + } + @return ($pxval / $base) * 1rem; +} diff --git a/_sass/bourbon/functions/_shade.scss b/_sass/bourbon/functions/_shade.scss new file mode 100644 index 0000000..8aaf2c6 --- /dev/null +++ b/_sass/bourbon/functions/_shade.scss @@ -0,0 +1,24 @@ +@charset "UTF-8"; + +/// Mixes a color with black. +/// +/// @param {Color} $color +/// +/// @param {Number (Percentage)} $percent +/// The amount of black to be mixed in. +/// +/// @example scss - Usage +/// .element { +/// background-color: shade(#ffbb52, 60%); +/// } +/// +/// @example css - CSS Output +/// .element { +/// background-color: #664a20; +/// } +/// +/// @return {Color} + +@function shade($color, $percent) { + @return mix(#000, $color, $percent); +} diff --git a/_sass/bourbon/functions/_strip-units.scss b/_sass/bourbon/functions/_strip-units.scss new file mode 100644 index 0000000..6c5f3e8 --- /dev/null +++ b/_sass/bourbon/functions/_strip-units.scss @@ -0,0 +1,17 @@ +@charset "UTF-8"; + +/// Strips the unit from a number. +/// +/// @param {Number (With Unit)} $value +/// +/// @example scss - Usage +/// $dimension: strip-units(10em); +/// +/// @example css - CSS Output +/// $dimension: 10; +/// +/// @return {Number (Unitless)} + +@function strip-units($value) { + @return ($value / ($value * 0 + 1)); +} diff --git a/_sass/bourbon/functions/_tint.scss b/_sass/bourbon/functions/_tint.scss new file mode 100644 index 0000000..2e33814 --- /dev/null +++ b/_sass/bourbon/functions/_tint.scss @@ -0,0 +1,24 @@ +@charset "UTF-8"; + +/// Mixes a color with white. +/// +/// @param {Color} $color +/// +/// @param {Number (Percentage)} $percent +/// The amount of white to be mixed in. +/// +/// @example scss - Usage +/// .element { +/// background-color: tint(#6ecaa6, 40%); +/// } +/// +/// @example css - CSS Output +/// .element { +/// background-color: #a8dfc9; +/// } +/// +/// @return {Color} + +@function tint($color, $percent) { + @return mix(#fff, $color, $percent); +} diff --git a/_sass/bourbon/functions/_transition-property-name.scss b/_sass/bourbon/functions/_transition-property-name.scss new file mode 100644 index 0000000..18348b9 --- /dev/null +++ b/_sass/bourbon/functions/_transition-property-name.scss @@ -0,0 +1,22 @@ +// Return vendor-prefixed property names if appropriate +// Example: transition-property-names((transform, color, background), moz) -> -moz-transform, color, background +//************************************************************************// +@function transition-property-names($props, $vendor: false) { + $new-props: (); + + @each $prop in $props { + $new-props: append($new-props, transition-property-name($prop, $vendor), comma); + } + + @return $new-props; +} + +@function transition-property-name($prop, $vendor: false) { + // put other properties that need to be prefixed here aswell + @if $vendor and $prop == transform { + @return unquote('-'+$vendor+'-'+$prop); + } + @else { + @return $prop; + } +} diff --git a/_sass/bourbon/functions/_unpack.scss b/_sass/bourbon/functions/_unpack.scss new file mode 100644 index 0000000..4367935 --- /dev/null +++ b/_sass/bourbon/functions/_unpack.scss @@ -0,0 +1,27 @@ +@charset "UTF-8"; + +/// Converts shorthand to the 4-value syntax. +/// +/// @param {List} $shorthand +/// +/// @example scss - Usage +/// .element { +/// margin: unpack(1em 2em); +/// } +/// +/// @example css - CSS Output +/// .element { +/// margin: 1em 2em 1em 2em; +/// } + +@function unpack($shorthand) { + @if length($shorthand) == 1 { + @return nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1); + } @else if length($shorthand) == 2 { + @return nth($shorthand, 1) nth($shorthand, 2) nth($shorthand, 1) nth($shorthand, 2); + } @else if length($shorthand) == 3 { + @return nth($shorthand, 1) nth($shorthand, 2) nth($shorthand, 3) nth($shorthand, 2); + } @else { + @return $shorthand; + } +} |