A project created by Hatem Hosny on LiveCodes.
Created
November 1, 2021 23:50
-
-
Save hatemhosny/406b6775436e136cb913ad3376f411b2 to your computer and use it in GitHub Desktop.
TypeScript Demo (for testing import)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<h1>Hello, <span id="title">World</span>!</h1> | |
<img class="logo" src="http://127.0.0.1:8080/livecodes/assets/templates/typescript.svg" /> | |
<p>You clicked <span id="counter">0</span> times.</p> | |
<button id="counter-button">Click me</button> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Counter { | |
private count: number; | |
constructor() { | |
this.count = 0; | |
} | |
increment() { | |
this.count += 1; | |
} | |
getValue() { | |
return this.count; | |
} | |
} | |
const title = document.querySelector("#title"); | |
const count = document.querySelector("#counter"); | |
const button = document.querySelector("#counter-button"); | |
title.textContent = "TypeScript"; | |
const counter = new Counter(); | |
button.addEventListener( | |
"click", | |
() => { | |
counter.increment(); | |
count.textContent = String(counter.getValue()); | |
}, | |
false | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container, | |
.container button { | |
text-align: center; | |
font: 1em sans-serif; | |
} | |
.logo { | |
width: 150px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment