-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
87 lines (80 loc) · 1.78 KB
/
index.html
File metadata and controls
87 lines (80 loc) · 1.78 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>string-utils-lite Playground</title>
<style>
body {
font-family: Arial, sans-serif;
padding: 20px;
max-width: 600px;
margin: auto;
}
input {
width: 100%;
padding: 10px;
margin-bottom: 20px;
font-size: 16px;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid #ccc;
padding: 8px 10px;
text-align: left;
}
th {
background: #f4f4f4;
}
</style>
</head>
<body>
<h1>string-utils-lite Playground</h1>
<p>Type something below to see transformations:</p>
<input id="textInput" type="text" placeholder="Type here...">
<table>
<thead>
<tr>
<th>Function</th>
<th>Result</th>
</tr>
</thead>
<tbody id="results"></tbody>
</table>
<script type="module">
import {
capitalize,
titleCase,
toKebabCase,
toSnakeCase,
toCamelCase,
toPascalCase
} from "https://esm.sh/string-utils-lite";
const input = document.getElementById("textInput");
const results = document.getElementById("results");
const functions = {
capitalize,
titleCase,
toKebabCase,
toSnakeCase,
toCamelCase,
toPascalCase
};
function updateResults(value) {
results.innerHTML = "";
for (const [name, fn] of Object.entries(functions)) {
const tr = document.createElement("tr");
tr.innerHTML = `<td>${name}</td><td>${fn(value)}</td>`;
results.appendChild(tr);
}
}
input.addEventListener("input", (e) => {
updateResults(e.target.value);
});
// initialize with empty string
updateResults("");
</script>
</body>
</html>