shelves 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/shelves.rb +2 -0
- data/lib/shelves/version.rb +1 -1
- data/scss/shelves/_functions.scss +87 -45
- data/scss/shelves/_settings.scss +15 -7
- data/scss/shelves/mixins/_base.scss +88 -39
- data/scss/shelves/mixins/_generators.scss +189 -114
- data/scss/shelves/mixins/_modifiers.scss +48 -12
- metadata +4 -4
data/lib/shelves.rb
CHANGED
@@ -16,6 +16,8 @@ if defined? ::Rails
|
|
16
16
|
require 'shelves/extensions/rails'
|
17
17
|
elsif defined? ::Sprockets::Plugin
|
18
18
|
require 'shelves/extensions/sprockets'
|
19
|
+
elsif defined? ::Sprockets && Sprockets.respond_to?(:append_path)
|
20
|
+
Sprockets.append_path Shelves.stylesheets_path
|
19
21
|
else
|
20
22
|
require 'shelves/extensions/compass'
|
21
23
|
end
|
data/lib/shelves/version.rb
CHANGED
@@ -3,14 +3,32 @@
|
|
3
3
|
// width relative to that number of columns.
|
4
4
|
//
|
5
5
|
// $context - The number of columns encapsulating the column.
|
6
|
-
// Defaults to the
|
6
|
+
// Defaults to the the value of $total.
|
7
|
+
// $total - The total number of columns in the grid.
|
8
|
+
// Defaults to the value of $shelves-columns.
|
9
|
+
// $gutter - The width of the gutter in the root context (in %).
|
10
|
+
// Defaults to the value of $shelves-gutter.
|
7
11
|
//
|
8
|
-
@function column-width(
|
9
|
-
|
10
|
-
|
12
|
+
@function column-width(
|
13
|
+
$context: nil,
|
14
|
+
$total: $shelves-columns,
|
15
|
+
$gutter: $shelves-gutter
|
16
|
+
) {
|
17
|
+
@if type-of($context) != 'number' or $context > $total {
|
18
|
+
$context: $total;
|
19
|
+
}
|
20
|
+
|
21
|
+
@if $context <= 1 {
|
22
|
+
@return 100%;
|
23
|
+
}
|
24
|
+
@else if $context >= $total {
|
25
|
+
$column-gutter: column-gutter($total: $total, $gutter: $gutter);
|
26
|
+
@return (100% - ($total - 1) * $column-gutter) / $total;
|
11
27
|
}
|
12
28
|
@else {
|
13
|
-
|
29
|
+
$column-width: column-width($total: $total, $gutter: $gutter);
|
30
|
+
$context-width: columns-width($n: $context, $total: $total, $gutter: $gutter);
|
31
|
+
@return $column-width * (100% / $context-width);
|
14
32
|
}
|
15
33
|
}
|
16
34
|
|
@@ -18,14 +36,30 @@
|
|
18
36
|
// this returns the gutter width relative to that number of columns.
|
19
37
|
//
|
20
38
|
// $context - The number of columns encapsulating the gutter.
|
21
|
-
// Defaults to the
|
39
|
+
// Defaults to the the value of $total.
|
40
|
+
// $total - The total number of columns in the grid.
|
41
|
+
// Defaults to the value of $shelves-columns.
|
42
|
+
// $gutter - The width of the gutter in the root context (in %).
|
43
|
+
// Defaults to the value of $shelves-gutter.
|
22
44
|
//
|
23
|
-
@function column-gutter(
|
24
|
-
|
25
|
-
|
45
|
+
@function column-gutter(
|
46
|
+
$context: nil,
|
47
|
+
$total: $shelves-columns,
|
48
|
+
$gutter: $shelves-gutter
|
49
|
+
) {
|
50
|
+
@if type-of($context) != 'number' or $context > $total {
|
51
|
+
$context: $total;
|
52
|
+
}
|
53
|
+
|
54
|
+
@if $context <= 1 {
|
55
|
+
@return 0%;
|
56
|
+
}
|
57
|
+
@else if $context >= $total {
|
58
|
+
@return $gutter;
|
26
59
|
}
|
27
60
|
@else {
|
28
|
-
|
61
|
+
$context-width: columns-width($n: $context, $total: $total);
|
62
|
+
@return $gutter * (100% / $context-width);
|
29
63
|
}
|
30
64
|
}
|
31
65
|
|
@@ -35,22 +69,34 @@
|
|
35
69
|
//
|
36
70
|
// $n - The number of columns to measure.
|
37
71
|
// $context - The number of columns encapsulating the columns.
|
38
|
-
// Defaults to the
|
72
|
+
// Defaults to the the value of $total.
|
73
|
+
// $total - The total number of columns in the grid.
|
74
|
+
// Defaults to the value of $shelves-columns.
|
75
|
+
// $gutter - The width of the gutter in the root context (in %).
|
76
|
+
// Defaults to the value of $shelves-gutter.
|
39
77
|
//
|
40
|
-
@function columns-width(
|
41
|
-
|
42
|
-
|
78
|
+
@function columns-width(
|
79
|
+
$n,
|
80
|
+
$context: nil,
|
81
|
+
$total: $shelves-columns,
|
82
|
+
$gutter: $shelves-gutter
|
83
|
+
) {
|
84
|
+
@if type-of($context) != 'number' or $context > $total {
|
85
|
+
$context: $total;
|
43
86
|
}
|
44
87
|
|
45
|
-
$
|
46
|
-
|
47
|
-
|
48
|
-
@if $
|
49
|
-
|
50
|
-
|
88
|
+
@if $n <= 1 {
|
89
|
+
@return column-width($context, $total, $gutter);
|
90
|
+
}
|
91
|
+
@else if $n >= $context {
|
92
|
+
@return 100%;
|
93
|
+
}
|
94
|
+
@else {
|
95
|
+
$column-width: column-width($context, $total, $gutter);
|
96
|
+
$column-gutter: column-gutter($context, $total, $gutter);
|
97
|
+
|
98
|
+
@return $column-width * $n + $column-gutter * ($n - 1);
|
51
99
|
}
|
52
|
-
|
53
|
-
@return $column-width * $n + $column-gutter * ($n - 1);
|
54
100
|
}
|
55
101
|
|
56
102
|
// Returns the total distance to shift a column the given
|
@@ -59,10 +105,19 @@
|
|
59
105
|
//
|
60
106
|
// $n - The number of columns to measure.
|
61
107
|
// $context - The number of columns encapsulating the columns.
|
62
|
-
// Defaults to the
|
108
|
+
// Defaults to the the value of $total.
|
109
|
+
// $total - The total number of columns in the grid.
|
110
|
+
// Defaults to the value of $shelves-columns.
|
111
|
+
// $gutter - The width of the gutter in the root context (in %).
|
112
|
+
// Defaults to the value of $shelves-gutter.
|
63
113
|
//
|
64
|
-
@function columns-distance(
|
65
|
-
|
114
|
+
@function columns-distance(
|
115
|
+
$n,
|
116
|
+
$context: nil,
|
117
|
+
$total: $shelves-columns,
|
118
|
+
$gutter: $shelves-gutter
|
119
|
+
) {
|
120
|
+
@return columns-width($n, $context, $total, $gutter) + column-gutter($context, $total, $gutter);
|
66
121
|
}
|
67
122
|
|
68
123
|
// Returns a column selector with the given class name,
|
@@ -79,26 +134,13 @@
|
|
79
134
|
@return ".#{$class-name}#{$separator}#{$index}";
|
80
135
|
}
|
81
136
|
|
82
|
-
// Returns a
|
83
|
-
// the last number.
|
84
|
-
//
|
85
|
-
// range(1, 6); // 1, 2, 3, 4, 5
|
86
|
-
// range(1, 6, $step: 2); // 1, 3, 5
|
87
|
-
//
|
88
|
-
// Arguments:
|
137
|
+
// Returns a selector that will select all columns with the given prefix.
|
89
138
|
//
|
90
|
-
// $
|
91
|
-
//
|
92
|
-
//
|
93
|
-
//
|
94
|
-
// Defaults to 1.
|
139
|
+
// $class-name - The class name to build the selector from.
|
140
|
+
// It should NOT have a preceding ".".
|
141
|
+
// $separator - The separator between the class name and index.
|
142
|
+
// Defaults to $shelves-separator.
|
95
143
|
//
|
96
|
-
@function
|
97
|
-
|
98
|
-
$i: $start + $step;
|
99
|
-
@while $i < $end {
|
100
|
-
$list: join($list, $i);
|
101
|
-
$i: $i + $step;
|
102
|
-
}
|
103
|
-
@return $list;
|
144
|
+
@function columns-selector($class-name, $separator: $shelves-separator) {
|
145
|
+
@return "[class*=\"#{$class-name}#{$separator}\"]";
|
104
146
|
}
|
data/scss/shelves/_settings.scss
CHANGED
@@ -1,17 +1,25 @@
|
|
1
1
|
// Default Grid Settings
|
2
|
-
$shelves-width:
|
2
|
+
$shelves-width: 1040px !default;
|
3
3
|
$shelves-max-width: $shelves-width !default;
|
4
4
|
$shelves-min-width: 767px !default;
|
5
5
|
$shelves-columns: 12 !default;
|
6
|
-
$shelves-
|
7
|
-
$shelves-
|
8
|
-
$shelves-gutter: 20px !default;
|
6
|
+
$shelves-margin: 32px !default;
|
7
|
+
$shelves-gutter: 24px !default;
|
9
8
|
|
10
|
-
//
|
9
|
+
// Convert the gutter to a percentage if necessary.
|
11
10
|
@if unit($shelves-gutter) != "%" {
|
12
11
|
$shelves-gutter: percentage($shelves-gutter / $shelves-max-width);
|
13
12
|
}
|
14
|
-
|
13
|
+
|
14
|
+
// Default Tablet Settings
|
15
|
+
$shelves-tablet-columns: 6 !default;
|
16
|
+
$shelves-tablet-margin: $shelves-margin * 0.75 !default;
|
17
|
+
$shelves-tablet-gutter: $shelves-gutter * 1.5 !default;
|
18
|
+
|
19
|
+
// Default Mobile Settings
|
20
|
+
$shelves-mobile-columns: 4 !default;
|
21
|
+
$shelves-mobile-margin: $shelves-margin * 0.5 !default;
|
22
|
+
$shelves-mobile-gutter: $shelves-gutter * 2.375 !default;
|
15
23
|
|
16
24
|
// Default Class Names
|
17
25
|
// (Note the lack of the preceding ".")
|
@@ -23,5 +31,5 @@ $shelves-suffix-name: "suffix" !default;
|
|
23
31
|
$shelves-push-name: "push" !default;
|
24
32
|
$shelves-pull-name: "pull" !default;
|
25
33
|
$shelves-separator: "-" !default;
|
34
|
+
$shelves-tablet-column-name: "tablet-column" !default;
|
26
35
|
$shelves-mobile-column-name: "mobile-column" !default;
|
27
|
-
$shelves-columns-selector: "[class*=\"#{$shelves-column-name}#{$shelves-separator}\"]" !default;
|
@@ -11,34 +11,44 @@
|
|
11
11
|
// Includes the styles for the row element. This includes
|
12
12
|
// a clearfix, widths, and centering.
|
13
13
|
//
|
14
|
-
// $max-width
|
15
|
-
//
|
16
|
-
//
|
17
|
-
// $min-width
|
18
|
-
//
|
19
|
-
// $
|
20
|
-
//
|
14
|
+
// $max-width - The max width of the row element. If this is
|
15
|
+
// false, the row is completely fluid. Defaults
|
16
|
+
// to $shelves-max-width.
|
17
|
+
// $min-width - The min width, for browsers that don't support
|
18
|
+
// media queries. Defaults to $shelves-min-width.
|
19
|
+
// $reset-if-tablet - Include styles for resetting the row at
|
20
|
+
// tablet sizes. Defaults to true.
|
21
|
+
// $reset-if-mobile - Include styles for resetting the row at
|
22
|
+
// mobile sizes. Defaults to false.
|
21
23
|
//
|
22
|
-
@mixin row(
|
24
|
+
@mixin row(
|
25
|
+
$max-width: $shelves-max-width,
|
26
|
+
$min-width: $shelves-min-width,
|
27
|
+
$reset-if-tablet: true,
|
28
|
+
$reset-if-mobile: false
|
29
|
+
) {
|
23
30
|
@include pie-clearfix;
|
24
31
|
width: 100%;
|
25
32
|
|
26
|
-
@if $max-width
|
33
|
+
@if type-of($max-width) == 'number' {
|
27
34
|
max-width: $max-width;
|
28
35
|
margin-left: auto;
|
29
36
|
margin-right: auto;
|
30
37
|
}
|
31
|
-
|
32
|
-
@if $min-width != false {
|
38
|
+
@if type-of($min-width) == 'number' {
|
33
39
|
min-width: $min-width;
|
34
40
|
|
35
41
|
.#{$shelves-row-name} {
|
36
42
|
min-width: 0;
|
37
43
|
}
|
38
44
|
}
|
39
|
-
|
40
|
-
|
41
|
-
|
45
|
+
@if $reset-if-tablet {
|
46
|
+
@media screen and (max-width: 800px) {
|
47
|
+
@include reset-row;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
@if $reset-if-mobile {
|
51
|
+
@media screen and (max-width: 480px) {
|
42
52
|
@include reset-row;
|
43
53
|
}
|
44
54
|
}
|
@@ -47,37 +57,58 @@
|
|
47
57
|
// Creates a column that spans the given number of
|
48
58
|
// grid columns.
|
49
59
|
//
|
50
|
-
// $n
|
51
|
-
// $context
|
52
|
-
//
|
53
|
-
// $
|
54
|
-
//
|
60
|
+
// $n - The number of columns the element should span.
|
61
|
+
// $context - The number of columns encapsulating the element.
|
62
|
+
// Defaults to the the value of $total.
|
63
|
+
// $total - The total number of columns in the grid.
|
64
|
+
// Defaults to the value of $shelves-columns.
|
65
|
+
// $gutter - The width of the gutter in the root context (in %).
|
66
|
+
// Defaults to the value of $shelves-gutter.
|
67
|
+
// $reset-if-tablet - Include styles for resetting the column at
|
68
|
+
// tablet sizes. Defaults to true.
|
69
|
+
// $reset-if-mobile - Include styles for resetting the column at
|
70
|
+
// mobile sizes. Defaults to false.
|
55
71
|
//
|
56
|
-
@mixin column(
|
57
|
-
|
58
|
-
|
59
|
-
|
72
|
+
@mixin column(
|
73
|
+
$n,
|
74
|
+
$context: nil,
|
75
|
+
$total: $shelves-columns,
|
76
|
+
$gutter: $shelves-gutter,
|
77
|
+
$reset-if-tablet: true,
|
78
|
+
$reset-if-mobile: false
|
79
|
+
) {
|
80
|
+
@include column-base($reset-if-tablet, $reset-if-mobile);
|
81
|
+
@include column-gutter($context, $total, $gutter);
|
82
|
+
@include columns-width($n, $context, $total, $gutter);
|
60
83
|
}
|
61
84
|
|
62
85
|
// Sets up an element to be a column in the grid system.
|
63
86
|
// This is used internally to generate grids, Use column($n)
|
64
87
|
// instead to create fully functioning columns.
|
65
88
|
//
|
66
|
-
// $
|
67
|
-
//
|
89
|
+
// $reset-if-tablet - Include styles for resetting the column at
|
90
|
+
// tablet sizes. Defaults to true.
|
91
|
+
// $reset-if-mobile - Include styles for resetting the column at
|
92
|
+
// mobile sizes. Defaults to false.
|
68
93
|
//
|
69
|
-
@mixin column-base($
|
94
|
+
@mixin column-base($reset-if-tablet: true, $reset-if-mobile: false) {
|
70
95
|
display: block;
|
71
96
|
float: left;
|
72
97
|
min-height: 1px;
|
73
98
|
position: relative;
|
74
99
|
|
75
100
|
@if $legacy-support-for-ie7 {
|
101
|
+
// IE6-7 incorrectly rounds up percentage widths (breaking layouts)
|
102
|
+
// http://ejohn.org/blog/sub-pixel-problems-in-css/
|
76
103
|
*margin-right: -1px;
|
77
104
|
}
|
78
|
-
|
79
|
-
|
80
|
-
|
105
|
+
@if $reset-if-tablet {
|
106
|
+
@media screen and (max-width: 800px) {
|
107
|
+
@include reset-column;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
@if $reset-if-mobile {
|
111
|
+
@media screen and (max-width: 480px) {
|
81
112
|
@include reset-column;
|
82
113
|
}
|
83
114
|
}
|
@@ -87,23 +118,41 @@
|
|
87
118
|
//
|
88
119
|
// $n - The number of columns the element should span.
|
89
120
|
// $context - The number of columns encapsulating the element.
|
90
|
-
// Defaults to the
|
121
|
+
// Defaults to the the value of $total.
|
122
|
+
// $total - The total number of columns in the grid.
|
123
|
+
// Defaults to the value of $shelves-columns.
|
124
|
+
// $gutter - The width of the gutter in the root context (in %).
|
125
|
+
// Defaults to the value of $shelves-gutter.
|
91
126
|
//
|
92
|
-
@mixin columns-width(
|
93
|
-
|
127
|
+
@mixin columns-width(
|
128
|
+
$n,
|
129
|
+
$context: nil,
|
130
|
+
$total: $shelves-columns,
|
131
|
+
$gutter: $shelves-gutter
|
132
|
+
) {
|
133
|
+
width: columns-width($n, $context, $total, $gutter);
|
94
134
|
}
|
95
135
|
|
96
136
|
// Includes the gutter for a column on the grid.
|
97
137
|
//
|
98
|
-
// $context
|
99
|
-
//
|
100
|
-
// $
|
101
|
-
//
|
138
|
+
// $context - The number of columns encapsulating the element.
|
139
|
+
// Defaults to the the value of $total.
|
140
|
+
// $total - The total number of columns in the grid.
|
141
|
+
// Defaults to the value of $shelves-columns.
|
142
|
+
// $gutter - The width of the gutter in the root context (in %).
|
143
|
+
// Defaults to the value of $shelves-gutter.
|
144
|
+
// $reset-first - Removes the gutter for the first column in a row.
|
145
|
+
// Defaults to true.
|
102
146
|
//
|
103
|
-
@mixin column-gutter(
|
104
|
-
|
147
|
+
@mixin column-gutter(
|
148
|
+
$context: nil,
|
149
|
+
$total: $shelves-columns,
|
150
|
+
$gutter: $shelves-gutter,
|
151
|
+
$reset-first: true
|
152
|
+
) {
|
153
|
+
margin-left: column-gutter($context, $total, $gutter);
|
105
154
|
|
106
|
-
@if $
|
155
|
+
@if $reset-first {
|
107
156
|
&:first-child {
|
108
157
|
@include reset-column-gutter;
|
109
158
|
}
|
@@ -1,96 +1,178 @@
|
|
1
1
|
// Generates the entire grid, made up of reusable classes for a modular OOCSS
|
2
2
|
// approach to using the grid. All of the class names can be customized.
|
3
3
|
//
|
4
|
-
// $
|
5
|
-
//
|
6
|
-
// $
|
7
|
-
//
|
8
|
-
// $
|
9
|
-
//
|
10
|
-
// $
|
11
|
-
//
|
12
|
-
// $
|
13
|
-
//
|
14
|
-
// $
|
15
|
-
//
|
16
|
-
// $
|
17
|
-
//
|
18
|
-
// $
|
19
|
-
//
|
20
|
-
//
|
21
|
-
//
|
4
|
+
// $prefixes - Include prefix classes. Deafults to true.
|
5
|
+
// $suffixes - Include suffix classes. Deafults to true.
|
6
|
+
// $pushes - Include push classes. Deafults to true.
|
7
|
+
// $pulls - Include pull classes. Deafults to true.
|
8
|
+
// $nested - Include nested columns in the default grid.
|
9
|
+
// Defaults to true.
|
10
|
+
// $nested-prefixes - Include prefix classes for neseted columns.
|
11
|
+
// Defaults to true.
|
12
|
+
// $nested-suffixes - Include suffix classes for neseted columns.
|
13
|
+
// Defaults to true.
|
14
|
+
// $nested-pushes - Include push classes for neseted columns.
|
15
|
+
// Defaults to false.
|
16
|
+
// $nested-pulls - Include pull classes for neseted columns.
|
17
|
+
// Defaults to false.
|
18
|
+
// $tablet - Include tablet columns & resets. Defaults to true.
|
19
|
+
// $tablet-prefixes - Include prefix classes for tablet columns.
|
20
|
+
// Defaults to false.
|
21
|
+
// $tablet-suffixes - Include suffix classes for tablet columns.
|
22
|
+
// Defaults to false.
|
23
|
+
// $tablet-pushes - Include push classes for tablet columns.
|
24
|
+
// Defaults to false.
|
25
|
+
// $tablet-pulls - Include pull classes for tablet columns.
|
26
|
+
// Defaults to false.
|
27
|
+
// $mobile - Include mobile columns & resets. Defaults to true.
|
28
|
+
// $mobile-prefixes - Include prefix classes for mobile columns.
|
29
|
+
// Defaults to false.
|
30
|
+
// $mobile-suffixes - Include suffix classes for mobile columns.
|
31
|
+
// Defaults to false.
|
32
|
+
// $mobile-pushes - Include push classes for mobile columns.
|
33
|
+
// Defaults to false.
|
34
|
+
// $mobile-pulls - Include pull classes for mobile columns.
|
35
|
+
// Defaults to false.
|
22
36
|
//
|
23
37
|
@mixin shelves(
|
24
|
-
$
|
25
|
-
$
|
26
|
-
$
|
27
|
-
$
|
28
|
-
$
|
29
|
-
$
|
30
|
-
$
|
31
|
-
$
|
32
|
-
$
|
33
|
-
$
|
34
|
-
$
|
38
|
+
$prefixes: true,
|
39
|
+
$suffixes: true,
|
40
|
+
$pushes: true,
|
41
|
+
$pulls: true,
|
42
|
+
$nested: true,
|
43
|
+
$nested-prefixes: true,
|
44
|
+
$nested-suffixes: true,
|
45
|
+
$nested-pushes: false,
|
46
|
+
$nested-pulls: false,
|
47
|
+
$tablet: true,
|
48
|
+
$tablet-prefixes: false,
|
49
|
+
$tablet-suffixes: false,
|
50
|
+
$tablet-pushes: false,
|
51
|
+
$tablet-pulls: false,
|
52
|
+
$mobile: true,
|
53
|
+
$mobile-prefixes: false,
|
54
|
+
$mobile-suffixes: false,
|
55
|
+
$mobile-pushes: false,
|
56
|
+
$mobile-pulls: false
|
35
57
|
) {
|
36
58
|
|
37
|
-
@include shelves-base;
|
59
|
+
@include shelves-base($reset-if-tablet: false, $reset-if-mobile: false);
|
38
60
|
@include shelves-columns(
|
39
|
-
$
|
40
|
-
$
|
41
|
-
$
|
42
|
-
$
|
43
|
-
$include-pull: $include-pull
|
61
|
+
$prefixes: $prefixes,
|
62
|
+
$suffixes: $suffixes,
|
63
|
+
$pushes: $pushes,
|
64
|
+
$pulls: $pulls
|
44
65
|
);
|
45
66
|
|
46
|
-
@if $
|
67
|
+
@if $nested {
|
47
68
|
@for $i from 1 to $shelves-columns - 1 {
|
48
69
|
// Loop background through the columns
|
49
70
|
// to cascade the nested column properties.
|
50
71
|
$i: $shelves-columns - $i;
|
51
72
|
|
52
73
|
#{column-selector($shelves-column-name, $i)} {
|
74
|
+
#{columns-selector($shelves-column-name)} {
|
75
|
+
@include column-gutter($i, $reset-first: false);
|
76
|
+
}
|
77
|
+
|
53
78
|
@include shelves-columns(
|
54
|
-
$
|
55
|
-
$
|
56
|
-
$
|
57
|
-
$
|
58
|
-
$
|
59
|
-
$include-suffix: $include-nested-suffix,
|
60
|
-
$include-push: $include-nested-push,
|
61
|
-
$include-pull: $include-nested-pull
|
79
|
+
$context: $i,
|
80
|
+
$prefixes: $nested-prefixes,
|
81
|
+
$suffixes: $nested-suffixes,
|
82
|
+
$pushes: $nested-pushes,
|
83
|
+
$pulls: $nested-pulls
|
62
84
|
);
|
63
85
|
}
|
64
86
|
}
|
65
87
|
}
|
66
88
|
|
67
|
-
@
|
68
|
-
@
|
89
|
+
@if $tablet {
|
90
|
+
@media screen and (max-width: 800px) {
|
91
|
+
@if $shelves-tablet-margin != $shelves-margin {
|
92
|
+
.#{$shelves-container-name} {
|
93
|
+
@include container($shelves-tablet-margin);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
69
97
|
@include shelves-resets;
|
98
|
+
|
99
|
+
// Use the extra specificity from the row class
|
100
|
+
// to apply tablet column properties even when nested
|
101
|
+
.#{$shelves-row-name} {
|
102
|
+
#{columns-selector($shelves-tablet-column-name)} {
|
103
|
+
@include column-base($reset-if-tablet: false, $reset-if-mobile: false);
|
104
|
+
@include column-gutter($total: $shelves-tablet-columns, $gutter: $shelves-tablet-gutter);
|
105
|
+
}
|
106
|
+
|
107
|
+
@include shelves-columns(
|
108
|
+
$column-name: $shelves-tablet-column-name,
|
109
|
+
$total: $shelves-tablet-columns,
|
110
|
+
$gutter: $shelves-tablet-gutter,
|
111
|
+
$prefixes: $tablet-prefixes,
|
112
|
+
$suffixes: $tablet-suffixes,
|
113
|
+
$pushes: $tablet-pushes,
|
114
|
+
$pulls: $tablet-pulls
|
115
|
+
);
|
116
|
+
}
|
70
117
|
}
|
71
|
-
|
72
|
-
|
118
|
+
}
|
119
|
+
|
120
|
+
@if $mobile {
|
121
|
+
@media screen and (max-width: 480px) {
|
122
|
+
@if $shelves-mobile-margin != if($tablet, $shelves-margin, $shelves-tablet-margin) {
|
123
|
+
.#{$shelves-container-name} {
|
124
|
+
@include container($shelves-mobile-margin);
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
@include shelves-resets($reset-row: $tablet == false);
|
129
|
+
|
130
|
+
// Use the extra specificity from the row class
|
131
|
+
// to apply mobile column properties even when nested
|
132
|
+
.#{$shelves-row-name} {
|
133
|
+
#{columns-selector($shelves-mobile-column-name)} {
|
134
|
+
@include column-base($reset-if-tablet: false, $reset-if-mobile: false);
|
135
|
+
@include column-gutter($total: $shelves-mobile-columns, $gutter: $shelves-mobile-gutter);
|
136
|
+
}
|
137
|
+
|
138
|
+
@include shelves-columns(
|
139
|
+
$column-name: $shelves-mobile-column-name,
|
140
|
+
$total: $shelves-mobile-columns,
|
141
|
+
$gutter: $shelves-mobile-gutter,
|
142
|
+
$prefixes: $mobile-prefixes,
|
143
|
+
$suffixes: $mobile-suffixes,
|
144
|
+
$pushes: $mobile-pushes,
|
145
|
+
$pulls: $mobile-pulls
|
146
|
+
);
|
147
|
+
}
|
73
148
|
}
|
74
149
|
}
|
75
150
|
}
|
76
151
|
|
77
152
|
// Generates the grid's base classes, namely the
|
78
153
|
// the row and container elements.
|
79
|
-
|
154
|
+
//
|
155
|
+
// $reset-if-tablet - Include styles for resetting the grid at
|
156
|
+
// tablet sizes. Defaults to true.
|
157
|
+
// $reset-if-mobile - Include styles for resetting the grid at
|
158
|
+
// mobile sizes. Defaults to false.
|
159
|
+
//
|
160
|
+
@mixin shelves-base($reset-if-tablet: true, $reset-if-mobile: false) {
|
80
161
|
.#{$shelves-container-name} {
|
81
162
|
@include container;
|
82
163
|
}
|
83
164
|
|
84
165
|
.#{$shelves-row-name} {
|
85
|
-
@include row($
|
166
|
+
@include row($reset-if-tablet: $reset-if-tablet, $reset-if-mobile: $reset-if-mobile);
|
86
167
|
}
|
87
168
|
|
88
|
-
#{$shelves-
|
89
|
-
@include column-base($
|
90
|
-
@include column-gutter($
|
91
|
-
|
92
|
-
|
93
|
-
|
169
|
+
#{columns-selector($shelves-column-name)} {
|
170
|
+
@include column-base($reset-if-tablet: $reset-if-tablet, $reset-if-mobile: $reset-if-mobile);
|
171
|
+
@include column-gutter($reset-first: false);
|
172
|
+
}
|
173
|
+
|
174
|
+
.#{$shelves-row-name} {
|
175
|
+
#{columns-selector($shelves-column-name)} {
|
94
176
|
&:first-child {
|
95
177
|
@include reset-column-gutter;
|
96
178
|
}
|
@@ -102,67 +184,70 @@
|
|
102
184
|
// the columns. This can be used in different contexts, varying
|
103
185
|
// the number of columns if necessary.
|
104
186
|
//
|
105
|
-
// $
|
106
|
-
//
|
107
|
-
// $
|
108
|
-
//
|
109
|
-
//
|
110
|
-
//
|
111
|
-
//
|
112
|
-
// $
|
113
|
-
//
|
114
|
-
// $
|
187
|
+
// $column-name - The name of the column to generate widths for.
|
188
|
+
// Defaults to $shelves-column-name
|
189
|
+
// $start - Where to start the loop. Defaults to 1.
|
190
|
+
// $end - Where to end the loop.
|
191
|
+
// Defaults to the value of $total.
|
192
|
+
// $context - The context of generated classes.
|
193
|
+
// Defaults to the value of $total.
|
194
|
+
// $total - The total number of columns in the grid.
|
195
|
+
// Defaults to the value of $shelves-columns.
|
196
|
+
// $gutter - The width of the gutter in the root context (in %).
|
197
|
+
// Defaults to the value of $shelves-gutter.
|
198
|
+
// $prefixes - Include prefix classes. Deafults to true.
|
199
|
+
// $suffixes - Include suffix classes. Deafults to true.
|
200
|
+
// $pushes - Include push classes. Deafults to true.
|
201
|
+
// $pulls - Include pull classes. Deafults to true.
|
115
202
|
//
|
116
203
|
@mixin shelves-columns(
|
117
|
-
$
|
118
|
-
$
|
119
|
-
$
|
120
|
-
$
|
121
|
-
$
|
122
|
-
$
|
123
|
-
$
|
124
|
-
$
|
204
|
+
$column-name: $shelves-column-name,
|
205
|
+
$start: 1,
|
206
|
+
$end: nil,
|
207
|
+
$context: nil,
|
208
|
+
$total: $shelves-columns,
|
209
|
+
$gutter: $shelves-gutter,
|
210
|
+
$prefixes: true,
|
211
|
+
$suffixes: true,
|
212
|
+
$pushes: true,
|
213
|
+
$pulls: true
|
125
214
|
) {
|
126
|
-
@if $
|
127
|
-
|
128
|
-
|
129
|
-
|
215
|
+
@if type-of($context) != 'number' or $context > $total {
|
216
|
+
$context: $total;
|
217
|
+
}
|
218
|
+
@if type-of($end) != 'number' or $end > $context {
|
219
|
+
$end: $context;
|
130
220
|
}
|
131
|
-
|
132
221
|
@for $i from $start to $end {
|
133
|
-
#{column-selector($
|
134
|
-
@include columns-width($i, $context);
|
222
|
+
#{column-selector($column-name, $i)} {
|
223
|
+
@include columns-width($i, $context, $total, $gutter);
|
135
224
|
}
|
136
225
|
}
|
137
|
-
|
138
|
-
@if $include-prefix == true {
|
226
|
+
@if $prefixes {
|
139
227
|
@for $i from $start to $end {
|
140
228
|
#{column-selector($shelves-prefix-name, $i)} {
|
141
|
-
@include column-prefix($i, $context);
|
229
|
+
@include column-prefix($i, $context, $total, $gutter);
|
142
230
|
}
|
143
231
|
}
|
144
232
|
}
|
145
|
-
|
146
|
-
@if $include-suffix == true {
|
233
|
+
@if $suffixes {
|
147
234
|
@for $i from $start to $end {
|
148
235
|
#{column-selector($shelves-suffix-name, $i)} {
|
149
|
-
@include column-suffix($i, $context);
|
236
|
+
@include column-suffix($i, $context, $total, $gutter);
|
150
237
|
}
|
151
238
|
}
|
152
239
|
}
|
153
|
-
|
154
|
-
@if $include-push == true {
|
240
|
+
@if $pushes {
|
155
241
|
@for $i from $start to $end {
|
156
242
|
#{column-selector($shelves-push-name, $i)} {
|
157
|
-
@include column-push($i, $context);
|
243
|
+
@include column-push($i, $context, $total, $gutter);
|
158
244
|
}
|
159
245
|
}
|
160
246
|
}
|
161
|
-
|
162
|
-
@if $include-pull == true {
|
247
|
+
@if $pulls {
|
163
248
|
@for $i from $start to $end {
|
164
249
|
#{column-selector($shelves-pull-name, $i)} {
|
165
|
-
@include column-pull($i, $context);
|
250
|
+
@include column-pull($i, $context, $total, $gutter);
|
166
251
|
}
|
167
252
|
}
|
168
253
|
}
|
@@ -171,29 +256,19 @@
|
|
171
256
|
// Resets the row and column elements so they take up
|
172
257
|
// the full width of their parent element. All modifying
|
173
258
|
// effects are removed from columns as well.
|
174
|
-
|
259
|
+
//
|
260
|
+
// $reset-row - Reset the row. Defaults to true.
|
261
|
+
// $reset-columns - Reset columns (including nested columns).
|
262
|
+
// Defaults to true
|
263
|
+
//
|
264
|
+
@mixin shelves-resets($reset-row: true, $reset-columns: true) {
|
175
265
|
.#{$shelves-row-name} {
|
176
|
-
@
|
177
|
-
|
178
|
-
|
179
|
-
#{$shelves-columns-selector} {
|
180
|
-
&,
|
181
|
-
& #{$shelves-columns-selector} {
|
182
|
-
@include reset-column;
|
266
|
+
@if $reset-row {
|
267
|
+
@include reset-row;
|
183
268
|
}
|
184
|
-
|
185
|
-
}
|
186
|
-
|
187
|
-
// Generates the classes for columns on mobile devices.
|
188
|
-
@mixin shelves-mobile-columns {
|
189
|
-
.#{$shelves-mobile-column-name} {
|
190
|
-
@include column-base($mobile-reset: false);
|
191
|
-
@include column-gutter($include-first-column: false);
|
192
|
-
|
193
|
-
$mobile-step: floor($shelves-columns / $shelves-mobile-columns);
|
194
|
-
@each $i in range($start: $mobile-step, $end: $shelves-columns, $step: $mobile-step) {
|
195
|
-
&#{column-selector($shelves-column-name, $i)} {
|
196
|
-
@include columns-width($i);
|
269
|
+
@if $reset-columns {
|
270
|
+
#{columns-selector($shelves-column-name)} {
|
271
|
+
@include reset-column;
|
197
272
|
}
|
198
273
|
}
|
199
274
|
}
|
@@ -3,10 +3,19 @@
|
|
3
3
|
//
|
4
4
|
// $n - The number of columns to pad.
|
5
5
|
// $context - The number of columns encapsulating the element.
|
6
|
-
// Defaults to the
|
6
|
+
// Defaults to the the value of $total.
|
7
|
+
// $total - The total number of columns in the grid.
|
8
|
+
// Defaults to the value of $shelves-columns.
|
9
|
+
// $gutter - The width of the gutter in the root context (in %).
|
10
|
+
// Defaults to the value of $shelves-gutter.
|
7
11
|
//
|
8
|
-
@mixin column-prefix(
|
9
|
-
|
12
|
+
@mixin column-prefix(
|
13
|
+
$n,
|
14
|
+
$context: nil,
|
15
|
+
$total: $shelves-columns,
|
16
|
+
$gutter: $shelves-gutter
|
17
|
+
) {
|
18
|
+
padding-left: columns-distance($n, $context, $total, $gutter);
|
10
19
|
}
|
11
20
|
|
12
21
|
// Adds a padding suffix (which shifts the column to the left)
|
@@ -14,10 +23,19 @@
|
|
14
23
|
//
|
15
24
|
// $n - The number of columns to pad.
|
16
25
|
// $context - The number of columns encapsulating the element.
|
17
|
-
// Defaults to the
|
26
|
+
// Defaults to the the value of $total.
|
27
|
+
// $total - The total number of columns in the grid.
|
28
|
+
// Defaults to the value of $shelves-columns.
|
29
|
+
// $gutter - The width of the gutter in the root context (in %).
|
30
|
+
// Defaults to the value of $shelves-gutter.
|
18
31
|
//
|
19
|
-
@mixin column-suffix(
|
20
|
-
|
32
|
+
@mixin column-suffix(
|
33
|
+
$n,
|
34
|
+
$context: nil,
|
35
|
+
$total: $shelves-columns,
|
36
|
+
$gutter: $shelves-gutter
|
37
|
+
) {
|
38
|
+
padding-right: columns-distance($n, $context, $total, $gutter);
|
21
39
|
}
|
22
40
|
|
23
41
|
// Reorder the content by shifting the column to the right. This
|
@@ -25,10 +43,19 @@
|
|
25
43
|
//
|
26
44
|
// $n - The number of columns to shift.
|
27
45
|
// $context - The number of columns encapsulating the element.
|
28
|
-
// Defaults to the
|
46
|
+
// Defaults to the the value of $total.
|
47
|
+
// $total - The total number of columns in the grid.
|
48
|
+
// Defaults to the value of $shelves-columns.
|
49
|
+
// $gutter - The width of the gutter in the root context (in %).
|
50
|
+
// Defaults to the value of $shelves-gutter.
|
29
51
|
//
|
30
|
-
@mixin column-push(
|
31
|
-
|
52
|
+
@mixin column-push(
|
53
|
+
$n,
|
54
|
+
$context: nil,
|
55
|
+
$total: $shelves-columns,
|
56
|
+
$gutter: $shelves-gutter
|
57
|
+
) {
|
58
|
+
left: columns-distance($n, $context, $total, $gutter);
|
32
59
|
}
|
33
60
|
|
34
61
|
// Reorder the content by shifting the column to the left. This
|
@@ -36,8 +63,17 @@
|
|
36
63
|
//
|
37
64
|
// $n - The number of columns to shift.
|
38
65
|
// $context - The number of columns encapsulating the element.
|
39
|
-
// Defaults to the
|
66
|
+
// Defaults to the the value of $total.
|
67
|
+
// $total - The total number of columns in the grid.
|
68
|
+
// Defaults to the value of $shelves-columns.
|
69
|
+
// $gutter - The width of the gutter in the root context (in %).
|
70
|
+
// Defaults to the value of $shelves-gutter.
|
40
71
|
//
|
41
|
-
@mixin column-pull(
|
42
|
-
|
72
|
+
@mixin column-pull(
|
73
|
+
$n,
|
74
|
+
$context: nil,
|
75
|
+
$total: $shelves-columns,
|
76
|
+
$gutter: $shelves-gutter
|
77
|
+
) {
|
78
|
+
right: columns-distance($n, $context, $total, $gutter);
|
43
79
|
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shelves
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pete Browne
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-03-
|
18
|
+
date: 2012-03-29 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: sass
|