Skip to content

Commit 904fb85

Browse files
committed
Add web component example.
1 parent a78d560 commit 904fb85

File tree

5 files changed

+43
-2
lines changed

5 files changed

+43
-2
lines changed

ui/index.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:root {
2+
--highlight-color: #dd0099;
3+
}

ui/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
<head>
44
<title>tech:lounge Todo App</title>
55

6+
<link type="text/css" rel="stylesheet" href="index.css">
67
<script src="dist/index.js" type="module"></script>
78
</head>
89

910
<body>
10-
<h1>Hallo Welt!</h1>
11+
<tl-header year="2026"></tl-header>
1112
</body>
1213
</html>

ui/src/components/Header.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { css, html, LitElement } from 'lit';
2+
import { customElement, property } from 'lit/decorators.js';
3+
4+
@customElement('tl-header')
5+
class Header extends LitElement {
6+
static styles = css`
7+
header {
8+
padding: 16px;
9+
text-align: center;
10+
}
11+
12+
h1 {
13+
font-family: sans-serif;
14+
font-size: 36px;
15+
font-weight: 400;
16+
color: var(--highlight-color);
17+
}
18+
19+
@media (max-width: 600px) {
20+
h1 {
21+
font-size: 24px;
22+
}
23+
}
24+
`;
25+
26+
@property({ type: String })
27+
year = '';
28+
29+
render() {
30+
return html`
31+
<header>
32+
<h1>tech:lounge Masterclass ${this.year}</h1>
33+
</header>
34+
`;
35+
}
36+
}

ui/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
console.log('Hallo aus JavaScript!');
1+
import './components/Header.ts';

ui/ui.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ import "embed"
44

55
//go:embed dist/*
66
//go:embed index.html
7+
//go:embed index.css
78
var Content embed.FS

0 commit comments

Comments
 (0)