-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
133 lines (124 loc) · 5.46 KB
/
index.html
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>ITCSS Specificity Graph</title>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<!-- SCOUT-APP CORNER -->
<style>
#scout-corner {
display: block;
width: 83px;
height: 67px;
position: absolute;
top: 0px;
left: 0px;
text-decoration: none;
}
#scout-corner:after {
content: 'Like Sass? Check out Scout-App 2';
position: absolute;
top: 5px;
left: -330px;
display: inline-block;
width: 100%;
min-width: 139px;
max-width: 300px;
background: #FFD255;
border: 1px solid rgba(130, 25, 25, 0.23);
border-radius: 4px;
padding: 5px 8px 5px 100px;
color: #D72D2A;
transition: 1s ease all;
z-index: 1;
}
#scout-corner:hover:after {
left: -20px;
}
#scout-corner img {
position: relative;
width: 83px;
z-index: 8;
}
</style>
<a href="http:https://scout-app.io" id="scout-corner"><img src="imgs/scout-app-corner.svg" alt="Scout-App logo icon"></a>
<!-- GITHUB CORNER -->
<style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
<a href="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/TheJaredWilcurt/itcss-specificity-graph" class="github-corner"><svg width="80" height="80" viewBox="0 0 250 250" style="position:absolute;top:0;border:0;right:0" fill="#4183d7" color="#f2f2f2"><path d="M0 0l115 115h15l12 27 108 108v-250z"/><path d="M128.3 109c-14.5-9.3-9.3-19.4-9.3-19.4 3-6.9 1.5-11 1.5-11-1.3-6.6 2.9-2.3 2.9-2.3 3.9 4.6 2.1 11 2.1 11-2.6 10.3 5.1 14.6 8.9 15.9" fill="#f2f2f2" style="transform-origin:130px 106px" class="octo-arm"/><path d="M115 115c-.1.1 3.7 1.5 4.8.4l13.9-13.8c3.2-2.4 6.2-3.2 8.5-3-8.4-10.6-14.7-24.2 1.6-40.6 4.7-4.6 10.2-6.8 15.9-7 .6-1.6 3.5-7.4 11.7-10.9 0 0 4.7 2.4 7.4 16.1 4.3 2.4 8.4 5.6 12.1 9.2 3.6 3.6 6.8 7.8 9.2 12.2 13.7 2.6 16.2 7.3 16.2 7.3-3.6 8.2-9.4 11.1-10.9 11.7-.3 5.8-2.4 11.2-7.1 15.9-16.4 16.4-30 10-40.6 1.6.2 2.8-1 6.8-5 10.8l-11.7 11.6c-1.2 1.2.6 5.4.8 5.3z" fill="#f2f2f2" class="octo-body"/></svg></a>
<div id="wrapper">
<h1>ITCSS: Specificity graph</h1>
<div class="explanation">
<p id="yourValues"></p>
</div>
<div class="chart"></div>
<h2>Paste your CSS:</h2>
<textarea id="paste">a { text-decoration: none; }
p a { color: #00F; }
div p span a { border-bottom: 1px solid #000; }
.text-center { text-align: center; }
.text-center.selected { background-color: #FF0; }
.selected.valid.new ul li a { text-shadow: 0 0 5px #FFF }
.selected.valid.new.logged-in ul li a { border-radius: 4px; }
#downloads .active { font-size: 23px; }</textarea>
<h2 id="data">Your data:</h2>
<ul id="pills">
<li data-pill="array" class="selected">Array</li>
<li data-pill="json">JSON</li>
<li data-pill="csv">CSV</li>
</ul>
<textarea class="data array"></textarea>
<textarea class="data json"></textarea>
<textarea class="data csv"></textarea>
</div>
<script type="text/javascript" src="js/ven.jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="js/ven.svglinegraph.js"></script>
<script type="text/javascript" src="js/ven.selectorstoarray.js"></script>
<script type="text/javascript" src="js/ven.specificity.js"></script>
<script>
function processCSS (css) {
//define vars
var graph = [];
var graphJSON = {};
var graphCSV = [];
//Convert the CSS to JSON
var selectors = window.selectorsToArray(css);
//Loop through each rule
for (var i = 0; i < selectors.length; i++) {
var selector = selectors[i];
var spec = SPECIFICITY.calculate(selector)[0].specificityArray;
var worth = 0;
worth = worth + (spec[0] * 1000); // inline-styles
worth = worth + (spec[1] * 100); // #id
worth = worth + (spec[2] * 10); // .class[attr]:psuedo
worth = worth + (spec[3] * 1); // tag
//Add this selectors total value (111) to the graph array
graph.push(worth);
graphJSON[i] = { [selector]: worth };
graphCSV.push(selector + ', ' + worth);
}
//Update the UI
chart.createChart('.chart', graph);
$('.data.array').html(graph.join(', '));
$('.data.json').html(JSON.stringify(graphJSON, null, 2));
$('.data.csv').html(graphCSV.join('\r\n'));
}
function updateChart () {
var css = $("#paste").val();
processCSS(css);
}
$("#paste").change(updateChart);
$("#paste").keyup(updateChart);
$(".data.json,.data.csv").hide();
$("#pills li").click(function () {
var selection = $(this).data('pill');
$('#pills li').removeClass('selected');
$(this).addClass('selected');
$('.data').hide();
$('.data.' + selection).show();
});
updateChart();
</script>
</body>
</html>