flint-gs 1.6.5 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -13
  3. data/lib/flint.rb +64 -4
  4. data/stylesheets/flint/config/_config.scss +3 -3
  5. data/stylesheets/flint/functions/_functions.scss +1 -1
  6. data/stylesheets/flint/functions/helpers/_helpers.scss +32 -23
  7. data/stylesheets/flint/functions/lib/_calc-breakpoint.scss +11 -11
  8. data/stylesheets/flint/functions/lib/_calc-margin.scss +40 -12
  9. data/stylesheets/flint/functions/lib/_calc-width.scss +21 -12
  10. data/stylesheets/flint/functions/lib/_exists.scss +6 -6
  11. data/stylesheets/flint/functions/lib/_fluid-width.scss +2 -2
  12. data/stylesheets/flint/functions/lib/_get-index.scss +3 -3
  13. data/stylesheets/flint/functions/lib/_get-instance-value.scss +4 -4
  14. data/stylesheets/flint/functions/lib/_get-value.scss +3 -3
  15. data/stylesheets/flint/functions/lib/_has-family-instance.scss +74 -0
  16. data/stylesheets/flint/functions/lib/_instance.scss +17 -15
  17. data/stylesheets/flint/functions/lib/_last.scss +2 -2
  18. data/stylesheets/flint/functions/lib/_list-to-string.scss +4 -4
  19. data/stylesheets/flint/functions/lib/_map-fetch.scss +6 -9
  20. data/stylesheets/flint/functions/lib/_next-index.scss +3 -3
  21. data/stylesheets/flint/functions/lib/_purge.scss +2 -2
  22. data/stylesheets/flint/functions/lib/_remove.scss +4 -4
  23. data/stylesheets/flint/functions/lib/_replace-substring.scss +21 -15
  24. data/stylesheets/flint/functions/lib/_replace.scss +3 -3
  25. data/stylesheets/flint/functions/lib/_steal-key.scss +3 -3
  26. data/stylesheets/flint/functions/lib/_steal-values.scss +3 -3
  27. data/stylesheets/flint/functions/lib/_string-to-list.scss +63 -57
  28. data/stylesheets/flint/functions/lib/_string-to-number.scss +42 -38
  29. data/stylesheets/flint/functions/lib/_support-syntax-bem.scss +3 -3
  30. data/stylesheets/flint/functions/lib/_support-syntax.scss +4 -4
  31. data/stylesheets/flint/functions/lib/_types-in-list.scss +3 -3
  32. data/stylesheets/flint/functions/lib/_use-syntax.scss +3 -3
  33. data/stylesheets/flint/globals/_globals.scss +20 -4
  34. data/stylesheets/flint/mixins/lib/_calculate.scss +368 -563
  35. data/stylesheets/flint/mixins/lib/_clearfix.scss +7 -7
  36. data/stylesheets/flint/mixins/lib/_main.scss +244 -244
  37. data/stylesheets/flint/mixins/lib/_new-instance.scss +20 -20
  38. data/stylesheets/flint/mixins/lib/_print-instance.scss +14 -14
  39. metadata +3 -3
  40. data/stylesheets/flint/functions/lib/_get-family-instance.scss +0 -59
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20b0ac111ab807d8eb76b531deaa0cdf2b63e576
4
- data.tar.gz: 4d2b7b97bc1bbfe4d2b20e79095a933fc65b9f96
3
+ metadata.gz: 6932f06e68ffebf4f0b177fc44128552ff044b6f
4
+ data.tar.gz: 36b23e74c25af88ed0c7bf3ad0eb5e23ae48e1f8
5
5
  SHA512:
6
- metadata.gz: 9c82db0bef304ec23e6b4a96eb57249cefde32d14071d26ccfe6860455ddc877fd350e9c4bd9f4a616224dd0a4aa967960c06881a61320ff384b97c7f41f7223
7
- data.tar.gz: bb7dd6765110ab39bac125be563a538e93164c9df8bb5b5d900e55d1fd50b96c9538aceb76e15ec19cc27ea0be26cc302f3010ea84246d286683fcbd45d4309b
6
+ metadata.gz: 63a6c699683f46828943c4961b27c2fe4dfd28e63faa5c42df7ed9858122ad6c425a8e93cff28de899bf7877f30b9da587233b135aed3834c5c83902b1a184d6
7
+ data.tar.gz: 88b955fbb75b8db9b05758fe8983922b96845eaf953203652ddd78adf88d909f9dcd9e66f87926d4560c3270a0aed31c09b9a24852e5c0aa51ec8061a04a3007
data/README.md CHANGED
@@ -30,12 +30,12 @@ Enjoy.
30
30
 
