|
3 | 3 | <head>
|
4 | 4 | <meta charset="utf-8" />
|
5 | 5 | <meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
6 |
| - <title>kasper-js</title> |
| 6 | + <title>Kasper.js</title> |
| 7 | + <meta |
| 8 | + name="description" |
| 9 | + content="Kasper-JS is a work-in-progress of a JavaScript HTML template parser and renderer designed to help create and learn core mechanics of modern JavaScript frameworks." |
| 10 | + /> |
7 | 11 | <meta name="viewport" content="width=device-width, initial-scale=1" />
|
8 | 12 | <link
|
9 | 13 | href="https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap"
|
10 | 14 | rel="stylesheet"
|
11 | 15 | />
|
12 | 16 | <script src="../dist/kasper.min.js"></script>
|
13 | 17 | <script src="./js/demo.js"></script>
|
14 |
| - |
15 | 18 | <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.9/ace.js"></script>
|
16 | 19 | <script src="https://cdn.tailwindcss.com"></script>
|
17 | 20 | <script>
|
|
28 | 31 | },
|
29 | 32 | };
|
30 | 33 | </script>
|
31 |
| - <script></script> |
32 | 34 | <style>
|
33 |
| - kasper { |
34 |
| - color: #374151; |
35 |
| - } |
36 |
| - kasper h3 { |
37 |
| - font-size: 28px; |
38 |
| - margin-bottom: 8px; |
39 |
| - } |
40 |
| - kasper h4 { |
41 |
| - font-size: 21px; |
42 |
| - margin-bottom: 8px; |
43 |
| - margin-top: 8px; |
44 |
| - } |
45 |
| - |
46 | 35 | .app {
|
47 | 36 | width: 100dvw;
|
48 | 37 | height: 100dvh;
|
49 | 38 | display: grid;
|
50 | 39 | grid-template-rows: 1fr;
|
51 |
| - grid-template-columns: minmax(724px, 1024px) minmax(120px, 1fr); |
| 40 | + grid-template-columns: minmax(724px, 804px) minmax(120px, 1fr); |
52 | 41 | }
|
53 | 42 |
|
54 | 43 | ::-webkit-scrollbar {
|
|
67 | 56 | ::-webkit-scrollbar-thumb:window-inactive {
|
68 | 57 | background: rgba(255, 255, 255, 0.4);
|
69 | 58 | }
|
| 59 | + |
| 60 | + button[role="tab"] { |
| 61 | + background-color: #191a1d; |
| 62 | + color: #bbbbbb; |
| 63 | + } |
| 64 | + |
| 65 | + button[aria-selected="true"] { |
| 66 | + background-color: #26282c; |
| 67 | + color: #ffffff; |
| 68 | + border-color: #aaaaaa; |
| 69 | + } |
70 | 70 | </style>
|
71 | 71 | </head>
|
72 | 72 | <body>
|
73 | 73 | <div class="app w-dvw h-dvh">
|
74 | 74 | <div class="flex flex-col bg-[#1d1f21]">
|
75 |
| - <div class="border-b border-gray-500 px-4 pt-4 flex justify-between"> |
76 |
| - <div |
77 |
| - class="text-white px-2 py-1 rounded-t-lg border-l border-r border-t border-gray-500 w-32 text-center" |
78 |
| - > |
79 |
| - App.kasper |
| 75 | + <div class="border-b border-gray-500 px-4 pt-4 flex"> |
| 76 | + <div class="flex-grow flex gap-2"> |
| 77 | + <button |
| 78 | + role="tab" |
| 79 | + aria-selected="true" |
| 80 | + aria-controls="htmlSource" |
| 81 | + class="text-white px-2 py-1 rounded-t-lg border-l border-r border-t border-gray-500 w-28 text-center" |
| 82 | + > |
| 83 | + App.html |
| 84 | + </button> |
| 85 | + <button |
| 86 | + role="tab" |
| 87 | + aria-selected="false" |
| 88 | + aria-controls="scriptSource" |
| 89 | + class="text-white px-2 py-1 rounded-t-lg border-l border-r border-t border-gray-500 w-28 text-center" |
| 90 | + > |
| 91 | + App.js |
| 92 | + </button> |
| 93 | + <button |
| 94 | + role="tab" |
| 95 | + aria-selected="false" |
| 96 | + aria-controls="stylesSource" |
| 97 | + class="text-white px-2 py-1 rounded-t-lg border-l border-r border-t border-gray-500 w-28 text-center" |
| 98 | + > |
| 99 | + App.css |
| 100 | + </button> |
80 | 101 | </div>
|
81 | 102 | <button
|
82 | 103 | class="px-8 py-1 bg-green-600 rounded text-white font-mono hover:bg-green-500 relative -top-2"
|
|
86 | 107 | </button>
|
87 | 108 | </div>
|
88 | 109 | <div id="editor" class="flex-grow w-full"></div>
|
89 |
| - <div class="border-b border-gray-500 pt-6 pl-2"> |
90 |
| - <div |
91 |
| - class="text-white px-2 py-1 rounded-t-lg border-l border-r border-t border-gray-500 w-32 text-center" |
92 |
| - > |
93 |
| - Data.kasper |
94 |
| - </div> |
95 |
| - </div> |
96 |
| - <div id="json" class="w-full h-64"></div> |
97 | 110 | </div>
|
98 |
| - <div class="bg-gray-100"> |
99 |
| - <div id="render" class="w-full h-full p-6"> |
| 111 | + <div class="text-white bg-gray-700 flex flex-col"> |
| 112 | + <div id="script" class="hidden"></div> |
| 113 | + <div id="render" class="flex-grow p-6"> |
100 | 114 | <div
|
101 |
| - class="w-full h-full flex items-center justify-center p-4 text-gray-500 text-center text-xl" |
| 115 | + class="w-full h-full flex items-center justify-center p-4 text-gray-300 text-center text-xl" |
102 | 116 | >
|
103 |
| - Hit RENDER to view template output |
| 117 | + Press RENDER to render! |
104 | 118 | </div>
|
105 | 119 | </div>
|
| 120 | + <div |
| 121 | + class="text-sm px-4 py-2 border-t border-gray-500" |
| 122 | + id="status" |
| 123 | + ></div> |
106 | 124 | </div>
|
107 | 125 | </div>
|
| 126 | + <script src="./js/playground.js"></script> |
108 | 127 | <a
|
109 | 128 | href="https://github.com/eugenioenko/kasper-js"
|
110 | 129 | title="View source on GitHub"
|
|
135 | 154 | ></path>
|
136 | 155 | </svg>
|
137 | 156 | </a>
|
138 |
| - <script> |
139 |
| - function createEditor(id, source, mode) { |
140 |
| - let editor = ace.edit(id); |
141 |
| - editor.session.setMode(`ace/mode/${mode || "javascript"}`); |
142 |
| - editor.getSession().setUseWorker(false); |
143 |
| - editor.setTheme("ace/theme/tomorrow_night"); |
144 |
| - editor.setFontSize(15); |
145 |
| - editor.setValue(source); |
146 |
| - editor.selection.moveCursorToPosition({ row: 1, column: 0 }); |
147 |
| - editor.selection.selectLine(); |
148 |
| - return editor; |
149 |
| - } |
150 |
| - |
151 |
| - const ejson = createEditor("json", DemoJson, "json"); |
152 |
| - const editor = createEditor("editor", DemoSourceCode, "html"); |
153 |
| - |
154 |
| - document.getElementById("execute").addEventListener("click", () => { |
155 |
| - const source = editor.getValue(); |
156 |
| - const result = kasper.execute(source); |
157 |
| - const entries = JSON.parse(ejson.getValue()); |
158 |
| - entries.alert = function (value) { |
159 |
| - alert(value); |
160 |
| - }; |
161 |
| - const node = kasper.transpile( |
162 |
| - source, |
163 |
| - entries, |
164 |
| - document.getElementById("render") |
165 |
| - ); |
166 |
| - }); |
167 |
| - </script> |
168 | 157 | </body>
|
169 | 158 | </html>
|
0 commit comments