-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11-html-template-css.htm
180 lines (133 loc) · 5.01 KB
/
11-html-template-css.htm
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<!DOCTYPE html>
<html>
<head>
<title>Alternative usage with HTML template and CSS</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<!-- LIBRARY FILES -->
<link rel="stylesheet" type="text/css" href="basic/basic.min.css">
<script src="basic/basic.min.js" type="text/javascript" charset="utf-8"></script>
<style>
.item-model {
position: relative;
display: block;
width: 100%;
height: 100%;
background-color: transparent;
border: 0px solid white;
}
.item-model.background {
position:absolute;
top: 2px;
left: 4px;
width: calc(100% - 8px);
height: calc(100% - 4px);
background-color: rgba(0, 0, 0, 0.01);
border-radius: 13px;
border: 1px solid rgba(0, 0, 0, 0.04);
box-sizing: border-box;
transition: background-color 0.3s ease 0s;
}
.item-model.icon {
position:absolute;
left: 30px;
top: 12px;
width: 70px;
height: 70px;
border-radius: 4px;
background-color: transparent;
border-width: 0px;
}
.item-model.title {
position:absolute;
left: 120px;
top: 25px;
width: 280px;
height: auto;
font-family: opensans;
font-size: 20px;
text-align: left;
color: #4A4A4A;
}
.item-model.description {
position:absolute;
left: 120px;
top: 49px;
width: 280px;
height: auto;
color: gray;
font-family: opensans;
font-size: 14px;
text-align: left;
}
</style>
<script>
let plantItemDataList = [
{ id: "1", name: "Broccoli", description: "Vegetable", iconPath: "assets/broccoli.png" },
{ id: "2", name: "Strawberry", description: "Fruit", iconPath: "assets/strawberry.png" },
{ id: "3", name: "Carrot", description: "Vegetable", iconPath: "assets/carrot.png" },
{ id: "4", name: "Blueberries", description: "Fruit", iconPath: "assets/blueberries.png" },
];
let plantItemList = [];
window.onload = function() {
page.color = "whitesmoke";
// BOX: Plant items container box. Parameters: left, top, width, height
page.boxItems = createBox(0, 0, 300, "100%");
that.color = "transparent";
that.scrollY = 1;
that.right = 0;
createPlantItems();
};
const createPlantItems = function() {
// Clear all items.
plantItemList = [];
page.boxItems.html = "";
// Add items from plantItemDataList.
for(index in plantItemDataList) {
// PLANT ITEM: Create a plant item object.
const item = createPlantItem(plantItemDataList[index], index);
// Move the created item into the container box.
page.boxItems.add(item);
// Give position after moving into the box to show the object.
item.position = "relative";
// On item clicked.
item.onClick(function(clickedItem) {
println("Clicked item index: " + clickedItem.index);
});
// Keep the object for later use.
plantItemList.push(item);
}
// NOTE: You can make any change on plantItemDataList and
// call createPlantItems again to refresh all.
// or you can directly change any properties
// of the created objects by using the plantItemList.
};
const createPlantItem = function(data, index) {
// BOX: Object container box
const box = createBox();
box.width = "100%";
box.height = 94;
box.color = "transparent";
// Keep item data:
box.data = data;
box.index = index;
// TEMPLATE:
box.html = `
<div class="item-model">
<div class="item-model background"></div>
<img class="item-model icon" src="${data.iconPath}">
<div class="item-model title">${data.name}</div>
<div class="item-model description">${data.description}</div>
</div>
`;
// NOTE: This technique may be more efficient
// if you are going to display text-heavy content.
makeBasicObject(box);
return box;
};
</script>
</head>
<body>
<!-- HTML content -->
</body>
</html>