Spaces:
Running
Running
Now add a modern look to the form and make it responsive
Browse files- index.html +41 -41
- script.js +18 -13
- style.css +98 -20
index.html
CHANGED
|
@@ -4,11 +4,14 @@
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>FormCraft Pro - JSON Data Wizard</title>
|
|
|
|
|
|
|
| 7 |
<link rel="stylesheet" href="style.css">
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
|
|
|
| 9 |
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
-
|
| 12 |
tailwind.config = {
|
| 13 |
theme: {
|
| 14 |
extend: {
|
|
@@ -25,71 +28,68 @@
|
|
| 25 |
}
|
| 26 |
</script>
|
| 27 |
</head>
|
| 28 |
-
<body class="bg-gray-50 min-h-screen">
|
| 29 |
-
<div class="container mx-auto px-4 py-12">
|
| 30 |
-
<div class="max-w-2xl mx-auto bg-white rounded-xl shadow-
|
| 31 |
-
<div class="bg-primary-500 p-6">
|
| 32 |
<div class="flex items-center">
|
| 33 |
-
<i data-feather="edit-3" class="text-white mr-3"></i>
|
| 34 |
-
<h1 class="text-2xl font-bold text-white">FormCraft Pro</h1>
|
| 35 |
</div>
|
| 36 |
-
<p class="text-primary-100 mt-
|
| 37 |
</div>
|
| 38 |
-
|
| 39 |
-
<form id="dataForm" class="p-6 space-y-6">
|
| 40 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 41 |
-
<div>
|
| 42 |
-
<label for="name" class="block text-sm font-medium text-gray-700 mb-1">Name
|
| 43 |
-
<input type="text" id="name" name="name"
|
| 44 |
-
class="w-full px-4 py-
|
| 45 |
</div>
|
| 46 |
-
|
| 47 |
-
<div class="md:col-span-2">
|
| 48 |
<label for="address" class="block text-sm font-medium text-gray-700 mb-1">Address</label>
|
| 49 |
<textarea id="address" name="address" rows="3"
|
| 50 |
-
class="w-full px-4 py-
|
| 51 |
</div>
|
| 52 |
-
|
| 53 |
-
<div>
|
| 54 |
<label for="phone" class="block text-sm font-medium text-gray-700 mb-1">Phone</label>
|
| 55 |
<input type="tel" id="phone" name="phone"
|
| 56 |
-
class="w-full px-4 py-
|
| 57 |
</div>
|
| 58 |
-
|
| 59 |
-
<div>
|
| 60 |
<label for="logoUrl" class="block text-sm font-medium text-gray-700 mb-1">Logo URL</label>
|
| 61 |
<div class="flex">
|
| 62 |
<input type="url" id="logoUrl" name="logoUrl"
|
| 63 |
-
class="flex-1 px-4 py-
|
| 64 |
-
<button type="button" class="bg-gray-100 px-4 border-t border-r border-b border-gray-300 rounded-r-lg hover:bg-gray-200 transition">
|
| 65 |
-
<i data-feather="upload" class="w-
|
| 66 |
</button>
|
| 67 |
</div>
|
| 68 |
</div>
|
| 69 |
-
</div>
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
Reset
|
| 74 |
</button>
|
| 75 |
-
<button type="submit" class="px-6 py-
|
| 76 |
-
<i data-feather="save" class="mr-2 w-
|
| 77 |
-
|
| 78 |
</button>
|
| 79 |
</div>
|
| 80 |
-
|
| 81 |
</div>
|
| 82 |
-
|
| 83 |
-
<div id="jsonOutput" class="max-w-2xl mx-auto mt-8 bg-gray-800 rounded-xl shadow-md overflow-hidden hidden">
|
| 84 |
<div class="bg-gray-700 p-4 flex justify-between items-center">
|
| 85 |
-
<
|
| 86 |
-
|
| 87 |
-
<
|
|
|
|
|
|
|
|
|
|
| 88 |
</button>
|
| 89 |
</div>
|
| 90 |
-
<pre class="p-4 text-gray-100 overflow-auto max-h-96"><code id="jsonContent"></code></pre>
|
| 91 |
</div>
|
| 92 |
-
|
| 93 |
|
| 94 |
<script src="script.js"></script>
|
| 95 |
<script>
|
|
|
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
<title>FormCraft Pro - JSON Data Wizard</title>
|
| 7 |
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap">
|
| 8 |
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Fira+Code&display=swap">
|
| 9 |
<link rel="stylesheet" href="style.css">
|
| 10 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 11 |
+
<script src="https://cdn.tailwindcss.com?plugins=forms,aspect-ratio,line-clamp"></script>
|
| 12 |
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 13 |
<script src="https://unpkg.com/feather-icons"></script>
|
| 14 |
+
<script>
|
| 15 |
tailwind.config = {
|
| 16 |
theme: {
|
| 17 |
extend: {
|
|
|
|
| 28 |
}
|
| 29 |
</script>
|
| 30 |
</head>
|
| 31 |
+
<body class="bg-gradient-to-br from-gray-50 to-gray-100 min-h-screen">
|
| 32 |
+
<div class="container mx-auto px-4 py-8 sm:py-12">
|
| 33 |
+
<div class="max-w-2xl mx-auto bg-white rounded-xl shadow-xl overflow-hidden transition-all duration-300 hover:shadow-2xl">
|
| 34 |
+
<div class="bg-gradient-to-r from-primary-500 to-secondary-500 p-6">
|
| 35 |
<div class="flex items-center">
|
| 36 |
+
<i data-feather="edit-3" class="text-white mr-3 w-6 h-6"></i>
|
| 37 |
+
<h1 class="text-2xl sm:text-3xl font-bold text-white">FormCraft Pro</h1>
|
| 38 |
</div>
|
| 39 |
+
<p class="text-primary-100 mt-2 opacity-90">Fill in the details below to generate JSON output</p>
|
| 40 |
</div>
|
| 41 |
+
<form id="dataForm" class="p-6 sm:p-8 space-y-6">
|
|
|
|
| 42 |
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 43 |
+
<div class="space-y-1">
|
| 44 |
+
<label for="name" class="block text-sm font-medium text-gray-700 mb-1">Name <span class="text-red-500">*</span></label>
|
| 45 |
+
<input type="text" id="name" name="name" required
|
| 46 |
+
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition placeholder-gray-400">
|
| 47 |
</div>
|
| 48 |
+
<div class="md:col-span-2 space-y-1">
|
|
|
|
| 49 |
<label for="address" class="block text-sm font-medium text-gray-700 mb-1">Address</label>
|
| 50 |
<textarea id="address" name="address" rows="3"
|
| 51 |
+
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition placeholder-gray-400"></textarea>
|
| 52 |
</div>
|
| 53 |
+
<div class="space-y-1">
|
|
|
|
| 54 |
<label for="phone" class="block text-sm font-medium text-gray-700 mb-1">Phone</label>
|
| 55 |
<input type="tel" id="phone" name="phone"
|
| 56 |
+
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition placeholder-gray-400">
|
| 57 |
</div>
|
| 58 |
+
<div class="space-y-1">
|
|
|
|
| 59 |
<label for="logoUrl" class="block text-sm font-medium text-gray-700 mb-1">Logo URL</label>
|
| 60 |
<div class="flex">
|
| 61 |
<input type="url" id="logoUrl" name="logoUrl"
|
| 62 |
+
class="flex-1 px-4 py-3 border border-gray-300 rounded-l-lg focus:ring-2 focus:ring-primary-500 focus:border-primary-500 transition placeholder-gray-400">
|
| 63 |
+
<button type="button" class="bg-gray-100 px-4 border-t border-r border-b border-gray-300 rounded-r-lg hover:bg-gray-200 transition flex items-center justify-center">
|
| 64 |
+
<i data-feather="upload" class="w-5 h-5"></i>
|
| 65 |
</button>
|
| 66 |
</div>
|
| 67 |
</div>
|
| 68 |
+
</div>
|
| 69 |
+
<div class="flex flex-col sm:flex-row justify-end space-y-3 sm:space-y-0 sm:space-x-4 pt-4">
|
| 70 |
+
<button type="reset" class="px-6 py-3 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 transition font-medium">
|
| 71 |
+
Reset Form
|
|
|
|
| 72 |
</button>
|
| 73 |
+
<button type="submit" class="px-6 py-3 bg-primary-500 text-white rounded-lg hover:bg-primary-600 transition flex items-center justify-center font-medium shadow-md hover:shadow-lg">
|
| 74 |
+
<i data-feather="save" class="mr-2 w-5 h-5"></i>
|
| 75 |
+
Generate JSON
|
| 76 |
</button>
|
| 77 |
</div>
|
| 78 |
+
</form>
|
| 79 |
</div>
|
| 80 |
+
<div id="jsonOutput" class="max-w-2xl mx-auto mt-8 bg-gray-800 rounded-xl shadow-lg overflow-hidden hidden">
|
|
|
|
| 81 |
<div class="bg-gray-700 p-4 flex justify-between items-center">
|
| 82 |
+
<div class="flex items-center">
|
| 83 |
+
<i data-feather="code" class="text-gray-300 mr-2 w-5 h-5"></i>
|
| 84 |
+
<h2 class="text-lg font-medium text-white">JSON Output</h2>
|
| 85 |
+
</div>
|
| 86 |
+
<button id="copyJson" class="text-gray-300 hover:text-white transition p-2 rounded-full hover:bg-gray-600">
|
| 87 |
+
<i data-feather="copy" class="w-5 h-5"></i>
|
| 88 |
</button>
|
| 89 |
</div>
|
| 90 |
+
<pre class="p-4 text-gray-100 overflow-auto max-h-96"><code id="jsonContent" class="language-json"></code></pre>
|
| 91 |
</div>
|
| 92 |
+
</div>
|
| 93 |
|
| 94 |
<script src="script.js"></script>
|
| 95 |
<script>
|
script.js
CHANGED
|
@@ -17,23 +17,28 @@ address: formData.get('address'),
|
|
| 17 |
// Display formatted JSON
|
| 18 |
jsonContent.textContent = JSON.stringify(data, null, 2);
|
| 19 |
jsonOutput.classList.remove('hidden');
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
copyButton.addEventListener('click', function() {
|
| 26 |
const textToCopy = jsonContent.textContent;
|
| 27 |
navigator.clipboard.writeText(textToCopy).then(() => {
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
feather.replace();
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
copyButton.innerHTML = originalIcon;
|
| 35 |
-
feather.replace();
|
| 36 |
-
}, 2000);
|
| 37 |
-
});
|
| 38 |
});
|
| 39 |
});
|
|
|
|
| 17 |
// Display formatted JSON
|
| 18 |
jsonContent.textContent = JSON.stringify(data, null, 2);
|
| 19 |
jsonOutput.classList.remove('hidden');
|
| 20 |
+
// Scroll to output with offset
|
| 21 |
+
setTimeout(() => {
|
| 22 |
+
window.scrollTo({
|
| 23 |
+
top: jsonOutput.offsetTop - 20,
|
| 24 |
+
behavior: 'smooth'
|
| 25 |
+
});
|
| 26 |
+
}, 100);
|
| 27 |
+
});
|
| 28 |
|
| 29 |
copyButton.addEventListener('click', function() {
|
| 30 |
const textToCopy = jsonContent.textContent;
|
| 31 |
navigator.clipboard.writeText(textToCopy).then(() => {
|
| 32 |
+
// Show copied feedback
|
| 33 |
+
const icon = copyButton.querySelector('i');
|
| 34 |
+
const originalIcon = icon.dataset.feather;
|
| 35 |
+
icon.setAttribute('data-feather', 'check');
|
| 36 |
+
feather.replace();
|
| 37 |
+
|
| 38 |
+
setTimeout(() => {
|
| 39 |
+
icon.setAttribute('data-feather', originalIcon);
|
| 40 |
feather.replace();
|
| 41 |
+
}, 2000);
|
| 42 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
});
|
| 44 |
});
|
style.css
CHANGED
|
@@ -1,35 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
/* Custom styles that can't be achieved with Tailwind */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
#jsonOutput pre {
|
| 3 |
-
|
| 4 |
-
|
| 5 |
}
|
| 6 |
|
| 7 |
#jsonOutput code {
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
}
|
| 12 |
|
| 13 |
-
/*
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
}
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
width: 8px;
|
| 22 |
}
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
}
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
}
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
/* Base Styles */
|
| 3 |
+
:root {
|
| 4 |
+
--primary: #6366F1;
|
| 5 |
+
--primary-hover: #4F46E5;
|
| 6 |
+
--secondary: #EC4899;
|
| 7 |
+
--dark: #1F2937;
|
| 8 |
+
--light: #F9FAFB;
|
| 9 |
+
--gray: #E5E7EB;
|
| 10 |
+
--dark-gray: #6B7280;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
/* Custom styles that can't be achieved with Tailwind */
|
| 14 |
+
body {
|
| 15 |
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
|
| 16 |
+
line-height: 1.5;
|
| 17 |
+
color: #1F2937;
|
| 18 |
+
}
|
| 19 |
+
/* Form Container */
|
| 20 |
+
.container {
|
| 21 |
+
max-width: 100%;
|
| 22 |
+
padding: 0 1rem;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/* Card Styles */
|
| 26 |
+
.rounded-xl {
|
| 27 |
+
border-radius: 1rem;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
.shadow-md {
|
| 31 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/* Form Elements */
|
| 35 |
+
input, textarea, select {
|
| 36 |
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
| 37 |
+
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
input:focus, textarea:focus, select:focus {
|
| 41 |
+
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
|
| 42 |
+
border-color: var(--primary);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/* Buttons */
|
| 46 |
+
button {
|
| 47 |
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
button[type="submit"]:hover {
|
| 51 |
+
background-color: var(--primary-hover);
|
| 52 |
+
transform: translateY(-1px);
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
/* JSON Output */
|
| 56 |
#jsonOutput pre {
|
| 57 |
+
background-color: var(--dark);
|
| 58 |
+
border-radius: 0 0 1rem 1rem;
|
| 59 |
}
|
| 60 |
|
| 61 |
#jsonOutput code {
|
| 62 |
+
font-family: 'Fira Code', 'Courier New', monospace;
|
| 63 |
+
font-size: 0.875rem;
|
| 64 |
+
line-height: 1.5;
|
| 65 |
}
|
| 66 |
|
| 67 |
+
/* Custom scrollbar */
|
| 68 |
+
::-webkit-scrollbar {
|
| 69 |
+
width: 8px;
|
| 70 |
+
height: 8px;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
::-webkit-scrollbar-track {
|
| 74 |
+
background: var(--gray);
|
| 75 |
}
|
| 76 |
|
| 77 |
+
::-webkit-scrollbar-thumb {
|
| 78 |
+
background: var(--dark-gray);
|
| 79 |
+
border-radius: 4px;
|
|
|
|
| 80 |
}
|
| 81 |
|
| 82 |
+
::-webkit-scrollbar-thumb:hover {
|
| 83 |
+
background: #9CA3AF;
|
| 84 |
}
|
| 85 |
|
| 86 |
+
/* Responsive Adjustments */
|
| 87 |
+
@media (max-width: 640px) {
|
| 88 |
+
.container {
|
| 89 |
+
padding: 0 0.5rem;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
.grid-cols-2 {
|
| 93 |
+
grid-template-columns: 1fr !important;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
.flex-col {
|
| 97 |
+
flex-direction: column;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
.space-y-6 > * + * {
|
| 101 |
+
margin-top: 1.5rem;
|
| 102 |
+
}
|
| 103 |
}
|
| 104 |
|
| 105 |
+
/* Animations */
|
| 106 |
+
@keyframes fadeIn {
|
| 107 |
+
from { opacity: 0; transform: translateY(10px); }
|
| 108 |
+
to { opacity: 1; transform: translateY(0); }
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
#jsonOutput {
|
| 112 |
+
animation: fadeIn 0.3s ease-out forwards;
|
| 113 |
+
}
|