smock 0.1.108 → 0.1.109

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smock (0.1.108)
4
+ smock (0.1.109)
5
5
  sass (= 3.2.19)
6
6
  thor (= 0.19.1)
7
7
 
@@ -26,7 +26,7 @@
26
26
  border-radius: $border-radius
27
27
  text-align: center
28
28
  padding: $typecsset-magic-number / 2
29
-
29
+ +space(margin-bottom)
30
30
 
31
31
  .style-group__example__color__name,
32
32
  .style-group__example__color__hex
@@ -1,61 +1,111 @@
1
- <div class="example">
2
- <ul class="style-group__example__colors">
3
- <li class="style-group__example__color">
4
- <div class="style-group__example__color__swatch--blue"></div>
5
- <span class="style-group__example__color__name">$blue</span>
6
- <span class="style-group__example__color__hex">#1FB4DA</span>
7
- </li>
8
- <li class="style-group__example__color">
9
- <div class="style-group__example__color__swatch--green"></div>
10
- <span class="style-group__example__color__name">$green</span>
11
- <span class="style-group__example__color__hex">#82B641</span>
12
- </li>
13
- <li class="style-group__example__color">
14
- <div class="style-group__example__color__swatch--orange"></div>
15
- <span class="style-group__example__color__name">$orange</span>
16
- <span class="style-group__example__color__hex">#F67D42</span>
17
- </li>
18
- <li class="style-group__example__color">
19
- <div class="style-group__example__color__swatch--yellow"></div>
20
- <span class="style-group__example__color__name">$yellow</span>
21
- <span class="style-group__example__color__hex">#FFBE00</span>
22
- </li>
23
- <li class="style-group__example__color">
24
- <div class="style-group__example__color__swatch--red"></div>
25
- <span class="style-group__example__color__name">$red</span>
26
- <span class="style-group__example__color__hex">#E65F51</span>
27
- </li>
28
- </ul>
29
- <ul class="style-group__example__colors">
30
- <li class="style-group__example__color">
31
- <div class="style-group__example__color__swatch--black"></div>
32
- <span class="style-group__example__color__name">$black</span>
33
- <span class="style-group__example__color__hex">#000000</span>
34
- </li>
35
- <li class="style-group__example__color">
36
- <div class="style-group__example__color__swatch--gray-dark"></div>
37
- <span class="style-group__example__color__name">$gray-dark</span>
38
- <span class="style-group__example__color__hex">#454545</span>
39
- </li>
40
- <li class="style-group__example__color">
41
- <div class="style-group__example__color__swatch--gray"></div>
42
- <span class="style-group__example__color__name">$gray</span>
43
- <span class="style-group__example__color__hex">#888888</span>
44
- </li>
45
- <li class="style-group__example__color">
46
- <div class="style-group__example__color__swatch--gray-light"></div>
47
- <span class="style-group__example__color__name">$gray-light</span>
48
- <span class="style-group__example__color__hex">#BFBFBF</span>
49
- </li>
50
- <li class="style-group__example__color">
51
- <div class="style-group__example__color__swatch--gray-lightest"></div>
52
- <span class="style-group__example__color__name">$gray-lightest</span>
53
- <span class="style-group__example__color__hex">#E1E1E1</span>
54
- </li>
55
- <li class="style-group__example__color">
56
- <div class="style-group__example__color__swatch--white"></div>
57
- <span class="style-group__example__color__name">$white</span>
58
- <span class="style-group__example__color__hex">#FFFFFF</span>
59
- </li>
60
- </ul>
61
- </div>
1
+ <h3>Colors used in the styleguide</h3>
2
+ <ul id="colors" class="style-group__example__colors"></ul>
3
+ <div class="separator"></div>
4
+
5
+ <script>
6
+ var colorsEl = $('#colors');
7
+
8
+ Array.prototype.getUnique = function(){
9
+ var u = {}, a = [];
10
+ for(var i = 0, l = this.length; i < l; ++i){
11
+ if(u.hasOwnProperty(this[i])) {
12
+ continue;
13
+ }
14
+ a.push(this[i]);
15
+ u[this[i]] = 1;
16
+ }
17
+ return a;
18
+ }
19
+
20
+ function rgbToHex(R,G,B) {
21
+ return toHex(R)+toHex(G)+toHex(B);
22
+ }
23
+
24
+ function toHex(n) {
25
+ n = parseInt(n,10);
26
+ if (isNaN(n)) return "00";
27
+ n = Math.max(0,Math.min(n,255));
28
+ return "0123456789ABCDEF".charAt((n-n%16)/16)
29
+ + "0123456789ABCDEF".charAt(n%16);
30
+ }
31
+
32
+ function sortColors(colors) {
33
+ for (var c = 0; c < colors.length; c++) {
34
+ /* Get the hex value without hash symbol. */
35
+ var hex = colors[c].substring(1);
36
+
37
+ /* Get the RGB values to calculate the Hue. */
38
+ var r = parseInt(hex.substring(0,2),16)/255;
39
+ var g = parseInt(hex.substring(2,4),16)/255;
40
+ var b = parseInt(hex.substring(4,6),16)/255;
41
+
42
+ /* Getting the Max and Min values for Chroma. */
43
+ var max = Math.max.apply(Math, [r,g,b]);
44
+ var min = Math.min.apply(Math, [r,g,b]);
45
+
46
+ /* Variables for HSV value of hex color. */
47
+ var chr = max-min;
48
+ var hue = 0;
49
+ var val = max;
50
+ var sat = 0;
51
+
52
+ if (val > 0) {
53
+ /* Calculate Saturation only if Value isn't 0. */
54
+ sat = chr/val;
55
+ if (sat > 0) {
56
+ if (r == max) {
57
+ hue = 60*(((g-min)-(b-min))/chr);
58
+ if (hue < 0) {hue += 360;}
59
+ } else if (g == max) {
60
+ hue = 120+60*(((b-min)-(r-min))/chr);
61
+ } else if (b == max) {
62
+ hue = 240+60*(((r-min)-(g-min))/chr);
63
+ }
64
+ }
65
+ }
66
+
67
+ /* Modifies existing objects by adding HSV values. */
68
+ colors[c].hue = hue;
69
+ colors[c].sat = sat;
70
+ colors[c].val = val;
71
+ }
72
+
73
+ /* Sort by Hue. */
74
+ return colors.sort(function(a,b){return a.hue - b.hue;});
75
+ }
76
+
77
+ for(var i = 0; i < document.styleSheets.length; i++) {
78
+ var styleSheet = document.styleSheets[i];
79
+ console.log(styleSheet);
80
+ var rules = styleSheet.rules;
81
+ if (rules) {
82
+ var colors = [];
83
+
84
+ for(var j = 0; j < rules.length; j++) {
85
+ var rule = rules[j];
86
+ if (rule.cssText.indexOf("rgb(") > 0) {
87
+ var color = /rgb\((.*?)\)/gi.exec(rule.cssText)[1];
88
+ colors.push(color);
89
+ }
90
+ }
91
+
92
+ var uniqueColors = colors.getUnique();
93
+ var uniqueHexColors = [];
94
+ for (var i = 0; i < uniqueColors.length; i++) {
95
+ var color = uniqueColors[i];
96
+ var colorRgb = color.split(',');
97
+ var colorHex = rgbToHex(colorRgb[0], colorRgb[1], colorRgb[2]);
98
+ uniqueHexColors.push("#" + colorHex);
99
+ }
100
+
101
+ uniqueHexColors = sortColors(uniqueHexColors);
102
+ for (var i = 0; i < uniqueColors.length; i++) {
103
+ var color = uniqueHexColors[i];
104
+ var template = "<li class=\"style-group__example__color\"><div class=\"style-group__example__color__swatch\" style=\"background-color: " + color + "\"></div><span class=\"style-group__example__color__name\">" + color + "</span></li>";
105
+ colorsEl.append(template);
106
+ }
107
+ }
108
+ }
109
+
110
+
111
+ </script>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.108
4
+ version: 0.1.109
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -421,7 +421,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
421
421
  version: '0'
422
422
  segments:
423
423
  - 0
424
- hash: 2939868190048851569
424
+ hash: 4548531276516916762
425
425
  required_rubygems_version: !ruby/object:Gem::Requirement
426
426
  none: false
427
427
  requirements:
@@ -430,7 +430,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
430
430
  version: '0'
431
431
  segments:
432
432
  - 0
433
- hash: 2939868190048851569
433
+ hash: 4548531276516916762
434
434
  requirements: []
435
435
  rubyforge_project: smock
436
436
  rubygems_version: 1.8.21