generated from btopro/polaris-chip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
old index.html
119 lines (101 loc) · 4.17 KB
/
old 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<meta name="Description" content="Boilerplate for polaris chip">
<base href="/">
<style>
:root,
html,
body {
margin: 0;
padding: 0;
font-family: sans-serif;
background-color: #ededed;
}
polaris-chip {
margin: 16px;
}
</style>
<title>polaris-chip / my-card</title>
</head>
<body>
<!--
<h1>polaris-chip</h1>
<polaris-chip title="News of Record" link="https://psu.edu/"></polaris-chip>
<polaris-chip title="Faculty and Staff"></polaris-chip>
<polaris-chip title="Sports are cool"></polaris-chip>
<polaris-chip title="Grants and donations"></polaris-chip>
-->
<h2>Controls</h2>
<div class="control-wrapper">
<button id="duplicate">Clone First Card</button>
<button id="change-title">Change Title</button>
<button id="change-image">Change Image</button>
<button id="bg-change">Change background</button>
<button id="delete-card">Delete Card</button>
</div>
<h1>my-card</h1>
<div class="card-wrapper">
<!-- <my-card></my-card>
<my-card fancy card-title="Another card" buttonText="Click Me"
imageLink="https://www.rd.com/wp-content/uploads/2019/09/GettyImages-621924830-scaled.jpg?w=2560"
buttonLink="https://hax.psu.edu/">Some random <strong>paragraph</strong> about info</my-card> -->
<!-- <my-card card-title="Numero Three" cardText="Lets gat that default image and a link to google lol"
buttonText="Click Me" buttonLink="https://google.com/"></my-card>
<my-card card-title="Exists?" cardText="Does google.edu exist? Hit the button" buttonText="To Find Out"
imageLink="https://s3.amazonaws.com/s3.timetoast.com/public/uploads/photos/12786918/edu.jpg"
buttonLink="https://google.edu/"></my-card>
<my-card card-title="Last One" cardText="Five is a lot of cards. This one has the default value for the link"
buttonText="Bring me"
imageLink="https://4.bp.blogspot.com/-XBHVmMlvP4w/VmsqEm1zkeI/AAAAAAABhzE/6vxIKM9hUH4/s1600/funny-animals-190-02.jpg"></my-card> -->
</div>
<counter-app></counter-app>
<counter-app counter="17" min="0" max="25"></counter-app>
<!-- this is what is bringing in the definition for this tag -->
<script type="module" src="./src/polaris-chip.js"></script>
<script type="module" src="./src/my-card.js"></script>
<script type="module" src="./src/counter-app.js"></script>
<script>
// Duplicate first card
document.querySelector("#duplicate").addEventListener("click", function (event) {
const newCard = document.querySelector("my-card").cloneNode(true);
// Ensure that when we ADD cards that we never add more than 10
if (document.querySelectorAll("my-card").length < 10) {
document.querySelector(".card-wrapper").appendChild(newCard);
}
});
// Change title
document.querySelector("#change-title").addEventListener("click", function (e) {
const myCard = document.querySelector("my-card");
myCard.title = "Whats up";
});
// Change card image
document.querySelector("#change-image").addEventListener("click", function (e) {
const myCard = document.querySelector("my-card");
myCard.imageLink = "https://github.com/vr.png";
});
// Change background color
document.querySelector("#bg-change").addEventListener("click", function (e) {
const myCards = document.querySelectorAll('my-card');
myCards.forEach(myCard => {
// Accessing shadow DOM
const shadowRoot = myCard.shadowRoot;
// Selecting all '.card' elements inside shadow DOM
const cards = shadowRoot.querySelectorAll('.card');
cards.forEach(card => {
card.classList.toggle('change-color');
});
});
});
// Delete last card
document.querySelector("#delete-card").addEventListener("click", function (e) {
if (document.querySelectorAll("my-card").length !== 1) {
let lastCardIndex = document.querySelectorAll("my-card").length - 1;
document.querySelectorAll("")[lastCardIndex].remove();
}
});
</script>
</body>
</html>