smock 0.1.108 → 0.1.109
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/Gemfile.lock +1 -1
- data/app/assets/stylesheets/modules/_styleguide.sass +1 -1
- data/examples/colors.html +111 -61
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/examples/colors.html
CHANGED
@@ -1,61 +1,111 @@
|
|
1
|
-
<
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
<
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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.
|
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:
|
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:
|
433
|
+
hash: 4548531276516916762
|
434
434
|
requirements: []
|
435
435
|
rubyforge_project: smock
|
436
436
|
rubygems_version: 1.8.21
|