singularity-quick-spanner 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 38deba1770ea38217a35bcdf3177da601deeec72
4
+ data.tar.gz: e0b7187f77a2f7a24376b54c808a81ec4738efab
5
+ SHA512:
6
+ metadata.gz: ff3a6d3424d7aac2a5a092f44de93ab8c2b113130b268f19b5f21893ffdcfc951813b845a53a9f9ed17c1127ccc73c3f727c95d8c23dd36711c82d6409e6f8d8
7
+ data.tar.gz: ea9235fdd410228d4af02737f7e8cf1bd0708d14dabc3ddf303c8c20fb4d3e6f84ec3b947a1943d92c576cb7b4b8aa74b40b3cbe6c974f1fbe87d0cb70b0aa21
@@ -0,0 +1,12 @@
1
+ if (defined? Compass)
2
+ require 'singularitygs'
3
+ Compass::Frameworks.register(
4
+ "singularity-quick-spanner",
5
+ :path => "#{File.dirname(__FILE__)}/.."
6
+ )
7
+ end
8
+
9
+ module SingularityQuickSpanner
10
+ VERSION = "0.1.1"
11
+ DATE = "2014-06-24"
12
+ end
@@ -0,0 +1,174 @@
1
+ //////////////////////
2
+ // Default settings //
3
+ //////////////////////
4
+
5
+ $sqs-thumb-span-pseudoclass: child !default !global
6
+ $sqs-thumb-span-center-last-row: false !default !global
7
+ $sqs-thumb-span-bottom-margins: true !default !global
8
+ $sqs-thumb-span-cancel-last-row-margins: false !default !global
9
+ $sqs-thumb-span-overhead-min: 1 !default !global
10
+ $sqs-thumb-span-overhead-max: 20 !default !global
11
+ $sqs-buffer: () !default !global
12
+
13
+
14
+
15
+ ////////////
16
+ // Mixins //
17
+ ////////////
18
+
19
+ // Removes existing Singularity grid and gutter definitions
20
+ // and sets new ones.
21
+ =reset-grid($grid: 2, $gutter: 0.1)
22
+ +sgs-reset(grids)
23
+ +sgs-reset(gutters)
24
+ +add-grid($grid)
25
+ +add-gutter($gutter)
26
+
27
+
28
+
29
+ // Saves current grid/gutter definition into a buffer
30
+ =save-grid
31
+ $sqs-buffer: (grids: sgs-get(grids), gutters: sgs-get(gutters)) !global
32
+
33
+
34
+
35
+ // Restores grid/gutter definition from a buffer
36
+ =restore-grid
37
+ $i-only-exist-to-have-a-funciton-executed: sgs-set(grids, map-get($sqs-buffer, grids))
38
+ $i-like-food-more-than-i-like-people: sgs-set(gutters, map-get($sqs-buffer, gutters))
39
+
40
+
41
+ // Should be applied to a class corresponding to each thumbnail (grid cell).
42
+ // Spans thumbnails in a grid by applying float spans to the nth-child/nth-of-type pseudoclasses.
43
+ //
44
+ // This makes most sense with symmetric grids, but it will still do the job
45
+ // if an asymmetric grid is provided.
46
+ //
47
+ // Arguments:
48
+ //- `$cols`: The number of columns to use.
49
+ // Allowed values: a positive unitless integer. Default is the current grid definition.
50
+ //
51
+ //- `$guts`: Gutter size, relative to a single column size.
52
+ // Allowed values: a non-negative float. Default is the current gutter definition.
53
+ //
54
+ //- `$gutstyle`: Gutter style. Default is the current gutter definition.
55
+ // Allowed values: i don't know. :) This value is simply passed to Singularity. See the [corresponding docs page](https://github.com/Team-Sass/Singularity/wiki/Creating-Grids#gutter-styles).
56
+ //
57
+ //- `$pseudoclass`: The pseudoclass used to apply spans to is constructed with ":nth-" and this value.
58
+ // Allowed values: `child` (default) or `of-type`.
59
+ //
60
+ //- `$center-last-row`: The last row of thumbnails may contain less elements than any other row. To make it look better, it can be centered.
61
+ // Allowed values: `true` or `false` (default).
62
+ //
63
+ //- `$bottom-margins`: Applies bottom margins to thumbnails proportional to grid gutters. This results in even vertical and horizontal gutters.
64
+ // Allowed values: `true` (default) or `false`.
65
+ //
66
+ //- `$cancel-last-row-margins`: Negate bottom margins for thumbnails in the last row, so that the parent doesn't have what appears to be bottom padding.
67
+ // Allowed values: `true` or `false` (default).
68
+ //
69
+ // The `$center-last-row` and `$cancel-last-row-margins` apply styles to the first item of the last row using a combination of `nth-child` and `nth-last-child` pseudoselectors. This would normally work only if you know the exact number of items in the grid. For these features to work with an arbitrary number of items, an excessive amount of CSS has to be generated. Use the `$overhead-min` and `$overhead-max` arguments to set the range of quantities of items to be styled. The larger the range, the more CSS will be generaged. Hold tight and pray for gzip compression.
70
+ //
71
+ // - `$overhead-min`: The starting number of grid items for which an excessive number of CSS should be generated.
72
+ // Allowed values: a positive unitless integer. Default: 1.
73
+ //
74
+ // - `$overhead-max`: The last number of grid items for which an excessive number of CSS should be generated.
75
+ // Allowed values: a positive unitless integer. Default: 20.
76
+ //
77
+ // If you know the exact number of items in the grid, set both arguments to the same value and no excessive CSS will be created.
78
+
79
+ =thumb-span($cols: find-grid(), $guts: find-gutter(), $gutstyle: find-gutter-style(), $pseudoclass: $sqs-thumb-span-pseudoclass, $center-last-row: $sqs-thumb-span-center-last-row, $bottom-margins: $sqs-thumb-span-bottom-margins, $cancel-last-row-margins: $sqs-thumb-span-cancel-last-row-margins, $overhead-min: $sqs-thumb-span-overhead-min, $overhead-max: $sqs-thumb-span-overhead-max)
80
+
81
+ +layout($cols, $guts, $gutter-style: $gutstyle)
82
+
83
+ // Detect an asymmetric grid, work around it
84
+ @if length($cols) > 1
85
+ $cols: length($cols)
86
+
87
+ // Apply the span
88
+ +float-span(1)
89
+ &:nth-#{$pseudoclass}(#{$cols}n+#{$cols})
90
+ +float-span(1, 'last')
91
+
92
+ // Applying bottom margins
93
+ @if $bottom-margins
94
+ margin-bottom: $guts / ( $cols + ($cols - 1) * $guts) * 100%
95
+
96
+ // Canceling last row margins
97
+ @if $cancel-last-row-margins
98
+
99
+ // Building a compound selector
100
+ $selector: ()
101
+ @for $i from 1 through $cols
102
+ $fragment: #{'&:nth-last-' + $pseudoclass + '(' + $i +')'}
103
+ $selector: append($selector, $fragment, comma)
104
+
105
+ #{$selector}
106
+ margin-bottom: 0
107
+
108
+ // Targeting the thumbnail from both beginning and end
109
+ @if $center-last-row or $cancel-last-row-margins
110
+
111
+ $selectors-center-last-row: ()
112
+ $selectors-cancel-margin: ()
113
+
114
+ // Looping through the numbers of thumbnails
115
+ @for $i from $overhead-min through $overhead-max
116
+
117
+ // Number of items in the last row
118
+ $remainder: $i % $cols
119
+
120
+ // Zero means the last row is full, no need to do anything
121
+ @if $remainder > 0
122
+
123
+ // Targeting an item from beginning and end at the same time
124
+ $fragment: #{"&:nth-" + $pseudoclass + "(" + ($i - $remainder + 1) + "):nth-last-" + $pseudoclass + "(" + $remainder + ")"}
125
+
126
+ // Centering the last row
127
+ @if $center-last-row
128
+ $margin: grid-span(1, 1) * ($cols - $remainder) / 2
129
+
130
+ $selector: if(map-has-key($selectors-center-last-row, $margin), map-get($selectors-center-last-row, $margin), ())
131
+ $selectors-center-last-row: map-merge($selectors-center-last-row, ($margin: append($selector, $fragment, comma)))
132
+
133
+
134
+ // Clearing the first item in the first row
135
+ // So that it doesn't cling to bottom margins
136
+ @if $cancel-last-row-margins
137
+ $selectors-cancel-margin: append($selectors-cancel-margin, $fragment, comma)
138
+
139
+
140
+ @if $center-last-row and length($selectors-center-last-row) > 0
141
+ @each $margin, $selector in $selectors-center-last-row
142
+ @if length($selector) > 0
143
+ #{$selector}
144
+ margin-left: $margin
145
+
146
+ @if $cancel-last-row-margins
147
+ @if length($selectors-cancel-margin) > 0
148
+ #{$selectors-cancel-margin}
149
+ clear: both
150
+
151
+
152
+ //This mixin leverages Breakpoint Slicer to create a responsive thumbnail grid. Within every slice (media query), it will apply a thumb-span, increasing the number of columns for every subsequent slice.
153
+ //
154
+ // Arguments:
155
+ //
156
+ //- `$start-cols`: Number of columns to start in the first slice.
157
+ // Allowed values: A positive unitless integer. Default: 1.
158
+ //
159
+ //- `$start-slice`: Slice number to start with.
160
+ // Allowed values: A positive unitless integer. Default: 1.
161
+ //
162
+ //It can accepts all arguments available for `thumb-grid` (except `$cols`, which is calculated dynmamically). Don't forget to define `$guts`!
163
+
164
+ =rwd-thumb-span($start-cols: 1, $start-slice: 1, $guts: 0.1, $gutstyle: find-gutter-style(), $pseudoclass: $sqs-thumb-span-pseudoclass, $center-last-row: $sqs-thumb-span-center-last-row, $bottom-margins: $sqs-thumb-span-bottom-margins, $cancel-last-row-margins: $sqs-thumb-span-cancel-last-row-margins, $overhead-min: $sqs-thumb-span-overhead-min, $overhead-max: $sqs-thumb-span-overhead-max)
165
+
166
+ @if not function-exists(at)
167
+ @warn "Singularity Quick Spanner's `rwd-thumb-span` mixin requires Breakpoint Slicer: https://github.com/lolmaus/breakpoint-slicer"
168
+
169
+ @for $i from 1 through (total-slices() - $start-slice + 1)
170
+ $slice: $start-slice + $i - 1
171
+ $cols: $start-cols + $i - 1
172
+
173
+ +at($slice)
174
+ +thumb-span($cols, $guts, $gutstyle, $pseudoclass, $center-last-row, $bottom-margins, $cancel-last-row-margins, $overhead-min, $overhead-max)
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: singularity-quick-spanner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - lolmaus (Andrey Mikhaylov)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sass
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: singularitygs
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.2.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: breakpoint
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 2.4.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.4.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: breakpoint-slicer
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.4
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.4
69
+ description: A collection of handy shortcut mixins for the Singularity grid system
70
+ email:
71
+ - lolmaus@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - lib/singularity-quick-spanner.rb
77
+ - stylesheets/_singularity-quick-spanner.sass
78
+ homepage: https://github.com/lolmaus/singularity-quick-spanner
79
+ licenses: []
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '1.2'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.3.0
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: 'Saves you some hassle for: working with multiple grid definitions on the
101
+ same page; spanning a symmetrical thumbnail grid; spanning a responsive symmetrical
102
+ thumbnail grid.'
103
+ test_files: []