This repository has been archived by the owner on Feb 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
159 lines (132 loc) · 4.4 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BarcelonaJS Banner Generator</title>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&display=swap" rel="stylesheet">
<style>
:root {
--padding: 64px;
--w: 1500px;
--h: 500px;
}
body {
font-family: 'Noto Sans JP', sans-serif;
color: white;
}
.Canvas {
border-radius: 2px;
margin: auto;
transition: all .3s;
background-color: #000000;
width: calc(var(--w) - var(--padding) * 2);
height: calc(var(--h));
position: relative;
padding: var(--padding)
}
.Motto {
font-size: 130px;
letter-spacing: 1px;
font-weight: 700;
margin: 0;
}
.Date {
font-size: 36px;
margin: 0 0 0 9px;
}
.Logo {
position: absolute;
bottom: var(--padding);
right: var(--padding);
}
.Info {
position: absolute;
bottom: var(--padding);
}
.Info h3 {
font-size: 42px;
}
.Info h4 {
font-size: 36px;
}
.Info h3,
.Info h4 {
margin: 0;
}
/* UI */
main {
display: block;
margin: auto;
}
header {
transition: all .3s;
margin: auto;
max-width: var(--w);
display: flex;
justify-content: space-between;
align-items: center;
padding: 24px 0;
}
</style>
</head>
<body>
<header>
<nav>
<button id="btn-twitter">Twitter Banner</button>
<button id="btn-meetup">Meetup Banner</button>
</nav>
<form>
<input placeholder="Company" id="company" name="company" type="text">
<input placeholder="Date" id="date" name="date" type="datetime-local">
<button>Generate</button>
</form>
<button id="btn-download"> Download</button>
</header>
<main>
<div class="Canvas">
<h1 class="Motto">BarcelonaJS</h1>
<h2 class="Date"></h2>
<div class="Info">
<h3> Offered by:</h3>
<h4 class="Company"></h4>
</div>
<img class="Logo" src="./logo.png" />
</div>
</main>
</body>
<script>
const params = new URLSearchParams(window.location.search);
const company = params.get('company') || '@company';
const date = params.get('date') ? new Date(params.get('date')) : new Date();
const dtf = new Intl.DateTimeFormat('en', { dateStyle: 'long', timeStyle: 'medium' })
document.querySelector('#company').value = company;
document.querySelector('#date').value = date.toISOString().slice(0, 16);
document.querySelector('.Date').innerText = dtf.format(date);
document.querySelector('.Company').innerText = company;
function handleTwitterClick() {
document.documentElement.style.setProperty('--w', 1500 + "px");
document.documentElement.style.setProperty('--h', 500 + "px");
}
function handleMeetupClick() {
document.documentElement.style.setProperty('--w', 1500 + "px");
document.documentElement.style.setProperty('--h', 720 + "px");
}
function handleDownloadClick() {
const canvas = document.querySelector('.Canvas');
html2canvas(canvas).then(function (canvas) {
const link = document.createElement('a');
link.download = 'logo.png';
link.href = canvas.toDataURL();
link.click();
});
}
document.querySelector('#btn-twitter').addEventListener('click', handleTwitterClick);
document.querySelector('#btn-meetup').addEventListener('click', handleMeetupClick);
document.querySelector('#btn-download').addEventListener('click', handleDownloadClick);
</script>
</html>