31
31
  ## Requirements
32
32
 
33
- * Sass ~> 3.3.0
34
- * Compass ~> 1.0.0.alpha.19
33
+ * Sass ~> `3.3.0`
34
+ * Compass ~> `1.0.0.alpha.19`
35
35
 
36
36
  ## Installation
37
37
 
38
- 1. Install via Ruby `gem install flint-gs`, or Bower `bower install flint`
38
+ 1. Install via Ruby `gem install flint-gs`, or Bower `bower install flint --save-dev`
39
39
  2. Add `require "flint"` to your `config.rb`
40
40
  3. Import it in your stylesheets with `@import "flint"`
41
41
 
@@ -291,11 +291,11 @@ Outputs, *(with debug mode on)*
291
291
 
292
292
  As you can see, since `"desktop"` is the framework `"default"`, it uses the output for desktop as the base styles. You can set this to any breakpoint you like. **So if you like mobile-first, you can do that.**
293
293
 
294
- Whatever your `"default"` is set to, **flint** will not wrap those styles in media-queries, so that they may be used in non-supported browsers.
294
+ Whatever your `"default"` is set to, flint will not wrap those styles in media-queries, so that they may be used in non-supported browsers.
295
295
 
296
296
  ### Recursive shorthand with identical context
297
297
 
298
- Use this if your nested context is *identical* across all breakpoints. The `context` is the span of the elements parent. ***Update:*** You can now use `$context: auto`, and we'll do all the calculations for you. Just be sure a parent element with a Flint `instance` actually exists or you'll get some weird output, or none at all. **Using `$context: auto` on fixed grids, the width with will be calculated by the parents width, instead of using the base breakpoints width.**
298
+ Use this if your nested context is *identical* across all breakpoints. The `context` is the span of the elements parent. ***Update:*** You can now use `$context: auto`, and we'll do all the calculations for you. Just be sure a parent element with a Flint `instance` actually flint-exists or you'll get some weird output, or none at all. **Using `$context: auto` on fixed grids, the width with will be calculated by the parents width, instead of using the base breakpoints width.**
299
299
 
300
300
  ```scss
301
301
  // `auto` will work
@@ -362,7 +362,7 @@ Outputs,
362
362
 
363
363
  ### Recursive shorthand with variable context
364
364
 
365
- Use this if your context is *not* indentical across breakpoints. The `context` is the span of the elements parent. You can now use `$context: auto`, and we'll do all the calculations for you. Just be sure a parent selector with a Flint instance actually exists, or you'll throw a warning and get no output.
365
+ Use this if your context is *not* indentical across breakpoints. The `context` is the span of the elements parent. You can now use `$context: auto`, and we'll do all the calculations for you. Just be sure a parent selector with a Flint instance actually flint-exists, or you'll throw a warning and get no output.
366
366
 
367
367
  When using `$context: auto` on fixed grids, Flint will automagically calculate based on the width of the closest parent element instance.
368
368
 
@@ -456,7 +456,7 @@ Outputs,
456
456
 
457
457
  ### Variable shorthand with context
458
458
 
459
- Use this if you're *nesting* columns using the variable shorthand. The `context` is the span of the elements parent. Before using `$context: auto`, be sure a parent element with a Flint `instance` actually exists or you'll get some weird output, or none at all.
459
+ Use this if you're *nesting* columns using the variable shorthand. The `context` is the span of the elements parent. Before using `$context: auto`, be sure a parent element with a Flint `instance` actually flint-exists or you'll get some weird output, or none at all.
460
460
 
461
461
  ```scss
