-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
366 lines (315 loc) · 8.21 KB
/
Copy pathindex.html
File metadata and controls
366 lines (315 loc) · 8.21 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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML to Image Playground</title>
<style>
:root {
--bg: #f7f7f5;
--panel: #ffffff;
--border: #d9d9d4;
--text: #1e1e1c;
--muted: #6a6a62;
--accent: #0f766e;
--danger: #b91c1c;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
background: var(--bg);
color: var(--text);
font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
}
main {
width: min(1120px, calc(100vw - 32px));
margin: 24px auto 40px;
display: grid;
gap: 16px;
}
.panel {
background: var(--panel);
border: 1px solid var(--border);
border-radius: 16px;
padding: 16px;
}
.warning-bar {
display: none;
padding: 12px 16px;
background: #b91c1c;
color: #fff;
border-radius: 12px;
font-weight: 700;
}
.warning-bar.is-visible {
display: block;
}
h1,
h2 {
margin: 0;
}
h1 {
font-size: 1.8rem;
}
h2 {
font-size: 1rem;
}
p {
margin: 8px 0 0;
color: var(--muted);
line-height: 1.6;
}
.controls {
display: grid;
gap: 12px;
}
label {
display: grid;
gap: 6px;
color: var(--muted);
font-size: 0.92rem;
}
textarea,
input,
select {
width: 100%;
border: 1px solid var(--border);
border-radius: 12px;
background: #fff;
color: var(--text);
font: inherit;
}
textarea {
min-height: 280px;
padding: 14px;
line-height: 1.6;
resize: vertical;
}
.css-input {
min-height: 96px;
}
input,
select {
padding: 10px 12px;
}
.row {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
}
.actions {
display: flex;
flex-wrap: wrap;
gap: 10px;
align-items: center;
}
button {
appearance: none;
border: 0;
border-radius: 999px;
padding: 10px 16px;
font: inherit;
font-weight: 700;
cursor: pointer;
}
button:disabled {
opacity: 0.45;
cursor: wait;
}
.primary {
background: var(--accent);
color: #fff;
}
.secondary {
background: #ededea;
color: var(--text);
}
.status {
min-height: 1.4em;
color: var(--muted);
font-size: 0.95rem;
}
.status.error {
color: var(--danger);
}
.preview-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 16px;
}
.preview-card {
display: grid;
gap: 10px;
}
.preview-stage {
display: flex;
align-items: flex-start;
border: 1px solid var(--border);
border-radius: 14px;
padding: 12px;
background:
linear-gradient(45deg, rgba(0, 0, 0, 0.03) 25%, transparent 25%),
linear-gradient(-45deg, rgba(0, 0, 0, 0.03) 25%, transparent 25%),
linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.03) 75%),
linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, 0.03) 75%);
background-size: 20px 20px;
background-position: 0 0, 0 10px, 10px -10px, -10px 0;
overflow: auto;
}
.preview-shell {
display: inline-block;
transform-origin: top left;
}
.preview-surface,
.image-output {
display: block;
width: 100%;
max-width: 100%;
background: #fff;
overflow: hidden;
}
.preview-surface {
min-height: 120px;
}
.preview-surface > * {
max-width: 100%;
}
.image-output {
object-fit: contain;
vertical-align: top;
}
.hidden-canvas {
position: absolute;
width: 1px;
height: 1px;
opacity: 0;
pointer-events: none;
}
.measure-root {
position: absolute;
left: -99999px;
top: 0;
visibility: hidden;
pointer-events: none;
}
.measure-surface {
display: block;
overflow: visible;
}
@media (max-width: 900px) {
.row,
.preview-grid {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<main>
<div id="safariWarning" class="warning-bar">
Safari には対応していません。Chrome 系ブラウザで開いてください。
</div>
<section class="panel">
<h1>HTML to Image</h1>
<p>HTML を入力すると、そのままの HTML プレビューと画像化した結果を並べて確認できます。</p>
</section>
<section class="panel controls">
<label for="sampleSelect">
Sample
<select id="sampleSelect">
<option value="simple">Simple</option>
<option value="game_notice_stable">Game Notice / Stable</option>
<option value="game_notice_stress">Game Notice / Stress</option>
<option value="news_article">News Article</option>
</select>
</label>
<label for="htmlInput">
HTML
<textarea id="htmlInput" spellcheck="false"><div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;background:linear-gradient(135deg,#0f766e 0%,#f59e0b 100%);color:white;font-family:'Hiragino Sans','Yu Gothic',sans-serif;">
<div style="padding:36px 44px;border:1px solid rgba(255,255,255,.35);border-radius:28px;background:rgba(255,255,255,.12);box-shadow:0 18px 50px rgba(0,0,0,.18);text-align:center;">
<div style="font-size:14px;letter-spacing:.24em;text-transform:uppercase;opacity:.85;">Client-side only</div>
<h1 style="margin:12px 0 8px;font-size:44px;line-height:1;">HTML → Image</h1>
<p style="margin:0;font-size:18px;opacity:.92;">HTML preview と image preview を並べて確認</p>
</div>
</div></textarea>
</label>
<label for="cssInput">
CSS
<textarea
id="cssInput"
class="css-input"
spellcheck="false"
placeholder=".card { color: red; }"
>.external-card {
padding: 40px;
background: linear-gradient(135deg, #1d4ed8 0%, #0f766e 100%);
color: #ffffff;
font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
}
.external-card__panel {
padding: 28px 32px;
border-radius: 24px;
background: rgba(255, 255, 255, 0.12);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.external-card__eyebrow {
font-size: 14px;
letter-spacing: 0.24em;
text-transform: uppercase;
opacity: 0.8;
}
.external-card__title {
margin: 12px 0 8px;
font-size: 48px;
line-height: 1.05;
}
.external-card__body {
margin: 0;
font-size: 20px;
line-height: 1.6;
}</textarea>
</label>
<div class="row">
<label for="widthInput">
Width
<input id="widthInput" type="number" min="1" value="1200">
</label>
<label for="backgroundInput">
Background
<input id="backgroundInput" type="text" value="#ffffff">
</label>
</div>
<div class="actions">
<button class="primary" id="renderButton">更新する</button>
<button class="secondary" id="sampleButton">サンプルを再読込</button>
<button class="secondary" id="downloadButton" disabled>PNG を保存</button>
</div>
<div id="status" class="status">準備完了</div>
</section>
<section class="panel preview-grid">
<article class="preview-card">
<h2>HTML Preview</h2>
<div class="preview-stage">
<div id="htmlPreviewShell" class="preview-shell">
<div id="htmlPreview" class="preview-surface"></div>
</div>
</div>
</article>
<article class="preview-card">
<h2>Image Preview</h2>
<div class="preview-stage">
<img id="pngOutput" class="image-output" alt="生成されたPNGプレビュー">
</div>
</article>
</section>
</main>
<canvas id="previewCanvas" class="hidden-canvas" width="1200" height="630"></canvas>
<a id="downloadLink" hidden>download</a>
<div class="measure-root" aria-hidden="true">
<div id="measureSurface" class="measure-surface"></div>
</div>
<script src="./script.js"></script>
</body>
</html>