-
Notifications
You must be signed in to change notification settings - Fork 107
/
my-tag.html
66 lines (58 loc) · 1.23 KB
/
my-tag.html
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
<my-tag>
<h1>Counter</h1>
<p>{ count }</p>
<div class="buttons">
<button onclick="{ increment }">+</button>
<button onclick="{ decrement }">-</button>
</div>
<script>
const { useState } = uhooks
export default withHook((props) => {
const [count, setCount] = useState(Number(props.count))
const increment = () => setCount(count + 1)
const decrement = () => setCount(count - 1)
return {
count,
increment,
decrement
}
})
</script>
<style>
:host {
display: flex;
flex-direction: column;
align-items: center;
background: white;
padding: 2rem;
min-width: 25vw;
border-radius: 1rem;
text-align: center;
box-shadow: 0 0 2rem rgba(0, 0, 0, 0.2);
}
h1 {
margin-bottom: 1rem;
}
p {
font-size: 1.6rem;
margin-top: 0;
}
.buttons {
display: flex;
grid-gap: 0.5rem;
}
button {
cursor: pointer;
color: white;
background: #0f1731;
border: none;
font-size: 1.8rem;
width: 4rem;
height: 4.2rem;
border-radius: 0.4rem;
}
button:hover, button:focus-visible {
background: #1FADC5;
}
</style>
</my-tag>