cv-website

Personal website and CV
git clone https://git.in0rdr.ch/cv-website.git
Log | Files | Refs | Pull requests |Archive | README | LICENSE

_linear-positions-parser.scss (1993B)


      1 @function _linear-positions-parser($pos) {
      2   $type: type-of(nth($pos, 1));
      3   $spec: null;
      4   $degree: null;
      5   $side: null;
      6   $corner: null;
      7   $length: length($pos);
      8   // Parse Side and corner positions
      9   @if ($length > 1) {
     10     @if nth($pos, 1) == "to" { // Newer syntax
     11       $side: nth($pos, 2);
     12 
     13       @if $length == 2 { // eg. to top
     14         // Swap for backwards compatibility
     15         $degree: _position-flipper(nth($pos, 2));
     16       }
     17       @else if $length == 3 { // eg. to top left
     18         $corner: nth($pos, 3);
     19       }
     20     }
     21     @else if $length == 2 { // Older syntax ("top left")
     22       $side: _position-flipper(nth($pos, 1));
     23       $corner: _position-flipper(nth($pos, 2));
     24     }
     25 
     26     @if ("#{$side} #{$corner}" == "left top") or ("#{$side} #{$corner}" == "top left") {
     27       $degree: _position-flipper(#{$side}) _position-flipper(#{$corner});
     28     }
     29     @else if ("#{$side} #{$corner}" == "right top") or ("#{$side} #{$corner}" == "top right") {
     30       $degree: _position-flipper(#{$side}) _position-flipper(#{$corner});
     31     }
     32     @else if ("#{$side} #{$corner}" == "right bottom") or ("#{$side} #{$corner}" == "bottom right") {
     33       $degree: _position-flipper(#{$side}) _position-flipper(#{$corner});
     34     }
     35     @else if ("#{$side} #{$corner}" == "left bottom") or ("#{$side} #{$corner}" == "bottom left") {
     36       $degree: _position-flipper(#{$side}) _position-flipper(#{$corner});
     37     }
     38     $spec: to $side $corner;
     39   }
     40   @else if $length == 1 {
     41     // Swap for backwards compatibility
     42     @if $type == string {
     43       $degree: $pos;
     44       $spec: to _position-flipper($pos);
     45     }
     46     @else {
     47       $degree: -270 - $pos; //rotate the gradient opposite from spec
     48       $spec: $pos;
     49     }
     50   }
     51   $degree: unquote($degree + ",");
     52   $spec:   unquote($spec + ",");
     53   @return $degree $spec;
     54 }
     55 
     56 @function _position-flipper($pos) {
     57   @return if($pos == left, right, null)
     58          if($pos == right, left, null)
     59          if($pos == top, bottom, null)
     60          if($pos == bottom, top, null);
     61 }