-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathHTMLTemplate.ts
142 lines (120 loc) · 2.93 KB
/
HTMLTemplate.ts
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
import { FieldsObjType } from '../types';
import { fieldsToArray, capitalize } from '../utils';
const template = (
data: FieldsObjType,
fieldNames: string,
formHeading: string
) => {
const fields = fieldsToArray(fieldNames) as Array<keyof FieldsObjType>;
let fieldsString = '';
for (let field of fields) {
fieldsString += `
<div class="fe-item" style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif">
<p class="fe-label" style="font-size: 14px;">
${capitalize(field)}
</p>
<p class="fe-content" style="font-size: 16px">
${data[field]}
</p>
</div>
`;
}
const now = new Date();
const date = now.toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
});
// +
// ' ' +
// now.toLocaleTimeString('en-US');
return `<!DOCTYPE html>
<html>
<head>
<base target="_top">
<style>
.fe-container {
display: flex;
justify-content: center;
margin: auto;
max-width: 500px;
padding: 0 20px;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
}
.fe-heading {
color: #4c4c4c;
font-size: 1.7rem;
}
.fe-item {
margin: 16px auto;
margin-bottom: 20px;
}
.fe-label {
color: #808080;
font-size: 0.8rem;
font-weight: 500;
margin: 0;
margin-bottom: 5px;
}
.fe-content {
margin: 0;
}
.fe-date {
color: #737373;
padding-top: 15px;
}
.fe-bottom {
background-image: linear-gradient(145deg,
#f60000,
#cd00cd,
#ff8c00,
#ffee00,
#4de94c,
#f60000,
#cd00cd,
#ff8c00,
#ffee00,
#4de94c,
#f60000,
#cd00cd);
width: 100%;
padding-top: 4px;
position: relative;
}
.fe-bottom a {
text-decoration: none;
}
.fe-bg {
position: absolute;
width: 100%;
padding-top: 5px;
background-color: white;
}
</style>
</head>
<body>
<div class="fe-container">
<div>
<h1 class="fe-heading" style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin-top:0;">
${formHeading}
</h1>
${fieldsString}
<div class="fe-item" style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif">
<p class="fe-date" style="font-size:14px">
Submitted on: ${date}
</p>
</div>
<div class="fe-bottom">
<div class="fe-bg" style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif">
<p style="margin: 0">
Created using: <a href="https://formify.vercel.app/">Formify</a>
</p>
</div>
</div>
</div>
</div>
</body>
</html>
`;
};
export default template;