Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 77be2ff

Browse files
Add playground demo
1 parent eb327f1 commit 77be2ff

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

‎playground.html‎

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>string-utils-lite Playground</title>
6+
<style>
7+
body {
8+
font-family: Arial, sans-serif;
9+
padding: 20px;
10+
max-width: 600px;
11+
margin: auto;
12+
}
13+
input {
14+
width: 100%;
15+
padding: 10px;
16+
margin-bottom: 20px;
17+
font-size: 16px;
18+
}
19+
table {
20+
width: 100%;
21+
border-collapse: collapse;
22+
}
23+
th, td {
24+
border: 1px solid #ccc;
25+
padding: 8px 10px;
26+
text-align: left;
27+
}
28+
th {
29+
background: #f4f4f4;
30+
}
31+
</style>
32+
</head>
33+
<body>
34+
<h1>string-utils-lite Playground</h1>
35+
<p>Type something below to see transformations:</p>
36+
<input id="textInput" type="text" placeholder="Type here...">
37+
38+
<table>
39+
<thead>
40+
<tr>
41+
<th>Function</th>
42+
<th>Result</th>
43+
</tr>
44+
</thead>
45+
<tbody id="results"></tbody>
46+
</table>
47+
48+
<script type="module">
49+
import {
50+
capitalize,
51+
titleCase,
52+
toKebabCase,
53+
toSnakeCase,
54+
toCamelCase,
55+
toPascalCase
56+
} from "https://esm.sh/string-utils-lite";
57+
58+
const input = document.getElementById("textInput");
59+
const results = document.getElementById("results");
60+
61+
const functions = {
62+
capitalize,
63+
titleCase,
64+
toKebabCase,
65+
toSnakeCase,
66+
toCamelCase,
67+
toPascalCase
68+
};
69+
70+
function updateResults(value) {
71+
results.innerHTML = "";
72+
for (const [name, fn] of Object.entries(functions)) {
73+
const tr = document.createElement("tr");
74+
tr.innerHTML = `<td>${name}</td><td>${fn(value)}</td>`;
75+
results.appendChild(tr);
76+
}
77+
}
78+
79+
input.addEventListener("input", (e) => {
80+
updateResults(e.target.value);
81+
});
82+
83+
// initialize with empty string
84+
updateResults("");
85+
</script>
86+
</body>
87+
</html>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /