This file contains hidden or 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
import Button from "./components/Button" | |
const appElement = document.getElementById('app') | |
const button = new Button('My Button') | |
// click handler assignation : | |
button.onClick = () => { | |
alert('My Button was clicked !') | |
} |
This file contains hidden or 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
$primary: #6699ff | |
button | |
border: none | |
border-radius: 0.33rem | |
padding: 0.5rem 1rem | |
background-color: $primary | |
color: white | |
&:hover | |
background-color: lighten($primary, 10%) |
This file contains hidden or 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
import Button from "./components/Button" | |
const appElement = document.getElementById('app') | |
const button = new Button('My Button') | |
function renderApp() { | |
if (appElement !== null) { | |
appElement.innerHTML = '' | |
button.render(appElement) |
This file contains hidden or 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
export default abstract class Component { | |
abstract element: HTMLElement | |
public render (parent: HTMLElement | Component): void { | |
if (parent instanceof Component) { | |
parent.element.appendChild(this.element) | |
} else { | |
parent.appendChild(this.element) | |
} | |
} |
This file contains hidden or 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
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es2015", | |
"module": "es2015", | |
"lib": [ "dom", "es2019"], | |
"sourceMap": true, | |
"strict": true | |
} | |
} |
This file contains hidden or 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
document.getElementById('app').textContent = 'My Application' |
This file contains hidden or 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
html | |
width: 80% | |
height: 100% | |
margin: 0 auto | |
padding: 0 | |
font-family: sans-serif | |
background-color: #eeeee9 | |
color: #333344 | |
body |