33< head >
44 < meta charset ="UTF-8 ">
55 < title > Scoped CSS Variables and JS</ title >
6+ < link rel ="stylesheet " href ="style.css ">
67</ head >
78< body >
89 < h2 > Update CSS Variables with < span class ='hl '> JS</ span > </ h2 >
@@ -14,68 +15,13 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
1415 < label for ="blur "> Blur:</ label >
1516 < input id ="blur " type ="range " name ="blur " min ="0 " max ="25 " value ="10 " data-sizing ="px ">
1617
17- < label for ="base "> Base Color</ label >
18- < input id ="base " type ="color " name ="base " value ="#ffc600 ">
18+ < label for ="color "> Base Color</ label >
19+ < input id ="color " type ="color " name ="color " value ="#ffc600 ">
1920 </ div >
2021
2122 < img src ="https://source.unsplash.com/7bwQXzbF6KE/800x500 ">
2223
23- < style >
24-
25- /*
26- misc styles, nothing to do with CSS variables
27- */
28-
29- : root {
30- --base : red;
31- --spacing : 10px ;
32- --blur : 0 ;
33- }
34-
35- body {
36- text-align : center;
37- background : # 193549 ;
38- color : white;
39- font-family : 'helvetica neue' , sans-serif;
40- font-weight : 100 ;
41- font-size : 50px ;
42- }
43-
44- .controls {
45- margin-bottom : 50px ;
46- }
47-
48- input {
49- width : 100px ;
50- }
51-
52- img {
53- padding : var (--spacing );
54- background : var (--base );
55- filter : blur (var (--blur ));
56- }
57-
58- .hl {
59- color : var (--base );
60- filter : blur (var (--blur ));
61- }
62-
63- </ style >
64-
65- < script type ="text/javascript ">
66-
67- const inputs = document . querySelectorAll ( 'input' ) ;
68-
69- function handleChange ( ) {
70- const sizing = this . dataset . sizing || '' ;
71- document . documentElement . style . setProperty ( `--${ this . name } ` , this . value + sizing ) ;
72- }
73-
74- inputs . forEach ( input => input . addEventListener ( 'change' , handleChange ) ) ;
75- inputs . forEach ( input => input . addEventListener ( 'mousemove' , handleChange ) ) ;
76-
77-
78- </ script >
24+ < script src ="main.js "> </ script >
7925
8026
8127</ body >
0 commit comments