forked from mrhm-dev/full-stack-army
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (27 loc) · 655 Bytes
/
app.js
File metadata and controls
31 lines (27 loc) · 655 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
window.onload = function () {
main();
};
function main() {
const app = Container([
Text('h1', 'Hello World'),
Text('p', 'This is a simple paragraph'),
Container([Text('h3', 'WOW'), Text('h3', 'NICE')], {
display: 'flex',
gap: '2rem',
}),
]);
document.getElementById('root').appendChild(app);
}
function Container(children, style = {}) {
const div = document.createElement('div');
Object.keys(style).map((key) => {
div.style[key] = style[key];
});
children.forEach((child) => div.appendChild(child));
return div;
}
function Text(tag, value) {
const text = document.createElement(tag);
text.innerText = value;
return text;
}