2022-02-18 00:34:11 +00:00
|
|
|
import { ParsedRequest } from './types'
|
2022-09-01 19:55:24 +00:00
|
|
|
import { getTemplateCss } from './template-css'
|
2022-01-07 20:07:38 +00:00
|
|
|
|
|
|
|
export function getHtml(parsedReq: ParsedRequest) {
|
2022-01-10 05:50:31 +00:00
|
|
|
const {
|
|
|
|
theme,
|
|
|
|
fontSize,
|
|
|
|
question,
|
|
|
|
probability,
|
|
|
|
metadata,
|
|
|
|
creatorName,
|
|
|
|
creatorUsername,
|
|
|
|
creatorAvatarUrl,
|
2022-08-05 12:56:10 +00:00
|
|
|
numericValue,
|
2022-09-01 19:55:24 +00:00
|
|
|
resolution,
|
2022-02-18 00:34:11 +00:00
|
|
|
} = parsedReq
|
|
|
|
const hideAvatar = creatorAvatarUrl ? '' : 'hidden'
|
2022-09-01 19:55:24 +00:00
|
|
|
|
|
|
|
let resolutionColor = 'text-primary'
|
2022-09-03 13:29:35 +00:00
|
|
|
let resolutionString = 'YES'
|
2022-09-01 19:55:24 +00:00
|
|
|
switch (resolution) {
|
|
|
|
case 'YES':
|
|
|
|
break
|
|
|
|
case 'NO':
|
|
|
|
resolutionColor = 'text-red-500'
|
2022-09-03 13:29:35 +00:00
|
|
|
resolutionString = 'NO'
|
2022-09-01 19:55:24 +00:00
|
|
|
break
|
|
|
|
case 'CANCEL':
|
|
|
|
resolutionColor = 'text-yellow-500'
|
|
|
|
resolutionString = 'N/A'
|
|
|
|
break
|
|
|
|
case 'MKT':
|
|
|
|
resolutionColor = 'text-blue-500'
|
|
|
|
resolutionString = numericValue ? numericValue : probability
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
const resolutionDiv = `
|
|
|
|
<span class='text-center ${resolutionColor}'>
|
|
|
|
<div class="text-8xl">
|
|
|
|
${resolutionString}
|
|
|
|
</div>
|
|
|
|
<div class="text-4xl">${
|
|
|
|
resolution === 'CANCEL' ? '' : 'resolved'
|
|
|
|
}</div>
|
|
|
|
</span>`
|
|
|
|
|
|
|
|
const probabilityDiv = `
|
|
|
|
<span class='text-primary text-center'>
|
|
|
|
<div class="text-8xl">${probability}</div>
|
|
|
|
<div class="text-4xl">chance</div>
|
|
|
|
</span>`
|
|
|
|
|
|
|
|
const numericValueDiv = `
|
|
|
|
<span class='text-blue-500 text-center'>
|
|
|
|
<div class="text-8xl ">${numericValue}</div>
|
|
|
|
<div class="text-4xl">expected</div>
|
|
|
|
</span>
|
|
|
|
`
|
|
|
|
|
2022-01-07 20:07:38 +00:00
|
|
|
return `<!DOCTYPE html>
|
|
|
|
<html>
|
2022-01-10 05:50:31 +00:00
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>Generated Image</title>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
2022-10-04 15:06:23 +00:00
|
|
|
<script src="https://cdn.tailwindcss.com?plugins=line-clamp"></script>
|
2022-01-10 05:50:31 +00:00
|
|
|
</head>
|
2022-01-07 20:07:38 +00:00
|
|
|
<style>
|
2022-09-01 19:55:24 +00:00
|
|
|
${getTemplateCss(theme, fontSize)}
|
2022-01-07 20:07:38 +00:00
|
|
|
</style>
|
2022-01-10 05:50:31 +00:00
|
|
|
<body>
|
|
|
|
<div class="px-24">
|
|
|
|
<!-- Profile image -->
|
|
|
|
<div class="absolute left-24 top-8">
|
|
|
|
<div class="flex flex-row align-bottom gap-6">
|
|
|
|
<img
|
2022-01-10 07:05:24 +00:00
|
|
|
class="h-24 w-24 rounded-full bg-white flex items-center justify-center ${hideAvatar}"
|
2022-01-10 05:50:31 +00:00
|
|
|
src="${creatorAvatarUrl}"
|
|
|
|
alt=""
|
|
|
|
/>
|
2022-01-10 07:05:24 +00:00
|
|
|
<div class="flex flex-col gap-2">
|
2022-01-10 05:50:31 +00:00
|
|
|
<p class="text-gray-900 text-3xl">${creatorName}</p>
|
|
|
|
<p class="text-gray-500 text-3xl">@${creatorUsername}</p>
|
|
|
|
</div>
|
2022-01-07 20:07:38 +00:00
|
|
|
</div>
|
2022-01-10 05:50:31 +00:00
|
|
|
</div>
|
|
|
|
|
2022-08-04 21:27:02 +00:00
|
|
|
<!-- Manifold logo -->
|
2022-01-10 05:50:31 +00:00
|
|
|
<div class="absolute right-24 top-8">
|
|
|
|
<a class="flex flex-row gap-3" href="/"
|
|
|
|
><img
|
|
|
|
class="sm:h-12 sm:w-12"
|
|
|
|
src="https://manifold.markets/logo.png"
|
|
|
|
width="40"
|
|
|
|
height="40"
|
|
|
|
/>
|
|
|
|
<div
|
|
|
|
class="hidden sm:flex font-major-mono lowercase mt-1 sm:text-3xl md:whitespace-nowrap"
|
|
|
|
>
|
|
|
|
Manifold Markets
|
|
|
|
</div></a
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex flex-row justify-between gap-12 pt-36">
|
2022-10-04 15:06:23 +00:00
|
|
|
<div class="text-indigo-700 text-6xl leading-tight line-clamp-4">
|
|
|
|
${question}
|
2022-01-10 05:50:31 +00:00
|
|
|
</div>
|
2022-09-01 19:55:24 +00:00
|
|
|
<div class="flex flex-col">
|
|
|
|
${
|
|
|
|
resolution
|
|
|
|
? resolutionDiv
|
|
|
|
: numericValue
|
|
|
|
? numericValueDiv
|
2022-09-06 15:36:41 +00:00
|
|
|
: probability
|
|
|
|
? probabilityDiv
|
|
|
|
: ''
|
2022-09-01 19:55:24 +00:00
|
|
|
}
|
2022-01-10 05:50:31 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-01-07 20:07:38 +00:00
|
|
|
|
2022-01-10 05:50:31 +00:00
|
|
|
<!-- Metadata -->
|
|
|
|
<div class="absolute bottom-16">
|
2022-10-04 15:14:27 +00:00
|
|
|
<div class="text-gray-500 text-3xl max-w-[80vw] line-clamp-2">
|
2022-01-10 05:50:31 +00:00
|
|
|
${metadata}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
2022-02-18 00:34:11 +00:00
|
|
|
</html>`
|
2022-01-07 20:07:38 +00:00
|
|
|
}
|