-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
136 lines (121 loc) · 2.79 KB
/
index.html
File metadata and controls
136 lines (121 loc) · 2.79 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
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
<!DOCTYPE html>
<html>
<head>
<title>Card Sheet Renderer</title>
<script src="cards.js"></script>
<script>
if (typeof(cards) === "undefined") {
cards = [
{ name: "Example",
icon: "Wand.png",
steps: [
"+1 Magic Token.",
"Test Text."
],
rarity: 'C',
}
];
}
</script>
<script src="https://unpkg.com/vue"></script>
<style>
#app{
position: relative;
}
@page {
/* this affects the margin in the printer settings */
margin: 2mm 2mm;
}
body {
background: #FFF;
}
.card-grid{
display: grid;
page-break-before: always;
grid-template-columns: repeat(5, 63mm);
grid-template-rows: repeat(2, 88mm);
grid-auto-flow: row;
}
.card {
border: 1mm solid black;
border-radius: 2mm;
height: 88mm;
position: relative;
font-family: sans-serif;
}
.card p{
margin: 2mm;
font-size: 0.8em;
}
.icon {
position: absolute; top: 2mm; right: 2mm; width: 10mm;
}
.card .name {
background-color: #EEE;
font-size: 1.5em;
padding-top: 5mm;
height: 15mm;
padding-left: 2mm;
}
.stat{
text-align: right;
}
.stat-name{
position: relative;
}
.stat-name .right{
position: absolute;
right: 0;
}
</style>
</head>
<body>
<div id="app">
<div class="card-grid" v-for="i in getPageCount()">
<div class="card" v-for="card in getCardsOnPage(i)":key="card.name">
<div class="name">{{ card.name }} </div>
<p v-for = "step in card.steps">{{step}}</p>
<img :src = "'icons/' + card.icon" class="icon"/>
</div>
</div>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
cards: cards,
pages: [],
},
methods: {
updatePagedCards: function() {
var pages = this.pages;
for (var i = 0; i < this.cards.length; i++){
var card = this.cards[i];
var pageIndex = Math.floor(i / 10);
if(pages.length <= pageIndex){
pages.push([]);
}
var currentPage = pages[pageIndex];
currentPage.push(card);
}
this.pages = pages;
},
getPageCount: function() {
return Math.ceil(this.cards.length / 10);
},
getCardsOnPage: function(page) {
var out = [];
for (var i = (page - 1) * 10; i < (page) * 10; i++){
if(typeof this.cards[i] !== 'undefined'){
out.push(this.cards[i]);
}
}
console.log(out);
return out;
}
}
})
app.updatePagedCards();
</script>
</body>
</html>