quantity-queries 0.3 → 0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27af58380f1095ba6712bdee07903c8cbfa16e8a
4
- data.tar.gz: 093e7c311fb519136ba5de27313d981d78048498
3
+ metadata.gz: 0560b5c09bd33a74008faa3e727e10f8675f18bd
4
+ data.tar.gz: 16fbfb76b7cefd8635062884a9fc742b9c3c2368
5
5
  SHA512:
6
- metadata.gz: 64ce70879377bc8ffcebee73fb86654d6e1e60bfc9cef825e7c15ffa83af9f693289dc8796dbb0920ce42815705982ead37ea1de14ed36ac02820549c2163230
7
- data.tar.gz: 3c2e04017c8979fd4e0a22224756d06a5494e4593b210e6c45cac1500560311733434e496cc05f227a86e88a619a9c0229dee52820964cc890ac0337a9571407
6
+ metadata.gz: 2b358e16029c320a4f0f40dc0df22bd8b2884536b4fb938731fc468615e04b977dd7baf36d66dd5c4b4779da04845458089af2945b3098f8a91642361bf160f2
7
+ data.tar.gz: 4f6f5f7e13fe362efa764d099a0a770e9e3fdd98bf0ab19d0e46122ffc64116040768c5896d7b78deb4c34581073c038313a94654559014d4e94c95a6a90c030
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0
4
+
5
+ * Added exactly() mixin
6
+
7
+ ## 0.3.0
8
+
9
+ * Added more checks
10
+
11
+ ## 0.2.0
12
+
13
+ * Small fixes
14
+
3
15
  ## 0.1.0
4
16
 
5
17
  * Initial release
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Quantity Queries mixins
2
2
 
