aboutsummaryrefslogtreecommitdiff
path: root/assets/sass/libs/_functions.scss
diff options
context:
space:
mode:
authorGravatar Anshul Gupta <ansg191@yahoo.com> 2020-08-04 16:27:53 -0700
committerGravatar Anshul Gupta <ansg191@yahoo.com> 2020-08-04 16:27:53 -0700
commit3ec2f4a87d8509aed4f42975d8a03b75e78c5218 (patch)
tree96b172b7b49476567331ed4b0758383dfb7870a4 /assets/sass/libs/_functions.scss
parente37306449b036fc192ddee5db78d3a30197a8f21 (diff)
downloadPortfolio-master.tar.gz
Portfolio-master.tar.zst
Portfolio-master.zip
Import TemplateHEADmaster
Diffstat (limited to 'assets/sass/libs/_functions.scss')
-rw-r--r--assets/sass/libs/_functions.scss90
1 files changed, 90 insertions, 0 deletions
diff --git a/assets/sass/libs/_functions.scss b/assets/sass/libs/_functions.scss
new file mode 100644
index 0000000..b367524
--- /dev/null
+++ b/assets/sass/libs/_functions.scss
@@ -0,0 +1,90 @@
+/// Removes a specific item from a list.
+/// @author Hugo Giraudel
+/// @param {list} $list List.
+/// @param {integer} $index Index.
+/// @return {list} Updated list.
+@function remove-nth($list, $index) {
+
+ $result: null;
+
+ @if type-of($index) != number {
+ @warn "$index: #{quote($index)} is not a number for `remove-nth`.";
+ }
+ @else if $index == 0 {
+ @warn "List index 0 must be a non-zero integer for `remove-nth`.";
+ }
+ @else if abs($index) > length($list) {
+ @warn "List index is #{$index} but list is only #{length($list)} item long for `remove-nth`.";
+ }
+ @else {
+
+ $result: ();
+ $index: if($index < 0, length($list) + $index + 1, $index);
+
+ @for $i from 1 through length($list) {
+
+ @if $i != $index {
+ $result: append($result, nth($list, $i));
+ }
+
+ }
+
+ }
+
+ @return $result;
+
+}
+
+/// Gets a value from a map.
+/// @author Hugo Giraudel
+/// @param {map} $map Map.
+/// @param {string} $keys Key(s).
+/// @return {string} Value.
+@function val($map, $keys...) {
+
+ @if nth($keys, 1) == null {
+ $keys: remove-nth($keys, 1);
+ }
+
+ @each $key in $keys {
+ $map: map-get($map, $key);
+ }
+
+ @return $map;
+
+}
+
+/// Gets a duration value.
+/// @param {string} $keys Key(s).
+/// @return {string} Value.
+@function _duration($keys...) {
+ @return val($duration, $keys...);
+}
+
+/// Gets a font value.
+/// @param {string} $keys Key(s).
+/// @return {string} Value.
+@function _font($keys...) {
+ @return val($font, $keys...);
+}
+
+/// Gets a misc value.
+/// @param {string} $keys Key(s).
+/// @return {string} Value.
+@function _misc($keys...) {
+ @return val($misc, $keys...);
+}
+
+/// Gets a palette value.
+/// @param {string} $keys Key(s).
+/// @return {string} Value.
+@function _palette($keys...) {
+ @return val($palette, $keys...);
+}
+
+/// Gets a size value.
+/// @param {string} $keys Key(s).
+/// @return {string} Value.
+@function _size($keys...) {
+ @return val($size, $keys...);
+} \ No newline at end of file