-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshirt_template.erb
158 lines (140 loc) · 3.85 KB
/
shirt_template.erb
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
<!DOCTYPE html>
<html>
<head>
<style>
@font-face {
font-family: 'Bank Printer';
src: url('fonts/F25_Bank_Printer.ttf') format('truetype');
}
body {
/*background-color: #D2E6FF;*/
font-family: 'Bank Printer', monospace;
margin: 0;
padding: 20px;
}
.container {
width: 800px;
height: 820px;
}
.header {
margin: 40px 30px;
}
.qr-card {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
width: 170px;
}
.qr-code {
width: 180px
}
.doubloon-icon {
height: 17px;
display: inline-block;
vertical-align: middle;
margin-top: -3px;
}
.container {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
grid-template-rows: 0.3fr repeat(auto-fit, 1fr);
align-items: center;
gap: 8px 8px;
grid-template-areas:
"title title title art1 art1 "
". . . art1 art1"
"art2 art2 . . ."
"art2 art2 . . ."
". . . art3 art3"
". . . art3 art3";
}
.shrink-to-fit {
white-space: nowrap;
transform: scale(1);
transform-origin: left;
}
.title {
grid-area: title;
font-size: 40px;
justify-self: center;
}
.ship-title {
width: 150px;
}
.art1 {
grid-area: art1;
align-self: end;
<%= v1_rotaté %>
}
.art2 {
grid-area: art2;
<%= v1_rotaté %>
}
.art3 {
grid-area: art3;
<%= v1_rotaté %>
}
.art {
vertical-align: middle;
}
.in-ysws {
border: 1.5px solid gold;
background: #FFFCEB;
border-radius: 14px;
}
</style>
</head>
<body style="zoom: 300%">
<div class="container">
<div class="title" data-width="1400">
<span class="shrink-to-fit"><%= shirt.handle %> – <%= 'project'.pluralize(ships.length) %></span>
</div>
<div class="art art1"><img src="images/art_2.png" width="300px"></div>
<% if shirt.ships.length > 3 %>
<div class="art art2"><img src="images/art_3.png" width="300px"></div>
<% end %>
<% if shirt.ships.length > 9 %>
<div class="art art3"><img src="images/art_1.png" width="320px"></div>
<% end %>
<% case shirt.ships.length
when 1 %>
<div style="grid-area: 2 / 1 / 3 / 4; align-self: center; justify-self: center;">
<%= erb '_ship.erb', locals: { ship: shirt.ships.first } %>
</div>
<% when 2 %>
<div style="grid-area: 1 / 1 / 5 / 1; align-self: center; justify-self: center;">
<%= erb '_ship.erb', locals: { ship: shirt.ships.first } %>
</div>
<div style="grid-area: 1 / 3 / 5 / 3; align-self: center; justify-self: center;">
<%= erb '_ship.erb', locals: { ship: shirt.ships.last } %>
</div>
<% else %>
<% shirt.ships.each do |ship| %>
<%= erb '_ship.erb', locals: { ship: } %>
<% end %>
<% end %>
</div>
<script>
// The poor man's jQuery
window.$ = (query, el = document) => {
return el.querySelector(query);
};
window.$all = (query, el = document) => {
return [...el.querySelectorAll(query)];
};
</script>
<script>
for (const element of $all('.shrink-to-fit')) {
console.log('awa')
var size = parseInt(getComputedStyle(element).getPropertyValue('font-size'));
const parent_width = element.parentElement.dataset.width
// if you ask me why it's 14.15 i'm legally allowed to come to your house and cry at you
while (element.getBoundingClientRect().width > parent_width - 14.15) {
element.style.fontSize = size + "px"
size -= 0.5
}
}
</script>
</body>
</html>