3
- Simple quantity queries mixins for Sass. Use quantity as a condition. Learn more about quantity queries in this [A List Apart article](http://alistapart.com/article/quantity-queries-for-css).
3
+ Simple quantity queries mixins for Sass. Use quantity as a condition to style your items. Learn more about quantity queries in this [A List Apart article](http://alistapart.com/article/quantity-queries-for-css). See the mixins in action in this [CodePen Demo](http://codepen.io/danielguillan/pen/GgBOxm)
4
+
5
+ [![Build Status](https://travis-ci.org/danielguillan/quantity-queries.svg?branch=master)](https://travis-ci.org/danielguillan/quantity-queries)
4
6
 
5
7
  ## Install
6
8
 
@@ -27,25 +29,32 @@ Import it into your main stylesheet:
27
29
 
28
30
  @import 'quantity-queries';
29
31
 
30
- ### at-least
32
+ ### at-least()
31
33
 
32
- Target the items inside elements that contain N items or more:
34
+ Target the items inside elements that contain `$count` items or more:
33
35
 
34
36
  @include at-least($count) { ... }
35
37
 
36
38
 
37
- ### at-most
39
+ ### at-most()
40
+
41
+ Target the items inside elements that contain `$count` items or less:
42
+
43
+ @include at-most($count) { ... }
44
+
45
+
46
+ ### between()
38
47
 
39
- Target the items inside elements that contain N items or less:
48
+ Target the items inside elements that contain a range between `$first` and `$last` items:
40
49
 
41
- @include nope($count) { ... }
50
+ @include between($first, $last) { ... }
42
51
 
43
52
 
44
- ### between
53
+ ### exactly()
45
54
 
46
- Target the items inside elements that contain between X and Y items:
55
+ Target the items inside elements that contain exactly `$count` items:
47
56
 
48
- @include between($at-least, $at-most) { ... }
57
+ @include exactly($count) { ... }
49
58
 
50
59
  ### Example
51
60
 
@@ -68,22 +77,28 @@ ul > li {
68
77
  @include between(5, 8) {
69
78
  background-color: green;
70
79
  }
80
+
81
+ // Add a shadow to `li` items when there are exactly 8 items
82
+ @include exactly(8) {
83
+ box-shadow: 0 1px 3px #000;
84
+ }
71
85
  }
72
86
  ```
73
87
 
74
88
  ### Custom selector
75
89
 
76
- The quantity query mixins assume you want to use the current simple selector for
77
- all your items by default. `li` in the previous example. If you need a diffrent
78
- selector or want it to be selector agnostic (a.k.a. the universal selector: `*`)
79
- you just need to pass it in the mixin:
90
+ The quantity query mixins assume you want to use the current last simple selector for all the items by default (`li` in the above example). If you need a different selector or want the quantity query to be selector agnostic pass the desired selector to the mixin.
80
91
 
81
92
  ```scss
82
93
 
83
94
  nav div {
84
- @include at-leat(4, '*') { ... }; // selector agnostic
95
+ @include at-least(4, '*') { ... }; // selector agnostic (universal selector)
85
96
  @include between(4, 8, 'span') { ... }; // use span instead of div
86
97
  }
87
98
  ```
88
99
 
89
- ### Demo on [CodePen](http://codepen.io/danielguillan/pen/GgBOxm)
100
+ ## Demo on [CodePen](http://codepen.io/danielguillan/pen/GgBOxm)
101
+
102
+ ## [LESS version](https://github.com/adjohnson916/quantity-queries.less)
103
+ (by [@adjohnson916](https://github.com/adjohnson916))
104
+
@@ -3,6 +3,6 @@ extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
3
3
  Compass::Frameworks.register('quantity-queries', :path => extension_path)
4
4
 
5
5
  module QuantityQueries
6
- VERSION = "0.3"
7
- DATE = "2015-03-04"
6
+ VERSION = "0.4"
7
+ DATE = "2015-03-09"
8
8
  end
@@ -7,6 +7,7 @@
7
7
  // 3. At least
8
8
  // 4. At most
9
9
  // 5. Between
10
+ // 6. Exactly
10
11
 
11
12
 
12
13
  // -----------------------------------------------------------------------------
@@ -76,7 +77,7 @@
76
77
  $selector-append: ':nth-last-child(n+#{$count})';
77
78
 
78
79
  @if type-of($count) != 'number' or not unitless($count) or $count < 1 {
79
- @error '`#{$count}` is not a valid number for `at-leat`';
80
+ @error '`#{$count}` is not a valid number for `at-least`';
80
81
  }
81
82
 
82
83
  @if $selector != null and (type-of($selector) != 'string' or length($selector) > 1) {
@@ -118,10 +119,10 @@
118
119
  @error '`#{$selector}` is not a valid selector for `at-most`';
119
120
  }
120
121
 
121
- $at-least-selector: _build-quantity-selector($selector-append, $selector);
122
+ $at-most-selector: _build-quantity-selector($selector-append, $selector);
122
123
 
123
124
 
124
- @at-root #{$at-least-selector} {
125
+ @at-root #{$at-most-selector} {
125
126
  @content;
126
127
  }
127
128
  }
@@ -148,11 +149,11 @@
148
149
  $selector-append: ':nth-last-child(n+#{$first}):nth-last-child(-n+#{$last}):first-child';
149
150
 
150
151
  @if type-of($first) != 'number' or not unitless($first) or $first < 1 {
151
- @error '`#{$first}` is not a valid number for `at-leat`';
152
+ @error '`#{$first}` is not a valid number for `between`';
152
153
  }
153
154
 
154
155
  @if type-of($last) != 'number' or not unitless($last) or $last < 1 {
155
- @error '`#{$last}` is not a valid number for `at-leat`';
156
+ @error '`#{$last}` is not a valid number for `between`';
156
157
  }
157
158
 
158
159
  @if $first > $last {
@@ -163,10 +164,45 @@
163
164
  @error '`#{$selector}` is not a valid selector for `between`';
164
165
  }
165
166
 
166
- $at-least-selector: _build-quantity-selector($selector-append, $selector);
167
+ $between-selector: _build-quantity-selector($selector-append, $selector);
167
168
 
168
169
 
169
- @at-root #{$at-least-selector} {
170
+ @at-root #{$between-selector} {
171
+ @content;
172
+ }
173
+ }
174
+
175
+
176
+ // -----------------------------------------------------------------------------
177
+ // 6. Exactly
178
+ // -----------------------------------------------------------------------------
179
+
180
+ /// Query when total items is exactly N items
181
+ /// @param {number} $count - Quantity to match (equal)
182
+ /// @example scss - Make the items color red when there are exactly 4 items
183
+ /// ul li {
184
+ /// @include exactly(4) { color: red; }
185
+ /// }
186
+ /// @example scss - Make the items color blue when there are exactly 6 items and use '*' (element agnostic) as the item selector
187
+ /// ul li {
188
+ /// @include exactly(6, '*') { color: blue; }
189
+ /// }
190
+
191
+ @mixin exactly($count, $selector: null) {
192
+ $selector-append: ':nth-last-child(#{$count}):first-child';
193
+
194
+ @if type-of($count) != 'number' or not unitless($count) or $count < 1 {
195
+ @error '`#{$count}` is not a valid number for `exactly`';
196
+ }
197
+
198
+ @if $selector != null and (type-of($selector) != 'string' or length($selector) > 1) {
199
+ @error '`#{$selector}` is not a valid selector for `exactly`';
200
+ }
201
+
202
+ $exactly-selector: _build-quantity-selector($selector-append, $selector);
203
+
204
+
205
+ @at-root #{$exactly-selector} {
170
206
  @content;
171
207
  }
172
208
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quantity-queries
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Guillan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-04 00:00:00.000000000 Z
11
+ date: 2015-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sass
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.0
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.0.0
40
+ version: '1.0'
41
41
  description: Simple item quantity queries mixins for Sass
42
42
  email:
43
43
  - daniel.guillan@gmail.com