-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathdemo.html
83 lines (83 loc) · 2.87 KB
/
demo.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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<style>
body {
font: 16px sans-serif;
color: #333;
width: 500px;
margin: 50px auto;
}
code {
color: teal;
}
.comment {
color: #333;
opacity: 0.8;
margin-bottom: 5px;
}
.radio-option {
display: block;
margin: 5px 0;
}
</style>
<script src="jss.js"></script>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script>
$(function() {
function updateOutput() {
$('#jss-output').html(
'<p class="comment">// Output for jss(\'code\').getAll();</p>' + JSON.stringify(jss.getAll('code'))
);
}
$('input[name="colour"]').change(function() {
jss.set('code', { color: $(this).val() });
updateOutput();
});
$('input[name="font-style"]').change(function() {
jss.set('code', { 'font-style': $(this).val() });
updateOutput();
});
$('#option-teal, #option-normal').click();
});
</script>
</head>
<body>
<h1>Thanks for trying out JSS</h1>
<p>You can add a new rule (or extend an existing rule) as follows:</p>
<code>
jss.set('code', {
color: teal;
});
</code>
<p>You can retrieve the rules for a specific CSS selector as follows:</p>
<code>
jss.getAll('code');
</code>
<p>This will return an object:</p>
<code>{"color":"teal"}</code>
<p>You can also completely remove an existing rule using:</p>
<code>jss.remove('code');</code>
<h2>Here's a live example:</h2>
<code id="jss-output"></code>
<p>Choose your colour:</p>
<div class="radio-option">
<input type="radio" name="colour" id="option-teal" value="teal">
<label for="option-teal">Teal</label>
</div>
<div class="radio-option">
<input type="radio" name="colour" id="option-salmon" value="salmon">
<label for="option-salmon">Salmon</label>
<div>
<p>Choose your font style:</p>
<div class="radio-option">
<input type="radio" name="font-style" id="option-normal" value="normal">
<label for="option-normal">Normal</label>
</div>
<div class="radio-option">
<input type="radio" name="font-style" id="option-italic" value="italic">
<label for="option-italic">Italic</label>
</div>
</body>
</html>