1// Calculate grid values
2$gutter: percentage($gutter-in-px / $row-max-width); // 2.1276596
3
4// Return single column width
5@function oneCol($hybrid-grid: false) {
6  @if ($hybrid-grid == true){
7    @return (100% - ($gutter * ($hybrid - 1))) / $hybrid;
8  }
9  @else{
10    @return (100% - ($gutter * ($cols - 1))) / $cols;
11  }
12}
13
14// Calculate Grid Column Widths
15@function columns($num, $hybrid-grid: false){
16  @if ($hybrid-grid == true) {
17    @return (oneCol(true) * $num) + ($gutter * ($num - 1));
18  }
19  @else {
20    @return (oneCol() * $num) + ($gutter * ($num - 1)); // (One column * 'x') + (gutter * ('x' - 1)) = Column Width
21  }
22}
23
24
25// Calculate the width required to acheive a desired global column number within a nested grid
26@function global-columns($desired_cols, $container_cols, $hybrid-grid: false){
27  @if ($hybrid-grid == true) {
28    @return (100% * (columns($desired_cols, true) / columns($container_cols, true)));
29  }
30  @else {
31    @return (100% * (columns($desired_cols) / columns($container_cols)));
32  }
33}
34
35// Calculate Push Class Margins
36@function push_x($num, $first-child: false, $is-hybrid: false) {
37  @if $first-child and $is-hybrid {
38    @return (oneCol(true) * $num) + ($gutter * ($num - 1)) + $gutter; // Column width + gutter
39  }
40  @else if $first-child != true and $is_hybrid{
41    @return (oneCol(true) * $num) + ($gutter * ($num - 1)) + ($gutter * 2); // Column width + (gutter * 2)
42  }
43  @else if $first-child and $is_hybrid != true{
44      @return (oneCol() * $num) + ($gutter * ($num - 1)) + $gutter;
45  }
46  @else {
47    @return (oneCol() * $num) + ($gutter * ($num - 1)) + ($gutter * 2); // Column width + (gutter * 2)
48  }
49}
50
51// Calculate Pull Class Margins
52// note absence of first-child; first-child column containers should not be pulled
53// $num is number of columns to be pulled
54// $width is number of columns of container that is being pulled
55@function pull_x($num, $width, $is-hybrid: false) {
56    @if $is-hybrid {
57        @return -((oneCol(true) * $num) + ($gutter * ($num - 1)) + (oneCol(true) * $width) + ($gutter * ($width - 1)) + $gutter); // Pull width + column width + gutter
58    }
59    @else {
60        @return -((oneCol() * $num) + ($gutter * ($num - 1)) + (oneCol() * $width) + ($gutter * ($width - 1)) + $gutter); // Pull width + column width + gutter
61    }
62}
63
64// Calculate Centered Class Margins
65@function centered($num, $hybrid-grid: false) {
66  @if $hybrid-grid{
67    @return 50% - ((($num * (oneCol(true))) + (($num - 1) * $gutter)) / 2);
68  }
69  @else{
70    @return 50% - ((($num * (oneCol())) + (($num - 1) * $gutter)) / 2);
71  }
72}
73
74// Create class names from column count integers
75@function number-as-word($number){
76  $w: "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven",
77"twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen",
78"twenty", "twenty-one", "twenty-two", "twenty-three", "twenty-four", "twenty-five", "twenty-six", "twenty-seven",
79"twenty-eight", "twenty-nine", "thirty", "thirty-one", "thirty-two", "thirty-three",
80"thirty-four", "thirty-five", "thirty-six";
81  @return nth($w, $number);
82}
83