File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,27 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
48
48
</ style >
49
49
50
50
< script >
51
+ const target = document . querySelector ( 'img' ) ;
52
+ const ctrl_bdr = document . getElementById ( 'spacing' ) ;
53
+ const ctrl_blur = document . getElementById ( 'blur' ) ;
54
+ const ctrl_bdrc = document . getElementById ( 'base' ) ;
55
+
56
+ function updateStyle ( formctrl , attr ) {
57
+ let unit = formctrl . hasAttribute ( 'data-sizing' ) ? formctrl . getAttribute ( 'data-sizing' ) : '' ;
58
+ target . style [ attr ] = attr === 'filter' ? `blur(${ formctrl . value + unit } )` : `${ formctrl . value + unit } ` ;
59
+ }
60
+
61
+ window . onload = function ( ) {
62
+ target . style . borderStyle = 'solid' ;
63
+ ( ( changes ) => {
64
+ for ( let ctrlAttr in changes ) {
65
+ updateStyle ( changes [ ctrlAttr ] , ctrlAttr ) ;
66
+ ( ( attr ) => changes [ attr ] . addEventListener ( 'change' , function ( ) {
67
+ updateStyle ( this , attr )
68
+ } ) ) ( ctrlAttr )
69
+ }
70
+ } ) ( { 'borderWidth' : ctrl_bdr , 'filter' : ctrl_blur , 'borderColor' : ctrl_bdrc } )
71
+ }
51
72
</ script >
52
73
53
74
</ body >
Original file line number Diff line number Diff line change 5
5
> Folked repo for practice and fun!
6
6
7
7
1 . [x] ~~ JavaScript Drum Kit~~
8
- 2 . [x] ~~ JS + CSS Clock ~~
9
- 3 . [ ] CSS Variables
10
- 4 . [ ] Array Cardio, Day 1
8
+ 2 . [x] ~~ JS + CSS Clock~~
9
+ 3 . [x] ~~ CSS Variables~~
10
+ 4 . [ ] Array Cardio, Day 1
11
11
5 . [ ] Flex Panel Gallery
12
12
6 . [ ] Type Ahead
13
13
7 . [ ] Array Cardio, Day 2
You can’t perform that action at this time.
0 commit comments