File tree Expand file tree Collapse file tree 5 files changed +78
-39
lines changed
Expand file tree Collapse file tree 5 files changed +78
-39
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ hljs.registerLanguage('javascript', javascript);
55
66const codeInput = document . querySelector ( '#code-input' ) ;
77const codeOutput = document . querySelector ( '#code-output' ) ;
8+ const runButton = document . querySelector ( '.run-button' ) ;
9+ const resultBlock = document . querySelector ( '.result' ) ;
810
911codeOutput . textContent = codeInput . value ;
1012hljs . highlightElement ( codeOutput ) ;
@@ -32,4 +34,20 @@ const resizeObserver = new ResizeObserver((entries) => {
3234 }
3335} ) ;
3436
37+ // const originalConsoleLog = console.log;
38+ console . log = function ( ...args ) {
39+ args . forEach ( function ( arg ) {
40+ resultBlock . innerHTML += `<div class="console-log">${ arg } </div>` ;
41+ } ) ;
42+ }
43+ runButton . addEventListener ( 'click' , ( event ) => {
44+ resultBlock . innerHTML = '' ;
45+ const code = codeInput . value ;
46+ try {
47+ Function ( code ) ( ) ;
48+ } catch ( e ) {
49+ console . log ( e ) ;
50+ }
51+ } )
52+
3553resizeObserver . observe ( codeInput ) ;
Original file line number Diff line number Diff line change 5151< main >
5252 < div class ="main box ">
5353 < h1 > Sandbox</ h1 >
54- < div class ="editor ">
55- < textarea id ="code-input " class ="input " spellcheck ="false "> </ textarea >
56- < div id ="code-output " class ="output language-javascript "> </ div >
54+ < div class ="sandbox-wrapper ">
55+ < div class ="editor ">
56+ < textarea id ="code-input " class ="input " spellcheck ="false "> </ textarea >
57+ < div id ="code-output " class ="output language-javascript "> </ div >
58+ </ div >
59+ < div class ="result "> </ div >
60+ </ div >
61+ < div >
62+ < button class ="run-button "> Run</ button >
5763 </ div >
5864 </ div >
5965</ main >
Original file line number Diff line number Diff line change 22
33button {
44 background-color : $button-color ;
5- border : none ;
6- border-radius : 1 rem ;
5+ border : 1 px solid $button-color ;
6+ border-radius : 0.5 rem ;
77 cursor : pointer ;
88 padding : 1rem ;
99
1010 font-weight : 600 ;
11- color : $font-color ;
11+ color : $font-color-dark ;
1212
1313 & :hover {
1414 background-color : $button-color-hover ;
15+ border-color : $font-color ;
16+ color : $font-color ;
1517 }
1618
1719 & .big {
Original file line number Diff line number Diff line change 33
44$font-color : $foreground ;
55$font-color-light : $white ;
6+ $font-color-dark : $dark ;
67
7- $button-color : $green ;
8- $button-color-hover : $green ;
8+ $button-color : $foreground ;
9+ $button-color-hover : $selection ;
910
1011$box-color : $bg ;
1112$box-light : $selection ;
Original file line number Diff line number Diff line change 11@use " ../includes/variables" as * ;
22@use " ../includes/mixins" as * ;
33
4- .editor {
5- position : relative ;
6- height : 30rem ;
7- padding : 0 ;
8- border : none ;
4+ .sandbox-wrapper {
5+ display : flex ;
6+ gap : 1rem ;
97 margin : 2rem 0 ;
108
11- .input , .output {
12- box-sizing : border-box ;
13- position : absolute ;
14- height : 100% ;
15- width : 90% ;
9+ .editor {
10+ position : relative ;
11+ flex-basis : 800px ;
12+ flex-grow : 1 ;
1613
17- font-family : monospace ;
18- padding : 0.5 em ;
14+ height : 30 rem ;
15+ padding : 0 ;
1916 border : none ;
20- font-size : 0.85rem ;
21- line-height : 1.375rem ;
22- white-space : pre ;
23- word-wrap : break-word ;
24- overflow : auto ;
25-
26- scrollbar-color : $secondary $highlight ;
27- scrollbar-width : thin ;
28- }
2917
30- .input {
31- z-index : 1 ;
32- color : transparent ;
33- caret-color : $foreground ;
34- background-color : transparent ;
35- }
18+ .input , .output {
19+ box-sizing : border-box ;
20+ position : absolute ;
21+ height : 100% ;
22+ width : 100% ;
23+
24+ font-family : monospace ;
25+ padding : 0.5em ;
26+ border : none ;
27+ font-size : 0.85rem ;
28+ line-height : 1.375rem ;
29+ white-space : pre ;
30+ word-wrap : break-word ;
31+ overflow : auto ;
3632
37- .output {
38- z-index : 0 ;
39- background-color : $bg ;
40- padding-bottom : 7px ;
33+ scrollbar-color : $secondary $highlight ;
34+ scrollbar-width : thin ;
35+ }
36+
37+ .input {
38+ z-index : 1 ;
39+ color : transparent ;
40+ caret-color : $foreground ;
41+ background-color : transparent ;
42+ }
43+
44+ .output {
45+ z-index : 0 ;
46+ background-color : $bg ;
47+ padding-bottom : 7px ;
48+ }
49+ }
50+ .result {
51+ flex-basis : 400px ;
52+ flex-shrink : 0 ;
4153 }
4254}
You can’t perform that action at this time.
0 commit comments