-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
98 lines (88 loc) · 2.98 KB
/
index.html
File metadata and controls
98 lines (88 loc) · 2.98 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>HTML | Elena Web Components</title>
<script src="https://unpkg.com/@elenajs/components@1.0.0/dist/bundle.js" type="module"></script>
<link rel="stylesheet" href="https://unpkg.com/@elenajs/components@1.0.0/dist/bundle.css" />
</head>
<body>
<h1>Elena + HTML</h1>
<p>Demonstrating Elena web components in plain HTML</p>
<section>
<h2>Variants</h2>
<elena-stack direction="row">
<elena-button variant="default">Default</elena-button>
<elena-button variant="primary">Primary</elena-button>
<elena-button variant="danger">Danger</elena-button>
</elena-stack>
</section>
<section>
<h2>Interactive: Counter</h2>
<p>Count: <span id="count">0</span></p>
<elena-stack direction="row">
<elena-button variant="primary" id="increment">Increment</elena-button>
<elena-button variant="danger" id="reset">Reset</elena-button>
</elena-stack>
</section>
<section>
<h2>Dynamic Variant</h2>
<elena-stack direction="column">
<elena-button class="cycle-button">
Click to cycle variant (current: default)
</elena-button>
<elena-button class="cycle-button">default</elena-button>
<p>Current: <span id="current-variant">default</span></p>
</elena-stack>
</section>
<script type="module">
const variants = ["default", "primary", "danger"];
let count = 0;
let variantIndex = 0;
const countEl = document.getElementById("count");
const currentVariantEl = document.getElementById("current-variant");
const cycleButtons = document.querySelectorAll(".cycle-button");
function updateVariant() {
const currentVariant = variants[variantIndex];
cycleButtons.forEach((button, index) => {
button.variant = currentVariant;
if (index === 0) {
button.text = `Click to cycle variant (current: ${currentVariant})`;
} else {
button.text = currentVariant;
}
});
currentVariantEl.textContent = currentVariant;
}
document.getElementById("increment").addEventListener("click", () => {
count++;
countEl.textContent = count;
});
document.getElementById("reset").addEventListener("click", () => {
count = 0;
countEl.textContent = count;
});
cycleButtons.forEach(button => {
button.addEventListener("click", () => {
variantIndex = (variantIndex + 1) % variants.length;
updateVariant();
});
});
</script>
<style>
body {
max-inline-size: 600px;
margin: 0 auto;
padding: 2rem;
font-family: sans-serif;
}
section {
margin-block: 2rem;
}
section h2 {
margin-block-end: 0.5rem;
}
</style>
</body>
</html>