mcgriddle 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,31 @@
1
+ /*!
2
+ * McGriddle
3
+ * @description
4
+ * @author Jonathan Suh @jonsuh
5
+ * @site https://
6
+ * @link https://
7
+ */
8
+
9
+ // Settings
10
+ // ==================================================
11
+ @import "settings/grid";
12
+
13
+ // Functions
14
+ // ==================================================
15
+ @import "functions/helpers";
16
+
17
+ @import "functions/gutter-width";
18
+ @import "functions/column-width";
19
+ @import "functions/shift-width";
20
+
21
+ // Mixins
22
+ // ==================================================
23
+ @import "mixins/grid-collapse";
24
+ @import "mixins/grid-direction";
25
+ @import "mixins/grid-flexbox";
26
+ @import "mixins/grid-reset";
27
+ @import "mixins/container-display";
28
+
29
+ @import "mixins/container";
30
+ @import "mixins/columns";
31
+ @import "mixins/shift";
@@ -0,0 +1,78 @@
1
+ // ==================================================
2
+ // Column Width
3
+ // ==================================================
4
+ @function column-width($_columns: 1, $_percent: true) {
5
+ $_grid-columns : $grid-columns;
6
+
7
+ $_column-width : $grid-width;
8
+ $_column-width-percent: 100%;
9
+
10
+ // major or minor
11
+ @if $_columns == major or $_columns == minor {
12
+ @if $_columns == major {
13
+ $_columns: 1 - $grid-minor;
14
+ }
15
+ @else {
16
+ $_columns: $grid-minor;
17
+ }
18
+
19
+ $_columns: $grid-columns * $_columns;
20
+ }
21
+ // '#/#'
22
+ @else if type-of($_columns) == string {
23
+ $_columns : str-replace($_columns, " ");
24
+ $_index : str-index($_columns, "/");
25
+ $_index-offset: 1;
26
+
27
+ @if $_index == null {
28
+ $_index : str-index($_columns, "of");
29
+ $_index-offset: 2;
30
+ }
31
+
32
+ @if $_index {
33
+ $_grid-columns: to-number(str-slice($_columns, $_index + $_index-offset, str-length($_columns)));
34
+ $_columns : to-number(str-slice($_columns, 1, $_index - 1));
35
+ }
36
+ }
37
+ // # of # or # #
38
+ @else if type-of($_columns) == list {
39
+ @if length($_columns) == 3 {
40
+ $_grid-columns: nth($_columns, 3);
41
+ }
42
+ @else {
43
+ $_grid-columns: nth($_columns, 2);
44
+ }
45
+
46
+ $_columns: nth($_columns, 1);
47
+ }
48
+
49
+ // calculate column width
50
+ @if $grid-collapse == true {
51
+ $_column-width: ($grid-width / $_grid-columns) * $_columns;
52
+
53
+ @if $_percent == true {
54
+ $_column-width-percent: $_column-width * 100% / $grid-width;
55
+ }
56
+ }
57
+ @else {
58
+ // $_column-count : ceil($_grid-columns / $_columns);
59
+ $_column-count : $_grid-columns / $_columns;
60
+
61
+ $_gutter-total-width : $grid-gutter * ($_column-count - 1);
62
+ $_grid-remainder-width: $grid-width - $_gutter-total-width;
63
+
64
+ $_column-width : $_grid-remainder-width / $_column-count;
65
+
66
+ @if $_percent == true {
67
+ $_column-width-percent: $_column-width * 100% / $grid-width;
68
+ }
69
+ }
70
+
71
+ // return column width in absolute or percent value
72
+ @if $_percent == true {
73
+ @return $_column-width-percent;
74
+ }
75
+ @else {
76
+ @return $_column-width;
77
+ }
78
+ }
@@ -0,0 +1,15 @@
1
+ // ==================================================
2
+ // Gutter Width
3
+ // ==================================================
4
+ @function gutter-width($_percent: true) {
5
+ $_gutter-width-fraction: $grid-gutter / $grid-width;
6
+
7
+ @if $_percent == true {
8
+ $_gutter-width-percent : $_gutter-width-fraction * 100%;
9
+
10
+ @return $_gutter-width-percent;
11
+ }
12
+ @else {
13
+ @return $grid-gutter;
14
+ }
15
+ }
@@ -0,0 +1,60 @@
1
+ //
2
+ // Replace `$search` with `$replace` in `$string`
3
+ // @author Hugo Giraudel
4
+ //
5
+ // @param {String} $string - Initial string
6
+ // @param {String} $search - Substring to replace
7
+ // @param {String} $replace ('') - New value
8
+ //
9
+ // @return {String} - Updated string
10
+ //
11
+ @function str-replace($string, $search, $replace: '') {
12
+ $index: str-index($string, $search);
13
+
14
+ @if $index {
15
+ @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
16
+ }
17
+
18
+ @return $string;
19
+ }
20
+
21
+ //
22
+ // String to number converter
23
+ // @author Hugo Giraudel
24
+ // @access private
25
+ //
26
+ // @param {String | Number} $value - Value to be parsed
27
+ //
28
+ // @return {Number}
29
+ //
30
+ @function to-number($value) {
31
+ @if type-of($value) == 'number' {
32
+ @return $value;
33
+ } @else if type-of($value) != 'string' {
34
+ $_: log('Value for `to-number` should be a number or a string.');
35
+ }
36
+
37
+ $result: 0;
38
+ $digits: 0;
39
+ $minus: str-slice($value, 1, 1) == '-';
40
+ $numbers: ('0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9);
41
+
42
+ @for $i from if($minus, 2, 1) through str-length($value) {
43
+ $character: str-slice($value, $i, $i);
44
+
45
+ @if not (index(map-keys($numbers), $character) or $character == '.') {
46
+ @return to-length(if($minus, -$result, $result), str-slice($value, $i))
47
+ }
48
+
49
+ @if $character == '.' {
50
+ $digits: 1;
51
+ } @else if $digits == 0 {
52
+ $result: $result * 10 + map-get($numbers, $character);
53
+ } @else {
54
+ $digits: $digits * 10;
55
+ $result: $result + map-get($numbers, $character) / $digits;
56
+ }
57
+ }
58
+
59
+ @return if($minus, -$result, $result);
60
+ }
@@ -0,0 +1,8 @@
1
+ // ==================================================
2
+ // Shift Width
3
+ // ==================================================
4
+ @function shift-width($_columns: 1, $_percent: true) {
5
+ $_shift: column-width($_columns, $_percent) + gutter-width($_percent);
6
+
7
+ @return $_shift;
8
+ }
@@ -0,0 +1,60 @@
1
+ // ==================================================
2
+ // Columns
3
+ // ==================================================
4
+ @mixin columns($_columns: 1, $_position: default, $_max-width: false) {
5
+ @if $_max-width == max or $_max-width == true {
6
+ width: 100%;
7
+ $_column-width: column-width($_columns, false);
8
+
9
+ max-width: $_column-width;
10
+ }
11
+ @else { // $_max-width == default
12
+ width: column-width($_columns);
13
+ }
14
+
15
+ @if $_position == center {
16
+ margin-left: auto;
17
+ margin-right: auto;
18
+ }
19
+ @else {
20
+ $_float: left;
21
+ $_margin: right;
22
+
23
+ @if ($grid-flexbox == true and $grid-flexbox-justify != space-between) or $grid-flexbox == false {
24
+ @if $grid-flexbox == true {
25
+ @if $grid-flexbox-justify == flex-end {
26
+ $_margin: left;
27
+
28
+ @if $grid-rtl == true {
29
+ $_margin: right;
30
+ }
31
+ }
32
+ // $grid-flexbox-justify == flex-start, flex-end, center
33
+ @else {
34
+ @if $grid-rtl == true {
35
+ $_margin: left;
36
+ }
37
+ }
38
+ }
39
+ // $grid-flexbox == false
40
+ @else {
41
+ @if $grid-rtl == true {
42
+ $_float: right;
43
+ $_margin: left;
44
+ }
45
+ }
46
+
47
+ @if $grid-flexbox == true {
48
+ @if $grid-flexbox-justify != space-between {
49
+ margin-#{$_margin}: gutter-width();
50
+ }
51
+ }
52
+ @else { // $grid-flexbox == false
53
+ @if $_position != last and $grid-collapse == false {
54
+ margin-#{$_margin}: gutter-width();
55
+ }
56
+ float: $_float;
57
+ }
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,25 @@
1
+ // ==================================================
2
+ // Container Display
3
+ // ==================================================
4
+ @mixin container-display($_flexbox: default) {
5
+ @if $_flexbox == default {
6
+ $_flexbox: $grid-flexbox;
7
+ }
8
+
9
+ @if $_flexbox == true {
10
+ width: 100%;
11
+ display: flex;
12
+ flex-wrap: wrap;
13
+ justify-content: $grid-flexbox-justify;
14
+ &:after {
15
+ display: none;
16
+ }
17
+ }
18
+ @else {
19
+ &:after {
20
+ content: " ";
21
+ display: block;
22
+ clear: both;
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,19 @@
1
+ // ==================================================
2
+ // Container
3
+ // ==================================================
4
+ @mixin container($_columns: true) {
5
+ @include container-display;
6
+
7
+ @if type-of($_columns) == number and $_columns > 0 {
8
+ max-width: column-width($_columns, false);
9
+ }
10
+ @else if $_columns == true or $_columns != false {
11
+ margin-left: auto;
12
+ margin-right: auto;
13
+ max-width: $grid-width;
14
+ }
15
+
16
+ @if $grid-rtl == true {
17
+ direction: rtl;
18
+ }
19
+ }
@@ -0,0 +1,13 @@
1
+ // ==================================================
2
+ // Grid Collapse
3
+ // ==================================================
4
+ @mixin grid-collapse($_collapse: default) {
5
+ @if $_collapse == default or $_collapse != true {
6
+ $_collapse: false;
7
+ }
8
+ @else if $_collapse == true {
9
+ $_collapse: true;
10
+ }
11
+
12
+ $grid-collapse: $_collapse !global;
13
+ }
@@ -0,0 +1,13 @@
1
+ // ==================================================
2
+ // Grid Direction
3
+ // ==================================================
4
+ @mixin grid-direction($_rtl: default) {
5
+ @if $_rtl == default or $_rtl != rtl {
6
+ $_rtl: false;
7
+ }
8
+ @else if $_rtl == rtl {
9
+ $_rtl: true;
10
+ }
11
+
12
+ $grid-rtl: $_rtl !global;
13
+ }
@@ -0,0 +1,13 @@
1
+ // ==================================================
2
+ // Grid Flexbox
3
+ // ==================================================
4
+ @mixin grid-flexbox($_flexbox: default) {
5
+ @if $_flexbox == default or $_flexbox != true {
6
+ $_flexbox: false;
7
+ }
8
+ @else if $_flexbox == true {
9
+ $_flexbox: true;
10
+ }
11
+
12
+ $grid-flexbox: $_flexbox !global;
13
+ }
@@ -0,0 +1,8 @@
1
+ // ==================================================
2
+ // Grid Reset
3
+ // ==================================================
4
+ @mixin grid-reset {
5
+ $grid-collapse: false !global;
6
+ $grid-flexbox : false !global;
7
+ $grid-rtl : false !global;
8
+ }
@@ -0,0 +1,14 @@
1
+ // ==================================================
2
+ // Shift
3
+ // ==================================================
4
+ @mixin shift($_columns: 1, $_percent: true) {
5
+ $_margin: left;
6
+
7
+ @if $grid-rtl == true {
8
+ $_margin: right;
9
+ }
10
+
11
+ $_shift: shift-width($_columns, $_percent);
12
+
13
+ margin-#{$_margin}: $_shift;
14
+ }
@@ -0,0 +1,11 @@
1
+ // ==================================================
2
+ // Settings
3
+ // ==================================================
4
+ $grid-width : 64em !default;
5
+ $grid-gutter : 1.875em !default;
6
+ $grid-columns : 12 !default;
7
+ $grid-minor : 1/3 !default;
8
+ $grid-collapse : false !default;
9
+ $grid-flexbox : false !default;
10
+ $grid-flexbox-justify: space-between !default;
11
+ $grid-rtl : false !default;
data/bower.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "mcgriddle",
3
+ "version": "0.3.1",
4
+ "description": "",
5
+ "license": "MIT",
6
+ "author": {
7
+ "name": "Jonathan Suh",
8
+ "email": "hello@jonsuh.com",
9
+ "url": "https://jonsuh.com/mcgriddle"
10
+ },
11
+ "main": "_sass/mcgriddle/_mcgriddle.scss",
12
+ "keywords": [
13
+ "css",
14
+ "grid",
15
+ "flexbox",
16
+ "sass",
17
+ "scss"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/jonsuh/mcgriddle.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/jonsuh/mcgriddle/issues"
25
+ },
26
+ "ignore": [
27
+ "Gemfile",
28
+ "lib/",
29
+ "mcgriddle.gemspec",
30
+ "package.json",
31
+ "yarn.lock"
32
+ ]
33
+ }
data/bs-config.js ADDED
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ "server": {
3
+ baseDir: "./"
4
+ },
5
+ "files": [
6
+ "css/**/*.css"
7
+ ],
8
+ "browser": "default",
9
+ "injectChanges": true,
10
+ "online": false,
11
+ "open": false,
12
+ "port": 3000,
13
+ "proxy": false,
14
+ "notify": false,
15
+ "watchTask": true
16
+ };