-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
95 lines (73 loc) · 2.8 KB
/
index.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Web Components</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<style>
body {
padding: 30px;
}
h1 {
color: red;
}
/* app-button::part(custome-btn){
background-color: red;
} */
</style>
</head>
<body>
<button type="button" class="btn btn-danger">Danger</button>
<app-button onclick="add()" >Add</app-button>
<app-button onclick="remove()">Remove</app-button>
<app-button text="move" onclick="move()"></app-button>
<app-card>
<h1 slot="card-header">Header</h1>
<h3 slot="card-header">Sub Header</h3>
<p slot="card-body">This is cart body</p>
<button type="button">action</button>
<button type="button">Another action</button>
</app-card>
<app-card>
<div slot="card-header">
<h1 >Header</h1>
</div>
<button type="button">action</button>
<button type="button">Another action</button>
</app-card>
<!-- <iframe></iframe>
<app-stopwatch></app-stopwatch> -->
<!--
<input type="range" name="" id=""> show user agent shadow dom
<video src=""></video> -->
<script>
const add = () => {
const counter = document.createElement('app-counter');
counter.setAttribute('until', '5');
document.body.append(counter);
}
const remove = () => {
document.querySelector('app-counter').remove();
}
const move = () => {
const iframe = document.querySelector('iframe');
const doc = document.implementation.createHTMLDocument("new document"); // new html doc (structure)
const destinationIframe = iframe.contentDocument;
destinationIframe.replaceChild(doc.documentElement, destinationIframe.documentElement);
const counter = document.querySelector('app-counter');
destinationIframe.body.appendChild(destinationIframe.adoptNode(counter));
}
// one way
// const card = document.querySelector('app-card');
// card.style.display = 'none';
// customElements.whenDefined('app-card').then(() => {
// card.style.display = 'block';
// })
</script>
<script src="./src/button.js" type="module"></script>
<script src="./src/counter.js" type="module"></script>
<script src="./src/stopWatch.js" type="module"></script>
<script src="./src/card.js" type="module"></script>
</body>
</html>