462
462
  .parent {
@@ -631,7 +631,7 @@ Here are different gutter modifiers that may be called in when defining spans us
631
631
 
632
632
  // no right margin
633
633
  .gutter-omega {
634
- // other aliases : `no-right` | `last`
634
+ // other aliases : `no-right` | `flint-last`
635
635
  @include _(desktop, 4, $gutter: omega);
636
636
  }
637
637
 
@@ -860,12 +860,12 @@ function parses the selector string (for example, `.block__element__element`) li
860
860
  // -------------------------------------------------------------------------------
861
861
  // @return [list] : parsed list of selectors according to syntax
862
862
 
863
- @function support-syntax-bem($selectors) {
863
+ @function flint-support-syntax-bem($selectors) {
864
864
  // Clean up selector, remove double underscores for spaces
865
865
  // add psudeo character to differentiate selectors
866
- $selectors: replace-substring($selectors, "__", "/");
866
+ $selectors: flint-replace-substring($selectors, "__", "/");
867
867
  // Parse string to list
868
- $selectors: string-to-list($selectors, "/");
868
+ $selectors: flint-string-to-list($selectors, "/");
869
869
  // Define top-most parent of selector
870
870
  $parent: nth($selectors, 1);
871
871
  // Create new list of parsed selectors
@@ -888,8 +888,8 @@ function parses the selector string (for example, `.block__element__element`) li
888
888
  ```
889
889
 
890
890
  This will be parsed into a list of selectors: `.block, .block__element, .block__element__element`. The list of selectors can then be used by
891
- instance system to look up a selectors parent, etc. To support your own preferred syntax: create a `support-syntax-<syntax-name>` function
892
- and hook into it through the config `"support-syntax": "<syntax-name>"` option -- the system will attempt to use the `call()` function in
891
+ instance system to look up a selectors parent, etc. To support your own preferred syntax: create a `flint-support-syntax-<syntax-name>` function
892
+ and hook into it through the config `"flint-support-syntax": "<syntax-name>"` option -- the system will attempt to use the `call()` function in
893
893
  order to parse the selector string.
894
894
 
895
895
  #### Officially supported syntaxes
data/lib/flint.rb CHANGED
@@ -1,17 +1,77 @@
1
1
  require 'compass'
2
+
2
3
  extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
3
4
  Compass::Frameworks.register('flint', :path => extension_path)
4
5
 
5
- # Version is a number. If a version contains alphas, it will be created as a prerelease version
6
6
  # Date is in the form of YYYY-MM-DD
7
7
  module Flint
8
- VERSION = "1.6.5"
9
- DATE = "2014-07-08"
8
+ VERSION = "1.7.0"
9
+ DATE = "2014-07-11"
10
10
  end
11
11
 
12
12
  # Custom functions
13
13
  module Sass::Script::Functions
14
+
15
+ # Use ruby functions
16
+ # ----
17
+ def flint_use_ruby()
18
+ Sass::Script::Bool.new(true)
19
+ end
20
+
21
+ # Returns stringified selector
22
+ # ----
23
+ # @return [string]
14
24
  def selector_string()
15
- return Sass::Script::String.new(environment.selector.to_s)
25
+ Sass::Script::String.new(environment.selector.to_s)
16
26
  end
27
+
28
+ # Turns string into a flat list
29
+ # ----
30
+ # @param string [string] : string
31
+ # @param separator [string] : item to find which separates substrings
32
+ # @param ignore [string] : removes remaining string beyond item
33
+ # ----
34
+ # @return [list] | error
35
+ def string_to_list(string, separator, ignore)
36
+ # Remove rest of string after ignore
37
+ ignore = string.value[/[^#{ignore}]+/]
38
+ # Get first set of strings, convert to array by separator
39
+ items = ignore.split(separator.value)
40
+ # Convert array to list
41
+ if items.count == 1
42
+ Sass::Script::String.new(items[0], :comma)
43
+ else
44
+ Sass::Script::List.new(items.map { |i| Sass::Script::String.new(i) }, :comma)
45
+ end
46
+ end
47
+
48
+ # Replace substring
49
+ # ----
50
+ # @param string [string] : string that contains substring
51
+ # @param find [string] : substring to replace
52
+ # @param replace [string] : new string to replace sub with
53
+ # ----
54
+ # @return [string]
55
+ def replace_substring(string, find, replace)
56
+ # Assert types
57
+ assert_type string, :String
58
+ assert_type find, :String
59
+ assert_type replace, :String
60
+ # Return new string
61
+ Sass::Script::String.new(string.value.gsub(find.value, replace.value))
62
+ end
63
+
64
+ # Converts string to number
65
+ # ----
66
+ # @param string [string] : string
67
+ # ----
68
+ # @return [number]
69
+ def string_to_number(string)
70
+ Sass::Script::Number.new(string.value.to_i)
71
+ end
72
+
73
+ declare :string_to_list, [:string, :separator, :ignore]
74
+ declare :replace_substring, [:string, :find, :replace]
75
+ declare :string_to_number, [:string]
76
+
17
77
  end
@@ -77,7 +77,7 @@ $flint: (
77
77
  "support-syntax": false,
78
78
 
79
79
  // Options: true | false
80
- "debug-mode": false,
81
- ),
82
- ),
80
+ "debug-mode": true,
81
+ )
82
+ )
83
83
  ) !default;
@@ -18,7 +18,7 @@
18
18
  @import "lib/calc-breakpoint";
19
19
  // Instance functions
20
20
  @import "lib/instance";
21
- @import "lib/get-family-instance";
21
+ @import "lib/has-family-instance";
22
22
  @import "lib/get-instance-value";
23
23
  // List functions
24
24
  @import "lib/list-to-string";
@@ -4,7 +4,7 @@
4
4
  // -------------------------------------------------------------------------------
5
5
  // @return [bool]
6
6
 
7
- @function is-true($value) {
7
+ @function flint-is-true($value) {
8
8
  @return if($value == null, false, $value and $value != null and $value != "" and $value != ());
9
9
  }
10
10
 
@@ -14,7 +14,7 @@
14
14
  // -------------------------------------------------------------------------------
15
15
  // @return [bool]
16
16
 
17
- @function is-map($n) {
17
+ @function flint-is-map($n) {
18
18
  @return type-of($n) == "map";
19
19
  }
20
20
 
@@ -24,7 +24,7 @@
24
24
  // -------------------------------------------------------------------------------
25
25
  // @return [bool]
26
26
 
27
- @function is-list($n) {
27
+ @function flint-is-list($n) {
28
28
  @return type-of($n) == "list";
29
29
  }
30
30
 
@@ -34,7 +34,7 @@
34
34
  // -------------------------------------------------------------------------------
35
35
  // @return [bool]
36
36
 
37
- @function is-number($n) {
37
+ @function flint-is-number($n) {
38
38
  @return type-of($n) == "number";
39
39
  }
40
40
 
@@ -44,7 +44,7 @@
44
44
  // -------------------------------------------------------------------------------
45
45
  // @return [bool]
46
46
 
47
- @function is-string($n) {
47
+ @function flint-is-string($n) {
48
48
  @return type-of($n) == "string";
49
49
  }
50
50
 
@@ -54,7 +54,7 @@
54
54
  // -------------------------------------------------------------------------------
55
55
  // @return [bool]
56
56
 
57
- @function is-not-string($n) {
57
+ @function flint-is-not-string($n) {
58
58
  @return type-of($n) != "string";
59
59
  }
60
60
 
@@ -62,11 +62,11 @@
62
62
  // -------------------------------------------------------------------------------
63
63
  // @return [list]
64
64
 
65
- @function get-all-keys() {
65
+ @function flint-get-all-keys() {
66
66
  $all-keys: ();
67
67
 
68
- @for $i from 1 through (length(map-fetch($flint, "config")) - 1) {
69
- $key: steal-key($i);
68
+ @for $i from 1 through (length(flint-map-fetch($flint, "config")) - 1) {
69
+ $key: flint-steal-key($i);
70
70
  $all-keys: append($all-keys, $key, "comma");
71
71
  }
72
72
 
@@ -77,7 +77,7 @@
77
77
  // -------------------------------------------------------------------------------
78
78
  // @return [list]
79
79
 
80
- @function get-all-breakpoints() {
80
+ @function flint-get-all-breakpoints() {
81
81
  $all-breakpoints: ();
82
82
 
83
83
  @each $map, $keys in map-get($flint, "config") {
@@ -93,14 +93,14 @@
93
93
 
94
94
  // Checks if passed $key is the highest breakpoint
95
95
  // -------------------------------------------------------------------------------
96
- // @dependence `get-value()`
96
+ // @dependence `flint-get-value()`
97
97
  // -------------------------------------------------------------------------------
98
98
  // @param $key [string] : alias of breakpoint
99
99
  // -------------------------------------------------------------------------------
100
100
  // @return [bool]
101
101
 
102
- @function is-highest-breakpoint($key) {
103
- @if get-value($key, "breakpoint") == max(get-all-breakpoints()...) {
102
+ @function flint-is-highest-breakpoint($key) {
103
+ @if flint-get-value($key, "breakpoint") == max(flint-get-all-breakpoints()...) {
104
104
  @return true;
105
105
  } @else {
106
106
  @return false;
@@ -109,14 +109,14 @@
109
109
 
110
110
  // Checks if passed $key is the lowest breakpoint
111
111
  // -------------------------------------------------------------------------------
112
- // @dependence `get-value()`
112
+ // @dependence `flint-get-value()`
113
113
  // -------------------------------------------------------------------------------
114
114
  // @param $key [string] : alias of breakpoint
115
115
  // -------------------------------------------------------------------------------
116
116
  // @return [bool]
117
117
 
118
- @function is-lowest-breakpoint($key) {
119
- @if get-value($key, "breakpoint") == min(get-all-breakpoints()...) {
118
+ @function flint-is-lowest-breakpoint($key) {
119
+ @if flint-get-value($key, "breakpoint") == min(flint-get-all-breakpoints()...) {
120
120
  @return true;
121
121
  } @else {
122
122
  @return false;
@@ -125,14 +125,14 @@
125
125
 
126
126
  // Checks if $key is grid default
127
127
  // -------------------------------------------------------------------------------
128
- // @dependence `get-value()`
128
+ // @dependence `flint-get-value()`
129
129
  // -------------------------------------------------------------------------------
130
130
  // @param $key [string] : alias of breakpoint
131
131
  // -------------------------------------------------------------------------------
132
132
  // @return [bool]
133
133
 
134
- @function is-default($key) {
135
- @if $key == get-value("settings", "default") {
134
+ @function flint-is-default($key) {
135
+ @if $key == flint-get-value("settings", "default") {
136
136
  @return true;
137
137
  } @else {
138
138
  @return false;
@@ -143,7 +143,7 @@
143
143
  // -------------------------------------------------------------------------------
144
144
  // @return [list]
145
145
 
146
- @function get-all-columns() {
146
+ @function flint-get-all-columns() {
147
147
  $all-columns: ();
148
148
 
149
149
  @each $map, $keys in map-get($flint, "config") {
@@ -161,8 +161,8 @@
161
161
  // -------------------------------------------------------------------------------
162
162
  // @return [literal]
163
163
 
164
- @function get-config-unit() {
165
- @return unit(get-value("settings", "gutter"));
164
+ @function flint-get-config-unit() {
165
+ @return unit(flint-get-value("settings", "gutter"));
166
166
  }
167
167
 
168
168
  // Convert pixel value to em
@@ -173,6 +173,15 @@
173
173
  // @return : em value of $target relative to $context
174
174
  // -------------------------------------------------------------------------------
175
175
 
176
- @function em($target, $context: $flint__base-font-size) {
176
+ @function flint-to-em($target, $context: $flint__base-font-size) {
177
177
  @return ($target / $context) * 1em;
178
178
  }
179
+
180
+ // Use Ruby functions in place of Sass functions where possiblre
181
+ // to speed up performance, especially with string functions
182
+ // -------------------------------------------------------------------------------
183
+ // @return [bool]
184
+
185
+ @function flint-use-ruby-functions() {
186
+ @return flint_use_ruby() == true;
187
+ }
@@ -6,28 +6,28 @@
6
6
  // -------------------------------------------------------------------------------
7
7
  // @return calculated value
8
8
 
9
- @function calc-breakpoint($n, $key, $i) {
9
+ @function flint-calc-breakpoint($n, $key, $i) {
10
10
  @if $n == "alias" {
11
- @if get-value("settings", "grid") == "fixed" {
12
- @if is-lowest-breakpoint($key) {
11
+ @if flint-get-value("settings", "grid") == "fixed" {
12
+ @if flint-is-lowest-breakpoint($key) {
13
13
  @return 0;
14
14
  } @else {
15
- @return get-value($key, "breakpoint");
15
+ @return flint-get-value($key, "breakpoint");
16
16
  }
17
- } @else if get-value("settings", "grid") == "fluid" {
18
- @return get-value($key, "breakpoint");
17
+ } @else if flint-get-value("settings", "grid") == "fluid" {
18
+ @return flint-get-value($key, "breakpoint");
19
19
  }
20
20
  } @else if $n == "next" {
21
- @if is-lowest-breakpoint($key) {
21
+ @if flint-is-lowest-breakpoint($key) {
22
22
  @return 0;
23
23
  } @else {
24
- @return get-value(steal-key(($i + 1)), "breakpoint");
24
+ @return flint-get-value(flint-steal-key(($i + 1)), "breakpoint");
25
25
  }
26
26
  } @else if $n == "prev" {
27
- @if is-highest-breakpoint($key) {
28
- @return get-value($key, "breakpoint");
27
+ @if flint-is-highest-breakpoint($key) {
28
+ @return flint-get-value($key, "breakpoint");
29
29
  } @else {
30
- @return get-value(steal-key(($i - 1)), "breakpoint");
30
+ @return flint-get-value(flint-steal-key(($i - 1)), "breakpoint");
31
31
  }
32
32
  }
33
33
  }
@@ -6,24 +6,52 @@
6
6
  // -------------------------------------------------------------------------------
7
7
  // @return calculated value | false
8
8
 
9
- @function calc-margin($key, $span, $context: null) {
10
- @if get-value("settings", "grid") == "fluid" {
9
+ @function flint-calc-margin($key, $span, $context: null) {
10
+ $result: false;
11
+
12
+ // Check to see if value has been cached
13
+ @if map-has-key($flint__cached-values, "#{$key, $span, $context}::margin") and $context != "auto" {
14
+ @return map-get($flint__cached-values, "#{$key, $span, $context}::margin");
15
+ }
16
+
17
+ @if flint-get-value("settings", "grid") == "fluid" {
18
+
11
19
  @if $key == "container" or $span == "container" {
12
- @return 0;
20
+
21
+ $result: 0;
22
+
13
23
  } @else if $context == null {
14
- @return fluid-width(get-value("settings", "gutter"), get-value($key, "breakpoint"));
15
- } @else if $context <= get-value($key, "columns") {
16
- @return fluid-width(get-value("settings", "gutter"), ((get-value($key, "breakpoint") / get-value($key, "columns") * $context)));
24
+
25
+ $result: flint-fluid-width(flint-get-value("settings", "gutter"), flint-get-value($key, "breakpoint"));
26
+
27
+ } @else if $context <= flint-get-value($key, "columns") {
28
+
29
+ $result: flint-fluid-width(flint-get-value("settings", "gutter"), ((flint-get-value($key, "breakpoint") / flint-get-value($key, "columns") * $context)));
30
+
17
31
  } @else {
18
- @return fluid-width(get-value("settings", "gutter") / get-value($key, "columns") * $context, ((get-value($key, "breakpoint") / get-value($key, "columns") * $context)));
32
+
33
+ $result: flint-fluid-width(flint-get-value("settings", "gutter") / flint-get-value($key, "columns") * $context, ((flint-get-value($key, "breakpoint") / flint-get-value($key, "columns") * $context)));
34
+
19
35
  }
20
- } @if get-value("settings", "grid") == "fixed" {
36
+
37
+ } @if flint-get-value("settings", "grid") == "fixed" {
38
+
21
39
  @if $key == "container" or $span == "container" {
22
- @return 0;
40
+
41
+ $result: 0;
42
+
23
43
  } @else {
24
- @return get-value("settings", "gutter");
44
+
45
+ $result: flint-get-value("settings", "gutter");
25
46
  }
26
- } @else {
27
- @return false;
47
+
28
48
  }
49
+
50
+ // Save result to cache
51
+ @if $context != "auto" {
52
+ $flint__cached-values: map-merge($flint__cached-values, ("#{$key, $span, $context}::margin": $result));
53
+ }
54
+
55
+ // Return result
56
+ @return $result;
29
57
  }