Spaces:
Running
Running
Add 3 files
Browse files- README.md +7 -5
- index.html +905 -19
- prompts.txt +1 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: gradiant-picker
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: green
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,905 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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title>Gradient Picker | Interactive Color Tool</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/chroma-js@2.1.2/chroma.min.js"></script>
|
| 9 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 10 |
+
<style>
|
| 11 |
+
.gradient-preview {
|
| 12 |
+
height: 120px;
|
| 13 |
+
border-radius: 0.5rem;
|
| 14 |
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
| 15 |
+
}
|
| 16 |
+
.color-slider {
|
| 17 |
+
-webkit-appearance: none;
|
| 18 |
+
width: 100%;
|
| 19 |
+
height: 8px;
|
| 20 |
+
border-radius: 4px;
|
| 21 |
+
outline: none;
|
| 22 |
+
}
|
| 23 |
+
.color-slider::-webkit-slider-thumb {
|
| 24 |
+
-webkit-appearance: none;
|
| 25 |
+
appearance: none;
|
| 26 |
+
width: 20px;
|
| 27 |
+
height: 20px;
|
| 28 |
+
border-radius: 50%;
|
| 29 |
+
cursor: pointer;
|
| 30 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
| 31 |
+
border: 2px solid white;
|
| 32 |
+
}
|
| 33 |
+
.color-picker-handle {
|
| 34 |
+
width: 24px;
|
| 35 |
+
height: 24px;
|
| 36 |
+
border-radius: 50%;
|
| 37 |
+
background: white;
|
| 38 |
+
border: 2px solid #333;
|
| 39 |
+
position: absolute;
|
| 40 |
+
top: -10px;
|
| 41 |
+
transform: translateX(-12px);
|
| 42 |
+
cursor: pointer;
|
| 43 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
| 44 |
+
}
|
| 45 |
+
.color-picker-handle::after {
|
| 46 |
+
content: '';
|
| 47 |
+
position: absolute;
|
| 48 |
+
width: 8px;
|
| 49 |
+
height: 8px;
|
| 50 |
+
background: #333;
|
| 51 |
+
border-radius: 50%;
|
| 52 |
+
top: 50%;
|
| 53 |
+
left: 50%;
|
| 54 |
+
transform: translate(-50%, -50%);
|
| 55 |
+
}
|
| 56 |
+
.color-block {
|
| 57 |
+
transition: all 0.2s ease;
|
| 58 |
+
cursor: pointer;
|
| 59 |
+
}
|
| 60 |
+
.color-block:hover {
|
| 61 |
+
transform: scale(1.05);
|
| 62 |
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
| 63 |
+
}
|
| 64 |
+
.copy-btn {
|
| 65 |
+
transition: all 0.2s ease;
|
| 66 |
+
}
|
| 67 |
+
.copy-btn:hover {
|
| 68 |
+
transform: translateY(-2px);
|
| 69 |
+
}
|
| 70 |
+
.copy-btn:active {
|
| 71 |
+
transform: translateY(0);
|
| 72 |
+
}
|
| 73 |
+
.tab-content {
|
| 74 |
+
display: none;
|
| 75 |
+
}
|
| 76 |
+
.tab-content.active {
|
| 77 |
+
display: block;
|
| 78 |
+
}
|
| 79 |
+
.contrast-ratio {
|
| 80 |
+
font-weight: bold;
|
| 81 |
+
}
|
| 82 |
+
.contrast-ratio.aa-pass {
|
| 83 |
+
color: #10b981;
|
| 84 |
+
}
|
| 85 |
+
.contrast-ratio.aa-fail {
|
| 86 |
+
color: #ef4444;
|
| 87 |
+
}
|
| 88 |
+
.contrast-ratio.aaa-pass {
|
| 89 |
+
color: #10b981;
|
| 90 |
+
}
|
| 91 |
+
.contrast-ratio.aaa-fail {
|
| 92 |
+
color: #ef4444;
|
| 93 |
+
}
|
| 94 |
+
</style>
|
| 95 |
+
</head>
|
| 96 |
+
<body class="bg-gray-50 text-gray-800 dark:bg-gray-900 dark:text-gray-200 min-h-screen">
|
| 97 |
+
<div class="container mx-auto px-4 py-8">
|
| 98 |
+
<header class="mb-8 text-center">
|
| 99 |
+
<h1 class="text-3xl md:text-4xl font-bold bg-gradient-to-r from-purple-600 to-blue-500 bg-clip-text text-transparent">Gradient Picker</h1>
|
| 100 |
+
<p class="mt-2 text-gray-600 dark:text-gray-400">Create, explore and export beautiful color gradients</p>
|
| 101 |
+
</header>
|
| 102 |
+
|
| 103 |
+
<div class="max-w-4xl mx-auto bg-white dark:bg-gray-800 rounded-xl shadow-lg overflow-hidden p-6 mb-8">
|
| 104 |
+
<!-- Color Inputs -->
|
| 105 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
|
| 106 |
+
<div class="color-input">
|
| 107 |
+
<div class="flex items-center justify-between mb-2">
|
| 108 |
+
<label class="font-medium">Start Color</label>
|
| 109 |
+
<div class="flex items-center">
|
| 110 |
+
<input type="text" id="color1-hex" value="#3b82f6" class="w-24 px-2 py-1 border rounded text-sm font-mono">
|
| 111 |
+
<button class="copy-btn ml-2 p-1 rounded-full text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100" onclick="copyToClipboard('color1-hex')">
|
| 112 |
+
<i class="far fa-copy"></i>
|
| 113 |
+
</button>
|
| 114 |
+
</div>
|
| 115 |
+
</div>
|
| 116 |
+
<input type="color" id="color1" value="#3b82f6" class="w-full h-10 rounded cursor-pointer">
|
| 117 |
+
<div class="mt-2 grid grid-cols-3 gap-2">
|
| 118 |
+
<div>
|
| 119 |
+
<label class="text-xs text-gray-500 dark:text-gray-400">RGB</label>
|
| 120 |
+
<input type="text" id="color1-rgb" readonly class="w-full px-2 py-1 border rounded text-sm font-mono bg-gray-50 dark:bg-gray-700">
|
| 121 |
+
</div>
|
| 122 |
+
<div>
|
| 123 |
+
<label class="text-xs text-gray-500 dark:text-gray-400">HSL</label>
|
| 124 |
+
<input type="text" id="color1-hsl" readonly class="w-full px-2 py-1 border rounded text-sm font-mono bg-gray-50 dark:bg-gray-700">
|
| 125 |
+
</div>
|
| 126 |
+
<div>
|
| 127 |
+
<label class="text-xs text-gray-500 dark:text-gray-400">Name</label>
|
| 128 |
+
<input type="text" id="color1-name" readonly class="w-full px-2 py-1 border rounded text-sm font-mono bg-gray-50 dark:bg-gray-700">
|
| 129 |
+
</div>
|
| 130 |
+
</div>
|
| 131 |
+
</div>
|
| 132 |
+
|
| 133 |
+
<div class="color-input">
|
| 134 |
+
<div class="flex items-center justify-between mb-2">
|
| 135 |
+
<label class="font-medium">End Color</label>
|
| 136 |
+
<div class="flex items-center">
|
| 137 |
+
<input type="text" id="color2-hex" value="#ec4899" class="w-24 px-2 py-1 border rounded text-sm font-mono">
|
| 138 |
+
<button class="copy-btn ml-2 p-1 rounded-full text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100" onclick="copyToClipboard('color2-hex')">
|
| 139 |
+
<i class="far fa-copy"></i>
|
| 140 |
+
</button>
|
| 141 |
+
</div>
|
| 142 |
+
</div>
|
| 143 |
+
<input type="color" id="color2" value="#ec4899" class="w-full h-10 rounded cursor-pointer">
|
| 144 |
+
<div class="mt-2 grid grid-cols-3 gap-2">
|
| 145 |
+
<div>
|
| 146 |
+
<label class="text-xs text-gray-500 dark:text-gray-400">RGB</label>
|
| 147 |
+
<input type="text" id="color2-rgb" readonly class="w-full px-2 py-1 border rounded text-sm font-mono bg-gray-50 dark:bg-gray-700">
|
| 148 |
+
</div>
|
| 149 |
+
<div>
|
| 150 |
+
<label class="text-xs text-gray-500 dark:text-gray-400">HSL</label>
|
| 151 |
+
<input type="text" id="color2-hsl" readonly class="w-full px-2 py-1 border rounded text-sm font-mono bg-gray-50 dark:bg-gray-700">
|
| 152 |
+
</div>
|
| 153 |
+
<div>
|
| 154 |
+
<label class="text-xs text-gray-500 dark:text-gray-400">Name</label>
|
| 155 |
+
<input type="text" id="color2-name" readonly class="w-full px-2 py-1 border rounded text-sm font-mono bg-gray-50 dark:bg-gray-700">
|
| 156 |
+
</div>
|
| 157 |
+
</div>
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
|
| 161 |
+
<!-- Gradient Controls -->
|
| 162 |
+
<div class="mb-6">
|
| 163 |
+
<div class="flex items-center justify-between mb-2">
|
| 164 |
+
<label class="font-medium">Gradient Steps</label>
|
| 165 |
+
<span id="steps-value" class="font-mono">5</span>
|
| 166 |
+
</div>
|
| 167 |
+
<input type="range" id="steps" min="2" max="20" value="5" class="color-slider">
|
| 168 |
+
</div>
|
| 169 |
+
|
| 170 |
+
<!-- Gradient Preview -->
|
| 171 |
+
<div class="mb-6 relative">
|
| 172 |
+
<div id="gradient-preview" class="gradient-preview" style="background: linear-gradient(to right, #3b82f6, #ec4899);"></div>
|
| 173 |
+
<div id="color-picker-handle" class="color-picker-handle" style="left: 50%;"></div>
|
| 174 |
+
</div>
|
| 175 |
+
|
| 176 |
+
<!-- Picked Color Info -->
|
| 177 |
+
<div id="picked-color-info" class="bg-gray-100 dark:bg-gray-700 rounded-lg p-4 mb-6 hidden">
|
| 178 |
+
<div class="flex items-center justify-between">
|
| 179 |
+
<div class="flex items-center">
|
| 180 |
+
<div id="picked-color-swatch" class="w-10 h-10 rounded-full border-2 border-white shadow mr-3"></div>
|
| 181 |
+
<div>
|
| 182 |
+
<div class="font-medium">Selected Color</div>
|
| 183 |
+
<div id="picked-color-hex" class="text-sm font-mono">#9d7dce</div>
|
| 184 |
+
</div>
|
| 185 |
+
</div>
|
| 186 |
+
<button id="copy-picked-color" class="copy-btn px-3 py-1 bg-gray-200 dark:bg-gray-600 rounded-full text-sm flex items-center">
|
| 187 |
+
<i class="far fa-copy mr-1"></i> Copy
|
| 188 |
+
</button>
|
| 189 |
+
</div>
|
| 190 |
+
<div class="mt-3 grid grid-cols-3 gap-2">
|
| 191 |
+
<div>
|
| 192 |
+
<label class="text-xs text-gray-500 dark:text-gray-400">RGB</label>
|
| 193 |
+
<input type="text" id="picked-color-rgb" readonly class="w-full px-2 py-1 border rounded text-sm font-mono bg-gray-50 dark:bg-gray-700">
|
| 194 |
+
</div>
|
| 195 |
+
<div>
|
| 196 |
+
<label class="text-xs text-gray-500 dark:text-gray-400">HSL</label>
|
| 197 |
+
<input type="text" id="picked-color-hsl" readonly class="w-full px-2 py-1 border rounded text-sm font-mono bg-gray-50 dark:bg-gray-700">
|
| 198 |
+
</div>
|
| 199 |
+
<div>
|
| 200 |
+
<label class="text-xs text-gray-500 dark:text-gray-400">Name</label>
|
| 201 |
+
<input type="text" id="picked-color-name" readonly class="w-full px-2 py-1 border rounded text-sm font-mono bg-gray-50 dark:bg-gray-700">
|
| 202 |
+
</div>
|
| 203 |
+
</div>
|
| 204 |
+
</div>
|
| 205 |
+
|
| 206 |
+
<!-- Color Steps -->
|
| 207 |
+
<div class="mb-6">
|
| 208 |
+
<h3 class="font-medium mb-3">Color Steps</h3>
|
| 209 |
+
<div id="color-steps" class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-3">
|
| 210 |
+
<!-- Color blocks will be generated here -->
|
| 211 |
+
</div>
|
| 212 |
+
</div>
|
| 213 |
+
|
| 214 |
+
<!-- Tabs -->
|
| 215 |
+
<div class="mb-6">
|
| 216 |
+
<div class="flex border-b border-gray-200 dark:border-gray-700">
|
| 217 |
+
<button class="tab-btn px-4 py-2 font-medium text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400" data-tab="export">Export</button>
|
| 218 |
+
<button class="tab-btn px-4 py-2 font-medium text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100" data-tab="harmonies">Color Harmonies</button>
|
| 219 |
+
<button class="tab-btn px-4 py-2 font-medium text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100" data-tab="contrast">Contrast Checker</button>
|
| 220 |
+
<button class="tab-btn px-4 py-2 font-medium text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100" data-tab="preview">UI Preview</button>
|
| 221 |
+
</div>
|
| 222 |
+
|
| 223 |
+
<div id="export" class="tab-content active mt-4">
|
| 224 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 225 |
+
<div>
|
| 226 |
+
<label class="block text-sm font-medium mb-2">CSS Gradient</label>
|
| 227 |
+
<div class="relative">
|
| 228 |
+
<textarea id="css-gradient" readonly class="w-full h-20 px-3 py-2 border rounded font-mono text-sm bg-gray-50 dark:bg-gray-700"></textarea>
|
| 229 |
+
<button onclick="copyToClipboard('css-gradient')" class="absolute top-2 right-2 copy-btn px-2 py-1 bg-gray-200 dark:bg-gray-600 rounded text-xs">
|
| 230 |
+
<i class="far fa-copy mr-1"></i> Copy
|
| 231 |
+
</button>
|
| 232 |
+
</div>
|
| 233 |
+
</div>
|
| 234 |
+
<div>
|
| 235 |
+
<label class="block text-sm font-medium mb-2">SVG Gradient</label>
|
| 236 |
+
<div class="relative">
|
| 237 |
+
<textarea id="svg-gradient" readonly class="w-full h-20 px-3 py-2 border rounded font-mono text-sm bg-gray-50 dark:bg-gray-700"></textarea>
|
| 238 |
+
<button onclick="copyToClipboard('svg-gradient')" class="absolute top-2 right-2 copy-btn px-2 py-1 bg-gray-200 dark:bg-gray-600 rounded text-xs">
|
| 239 |
+
<i class="far fa-copy mr-1"></i> Copy
|
| 240 |
+
</button>
|
| 241 |
+
</div>
|
| 242 |
+
</div>
|
| 243 |
+
</div>
|
| 244 |
+
<div class="mt-4">
|
| 245 |
+
<button id="download-png" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded flex items-center">
|
| 246 |
+
<i class="fas fa-download mr-2"></i> Download PNG
|
| 247 |
+
</button>
|
| 248 |
+
</div>
|
| 249 |
+
</div>
|
| 250 |
+
|
| 251 |
+
<div id="harmonies" class="tab-content mt-4">
|
| 252 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 253 |
+
<div>
|
| 254 |
+
<h4 class="font-medium mb-3">Complementary</h4>
|
| 255 |
+
<div id="complementary-colors" class="grid grid-cols-5 gap-2">
|
| 256 |
+
<!-- Complementary colors will be generated here -->
|
| 257 |
+
</div>
|
| 258 |
+
</div>
|
| 259 |
+
<div>
|
| 260 |
+
<h4 class="font-medium mb-3">Analogous</h4>
|
| 261 |
+
<div id="analogous-colors" class="grid grid-cols-3 gap-2">
|
| 262 |
+
<!-- Analogous colors will be generated here -->
|
| 263 |
+
</div>
|
| 264 |
+
</div>
|
| 265 |
+
<div>
|
| 266 |
+
<h4 class="font-medium mb-3">Triadic</h4>
|
| 267 |
+
<div id="triadic-colors" class="grid grid-cols-3 gap-2">
|
| 268 |
+
<!-- Triadic colors will be generated here -->
|
| 269 |
+
</div>
|
| 270 |
+
</div>
|
| 271 |
+
<div>
|
| 272 |
+
<h4 class="font-medium mb-3">Tetradic</h4>
|
| 273 |
+
<div id="tetradic-colors" class="grid grid-cols-4 gap-2">
|
| 274 |
+
<!-- Tetradic colors will be generated here -->
|
| 275 |
+
</div>
|
| 276 |
+
</div>
|
| 277 |
+
</div>
|
| 278 |
+
</div>
|
| 279 |
+
|
| 280 |
+
<div id="contrast" class="tab-content mt-4">
|
| 281 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 282 |
+
<div>
|
| 283 |
+
<h4 class="font-medium mb-3">Contrast Ratio</h4>
|
| 284 |
+
<div class="bg-gray-100 dark:bg-gray-700 p-4 rounded-lg">
|
| 285 |
+
<div class="flex items-center justify-between mb-2">
|
| 286 |
+
<span>WCAG AA (4.5:1)</span>
|
| 287 |
+
<span id="contrast-aa" class="contrast-ratio aa-pass">4.8:1</span>
|
| 288 |
+
</div>
|
| 289 |
+
<div class="flex items-center justify-between mb-2">
|
| 290 |
+
<span>WCAG AAA (7:1)</span>
|
| 291 |
+
<span id="contrast-aaa" class="contrast-ratio aaa-fail">4.8:1</span>
|
| 292 |
+
</div>
|
| 293 |
+
<div class="mt-4">
|
| 294 |
+
<label class="block text-sm font-medium mb-2">Test Background</label>
|
| 295 |
+
<input type="color" id="contrast-bg" value="#ffffff" class="w-full h-10 rounded cursor-pointer">
|
| 296 |
+
</div>
|
| 297 |
+
</div>
|
| 298 |
+
</div>
|
| 299 |
+
<div>
|
| 300 |
+
<h4 class="font-medium mb-3">Preview</h4>
|
| 301 |
+
<div id="contrast-preview" class="p-4 rounded-lg" style="background-color: #ffffff;">
|
| 302 |
+
<p class="text-lg" style="color: #3b82f6;">This is sample text to demonstrate contrast</p>
|
| 303 |
+
<p class="text-sm mt-2" style="color: #3b82f6;">Smaller text requires higher contrast</p>
|
| 304 |
+
</div>
|
| 305 |
+
</div>
|
| 306 |
+
</div>
|
| 307 |
+
</div>
|
| 308 |
+
|
| 309 |
+
<div id="preview" class="tab-content mt-4">
|
| 310 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 311 |
+
<div>
|
| 312 |
+
<div class="bg-gray-100 dark:bg-gray-700 p-4 rounded-lg">
|
| 313 |
+
<div class="flex items-center justify-between mb-3">
|
| 314 |
+
<h4 class="font-medium">Card</h4>
|
| 315 |
+
<div class="flex">
|
| 316 |
+
<button class="preview-mode-btn px-2 py-1 text-xs bg-gray-200 dark:bg-gray-600 rounded-l" data-mode="light">Light</button>
|
| 317 |
+
<button class="preview-mode-btn px-2 py-1 text-xs bg-gray-300 dark:bg-gray-800 rounded-r" data-mode="dark">Dark</button>
|
| 318 |
+
</div>
|
| 319 |
+
</div>
|
| 320 |
+
<div class="preview-card p-4 rounded-lg shadow" style="background: linear-gradient(to right, #3b82f6, #ec4899);">
|
| 321 |
+
<h5 class="font-bold text-white">Card Title</h5>
|
| 322 |
+
<p class="text-white text-opacity-90 text-sm mt-1">This is a preview card with your gradient</p>
|
| 323 |
+
</div>
|
| 324 |
+
</div>
|
| 325 |
+
</div>
|
| 326 |
+
<div>
|
| 327 |
+
<div class="bg-gray-100 dark:bg-gray-700 p-4 rounded-lg">
|
| 328 |
+
<h4 class="font-medium mb-3">Buttons</h4>
|
| 329 |
+
<div class="grid grid-cols-2 gap-3">
|
| 330 |
+
<button class="px-4 py-2 rounded text-white font-medium" style="background-color: #3b82f6;">Primary</button>
|
| 331 |
+
<button class="px-4 py-2 rounded text-white font-medium" style="background-color: #ec4899;">Secondary</button>
|
| 332 |
+
<button class="px-4 py-2 rounded font-medium border" style="border-color: #3b82f6; color: #3b82f6;">Outline</button>
|
| 333 |
+
<button class="px-4 py-2 rounded font-medium border" style="border-color: #ec4899; color: #ec4899;">Outline</button>
|
| 334 |
+
</div>
|
| 335 |
+
</div>
|
| 336 |
+
</div>
|
| 337 |
+
</div>
|
| 338 |
+
</div>
|
| 339 |
+
</div>
|
| 340 |
+
</div>
|
| 341 |
+
|
| 342 |
+
<footer class="text-center text-gray-600 dark:text-gray-400 text-sm mt-8">
|
| 343 |
+
<p>Gradient Picker © 2023 | Made with <i class="fas fa-heart text-red-500"></i> for designers & developers</p>
|
| 344 |
+
</footer>
|
| 345 |
+
</div>
|
| 346 |
+
|
| 347 |
+
<script>
|
| 348 |
+
// DOM Elements
|
| 349 |
+
const color1Input = document.getElementById('color1');
|
| 350 |
+
const color1HexInput = document.getElementById('color1-hex');
|
| 351 |
+
const color1RgbInput = document.getElementById('color1-rgb');
|
| 352 |
+
const color1HslInput = document.getElementById('color1-hsl');
|
| 353 |
+
const color1NameInput = document.getElementById('color1-name');
|
| 354 |
+
|
| 355 |
+
const color2Input = document.getElementById('color2');
|
| 356 |
+
const color2HexInput = document.getElementById('color2-hex');
|
| 357 |
+
const color2RgbInput = document.getElementById('color2-rgb');
|
| 358 |
+
const color2HslInput = document.getElementById('color2-hsl');
|
| 359 |
+
const color2NameInput = document.getElementById('color2-name');
|
| 360 |
+
|
| 361 |
+
const stepsInput = document.getElementById('steps');
|
| 362 |
+
const stepsValue = document.getElementById('steps-value');
|
| 363 |
+
|
| 364 |
+
const gradientPreview = document.getElementById('gradient-preview');
|
| 365 |
+
const colorPickerHandle = document.getElementById('color-picker-handle');
|
| 366 |
+
|
| 367 |
+
const pickedColorInfo = document.getElementById('picked-color-info');
|
| 368 |
+
const pickedColorSwatch = document.getElementById('picked-color-swatch');
|
| 369 |
+
const pickedColorHex = document.getElementById('picked-color-hex');
|
| 370 |
+
const pickedColorRgb = document.getElementById('picked-color-rgb');
|
| 371 |
+
const pickedColorHsl = document.getElementById('picked-color-hsl');
|
| 372 |
+
const pickedColorName = document.getElementById('picked-color-name');
|
| 373 |
+
const copyPickedColorBtn = document.getElementById('copy-picked-color');
|
| 374 |
+
|
| 375 |
+
const colorStepsContainer = document.getElementById('color-steps');
|
| 376 |
+
|
| 377 |
+
const cssGradientTextarea = document.getElementById('css-gradient');
|
| 378 |
+
const svgGradientTextarea = document.getElementById('svg-gradient');
|
| 379 |
+
const downloadPngBtn = document.getElementById('download-png');
|
| 380 |
+
|
| 381 |
+
const complementaryColorsContainer = document.getElementById('complementary-colors');
|
| 382 |
+
const analogousColorsContainer = document.getElementById('analogous-colors');
|
| 383 |
+
const triadicColorsContainer = document.getElementById('triadic-colors');
|
| 384 |
+
const tetradicColorsContainer = document.getElementById('tetradic-colors');
|
| 385 |
+
|
| 386 |
+
const contrastRatioAA = document.getElementById('contrast-aa');
|
| 387 |
+
const contrastRatioAAA = document.getElementById('contrast-aaa');
|
| 388 |
+
const contrastBgInput = document.getElementById('contrast-bg');
|
| 389 |
+
const contrastPreview = document.getElementById('contrast-preview');
|
| 390 |
+
|
| 391 |
+
// Tab functionality
|
| 392 |
+
const tabButtons = document.querySelectorAll('.tab-btn');
|
| 393 |
+
tabButtons.forEach(button => {
|
| 394 |
+
button.addEventListener('click', () => {
|
| 395 |
+
// Remove active class from all buttons and content
|
| 396 |
+
tabButtons.forEach(btn => {
|
| 397 |
+
btn.classList.remove('text-blue-600', 'dark:text-blue-400', 'border-b-2', 'border-blue-600', 'dark:border-blue-400');
|
| 398 |
+
btn.classList.add('text-gray-600', 'dark:text-gray-400');
|
| 399 |
+
});
|
| 400 |
+
|
| 401 |
+
// Add active class to clicked button
|
| 402 |
+
button.classList.add('text-blue-600', 'dark:text-blue-400', 'border-b-2', 'border-blue-600', 'dark:border-blue-400');
|
| 403 |
+
button.classList.remove('text-gray-600', 'dark:text-gray-400');
|
| 404 |
+
|
| 405 |
+
// Hide all tab content
|
| 406 |
+
document.querySelectorAll('.tab-content').forEach(content => {
|
| 407 |
+
content.classList.remove('active');
|
| 408 |
+
});
|
| 409 |
+
|
| 410 |
+
// Show selected tab content
|
| 411 |
+
const tabId = button.getAttribute('data-tab');
|
| 412 |
+
document.getElementById(tabId).classList.add('active');
|
| 413 |
+
});
|
| 414 |
+
});
|
| 415 |
+
|
| 416 |
+
// Preview mode (light/dark)
|
| 417 |
+
const previewModeButtons = document.querySelectorAll('.preview-mode-btn');
|
| 418 |
+
previewModeButtons.forEach(button => {
|
| 419 |
+
button.addEventListener('click', () => {
|
| 420 |
+
previewModeButtons.forEach(btn => {
|
| 421 |
+
btn.classList.remove('bg-gray-300', 'dark:bg-gray-800');
|
| 422 |
+
btn.classList.add('bg-gray-200', 'dark:bg-gray-600');
|
| 423 |
+
});
|
| 424 |
+
|
| 425 |
+
button.classList.add('bg-gray-300', 'dark:bg-gray-800');
|
| 426 |
+
button.classList.remove('bg-gray-200', 'dark:bg-gray-600');
|
| 427 |
+
|
| 428 |
+
const mode = button.getAttribute('data-mode');
|
| 429 |
+
const previewCard = document.querySelector('.preview-card');
|
| 430 |
+
|
| 431 |
+
if (mode === 'dark') {
|
| 432 |
+
previewCard.classList.add('dark-mode-preview');
|
| 433 |
+
previewCard.querySelector('h5').classList.add('dark:text-white');
|
| 434 |
+
previewCard.querySelector('p').classList.add('dark:text-white');
|
| 435 |
+
} else {
|
| 436 |
+
previewCard.classList.remove('dark-mode-preview');
|
| 437 |
+
previewCard.querySelector('h5').classList.remove('dark:text-white');
|
| 438 |
+
previewCard.querySelector('p').classList.remove('dark:text-white');
|
| 439 |
+
}
|
| 440 |
+
});
|
| 441 |
+
});
|
| 442 |
+
|
| 443 |
+
// Initialize
|
| 444 |
+
function init() {
|
| 445 |
+
updateColorInfo(color1Input, color1HexInput, color1RgbInput, color1HslInput, color1NameInput);
|
| 446 |
+
updateColorInfo(color2Input, color2HexInput, color2RgbInput, color2HslInput, color2NameInput);
|
| 447 |
+
updateGradient();
|
| 448 |
+
updateColorSteps();
|
| 449 |
+
updateColorHarmonies();
|
| 450 |
+
updateContrastRatio();
|
| 451 |
+
|
| 452 |
+
// Set initial tab
|
| 453 |
+
document.querySelector('.tab-btn[data-tab="export"]').click();
|
| 454 |
+
}
|
| 455 |
+
|
| 456 |
+
// Update color information
|
| 457 |
+
function updateColorInfo(colorInput, hexInput, rgbInput, hslInput, nameInput) {
|
| 458 |
+
const color = chroma(colorInput.value);
|
| 459 |
+
|
| 460 |
+
// Update hex value
|
| 461 |
+
hexInput.value = color.hex();
|
| 462 |
+
|
| 463 |
+
// Update RGB value
|
| 464 |
+
const rgb = color.rgb();
|
| 465 |
+
rgbInput.value = `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`;
|
| 466 |
+
|
| 467 |
+
// Update HSL value
|
| 468 |
+
const hsl = color.hsl();
|
| 469 |
+
hslInput.value = `hsl(${Math.round(hsl[0])}, ${Math.round(hsl[1] * 100)}%, ${Math.round(hsl[2] * 100)}%)`;
|
| 470 |
+
|
| 471 |
+
// Update color name (simplified)
|
| 472 |
+
nameInput.value = getColorName(color.hex());
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
// Simple color name lookup
|
| 476 |
+
function getColorName(hex) {
|
| 477 |
+
const colorMap = {
|
| 478 |
+
'#3b82f6': 'Blue 500',
|
| 479 |
+
'#ec4899': 'Pink 500',
|
| 480 |
+
'#ffffff': 'White',
|
| 481 |
+
'#000000': 'Black',
|
| 482 |
+
'#f59e0b': 'Amber 500',
|
| 483 |
+
'#10b981': 'Emerald 500',
|
| 484 |
+
'#ef4444': 'Red 500',
|
| 485 |
+
'#8b5cf6': 'Violet 500',
|
| 486 |
+
'#f97316': 'Orange 500',
|
| 487 |
+
'#14b8a6': 'Teal 500'
|
| 488 |
+
};
|
| 489 |
+
|
| 490 |
+
return colorMap[hex.toLowerCase()] || 'Custom Color';
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
+
// Update gradient preview
|
| 494 |
+
function updateGradient() {
|
| 495 |
+
const color1 = color1HexInput.value;
|
| 496 |
+
const color2 = color2HexInput.value;
|
| 497 |
+
|
| 498 |
+
gradientPreview.style.background = `linear-gradient(to right, ${color1}, ${color2})`;
|
| 499 |
+
|
| 500 |
+
// Update CSS gradient code
|
| 501 |
+
cssGradientTextarea.value = `background: linear-gradient(to right, ${color1}, ${color2});`;
|
| 502 |
+
|
| 503 |
+
// Update SVG gradient code
|
| 504 |
+
svgGradientTextarea.value = `<svg width="100%" height="100%">
|
| 505 |
+
<defs>
|
| 506 |
+
<linearGradient id="gradient" x1="0%" y1="0%" x2="100%" y2="0%">
|
| 507 |
+
<stop offset="0%" stop-color="${color1}" />
|
| 508 |
+
<stop offset="100%" stop-color="${color2}" />
|
| 509 |
+
</linearGradient>
|
| 510 |
+
</defs>
|
| 511 |
+
<rect width="100%" height="100%" fill="url(#gradient)" />
|
| 512 |
+
</svg>`;
|
| 513 |
+
|
| 514 |
+
// Update UI preview elements
|
| 515 |
+
document.querySelectorAll('.preview-card').forEach(card => {
|
| 516 |
+
card.style.background = `linear-gradient(to right, ${color1}, ${color2})`;
|
| 517 |
+
});
|
| 518 |
+
|
| 519 |
+
document.querySelectorAll('.preview-card h5, .preview-card p').forEach(text => {
|
| 520 |
+
// Choose text color with better contrast
|
| 521 |
+
const contrast1 = chroma.contrast(color1, '#ffffff');
|
| 522 |
+
const contrast2 = chroma.contrast(color2, '#ffffff');
|
| 523 |
+
text.style.color = contrast1 > contrast2 ? '#ffffff' : '#000000';
|
| 524 |
+
});
|
| 525 |
+
|
| 526 |
+
// Update buttons in preview
|
| 527 |
+
const buttons = document.querySelectorAll('#preview button');
|
| 528 |
+
if (buttons.length >= 4) {
|
| 529 |
+
buttons[0].style.backgroundColor = color1;
|
| 530 |
+
buttons[1].style.backgroundColor = color2;
|
| 531 |
+
buttons[2].style.borderColor = color1;
|
| 532 |
+
buttons[2].style.color = color1;
|
| 533 |
+
buttons[3].style.borderColor = color2;
|
| 534 |
+
buttons[3].style.color = color2;
|
| 535 |
+
}
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
// Update color steps
|
| 539 |
+
function updateColorSteps() {
|
| 540 |
+
const steps = parseInt(stepsInput.value);
|
| 541 |
+
stepsValue.textContent = steps;
|
| 542 |
+
|
| 543 |
+
const color1 = color1HexInput.value;
|
| 544 |
+
const color2 = color2HexInput.value;
|
| 545 |
+
|
| 546 |
+
colorStepsContainer.innerHTML = '';
|
| 547 |
+
|
| 548 |
+
// Generate color steps
|
| 549 |
+
for (let i = 0; i < steps; i++) {
|
| 550 |
+
const t = i / (steps - 1);
|
| 551 |
+
const color = chroma.mix(color1, color2, t);
|
| 552 |
+
const hex = color.hex();
|
| 553 |
+
const rgb = color.rgb();
|
| 554 |
+
const rgbStr = `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`;
|
| 555 |
+
|
| 556 |
+
const colorBlock = document.createElement('div');
|
| 557 |
+
colorBlock.className = 'color-block h-16 rounded-lg flex flex-col items-center justify-center text-white text-xs font-medium';
|
| 558 |
+
colorBlock.style.backgroundColor = hex;
|
| 559 |
+
colorBlock.innerHTML = `
|
| 560 |
+
<span class="font-mono">${hex}</span>
|
| 561 |
+
<button class="copy-btn mt-1 px-2 py-1 bg-black bg-opacity-20 rounded-full text-xs" data-color="${hex}">
|
| 562 |
+
<i class="far fa-copy mr-1"></i> Copy
|
| 563 |
+
</button>
|
| 564 |
+
`;
|
| 565 |
+
|
| 566 |
+
// Add click event to show color info
|
| 567 |
+
colorBlock.addEventListener('click', () => {
|
| 568 |
+
showPickedColorInfo(hex);
|
| 569 |
+
});
|
| 570 |
+
|
| 571 |
+
// Add click event to copy button
|
| 572 |
+
const copyBtn = colorBlock.querySelector('button');
|
| 573 |
+
copyBtn.addEventListener('click', (e) => {
|
| 574 |
+
e.stopPropagation();
|
| 575 |
+
copyToClipboardFromAttribute(copyBtn, 'data-color');
|
| 576 |
+
|
| 577 |
+
// Show feedback
|
| 578 |
+
const originalText = copyBtn.innerHTML;
|
| 579 |
+
copyBtn.innerHTML = '<i class="fas fa-check mr-1"></i> Copied!';
|
| 580 |
+
setTimeout(() => {
|
| 581 |
+
copyBtn.innerHTML = originalText;
|
| 582 |
+
}, 1500);
|
| 583 |
+
});
|
| 584 |
+
|
| 585 |
+
colorStepsContainer.appendChild(colorBlock);
|
| 586 |
+
}
|
| 587 |
+
}
|
| 588 |
+
|
| 589 |
+
// Show picked color info
|
| 590 |
+
function showPickedColorInfo(hex) {
|
| 591 |
+
const color = chroma(hex);
|
| 592 |
+
|
| 593 |
+
pickedColorSwatch.style.backgroundColor = hex;
|
| 594 |
+
pickedColorHex.textContent = hex;
|
| 595 |
+
|
| 596 |
+
const rgb = color.rgb();
|
| 597 |
+
pickedColorRgb.value = `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`;
|
| 598 |
+
|
| 599 |
+
const hsl = color.hsl();
|
| 600 |
+
pickedColorHsl.value = `hsl(${Math.round(hsl[0])}, ${Math.round(hsl[1] * 100)}%, ${Math.round(hsl[2] * 100)}%)`;
|
| 601 |
+
|
| 602 |
+
pickedColorName.value = getColorName(hex);
|
| 603 |
+
|
| 604 |
+
pickedColorInfo.classList.remove('hidden');
|
| 605 |
+
|
| 606 |
+
// Position the handle on the gradient
|
| 607 |
+
const color1 = color1HexInput.value;
|
| 608 |
+
const color2 = color2HexInput.value;
|
| 609 |
+
|
| 610 |
+
if (hex.toLowerCase() === color1.toLowerCase()) {
|
| 611 |
+
colorPickerHandle.style.left = '0%';
|
| 612 |
+
} else if (hex.toLowerCase() === color2.toLowerCase()) {
|
| 613 |
+
colorPickerHandle.style.left = '100%';
|
| 614 |
+
} else {
|
| 615 |
+
// Find position in gradient
|
| 616 |
+
const steps = parseInt(stepsInput.value);
|
| 617 |
+
let closestPos = 50;
|
| 618 |
+
|
| 619 |
+
for (let i = 0; i < steps; i++) {
|
| 620 |
+
const t = i / (steps - 1);
|
| 621 |
+
const stepColor = chroma.mix(color1, color2, t);
|
| 622 |
+
if (stepColor.hex().toLowerCase() === hex.toLowerCase()) {
|
| 623 |
+
closestPos = t * 100;
|
| 624 |
+
break;
|
| 625 |
+
}
|
| 626 |
+
}
|
| 627 |
+
|
| 628 |
+
colorPickerHandle.style.left = `${closestPos}%`;
|
| 629 |
+
}
|
| 630 |
+
}
|
| 631 |
+
|
| 632 |
+
// Update color harmonies
|
| 633 |
+
function updateColorHarmonies() {
|
| 634 |
+
const color = chroma(color1HexInput.value);
|
| 635 |
+
|
| 636 |
+
// Complementary colors
|
| 637 |
+
complementaryColorsContainer.innerHTML = '';
|
| 638 |
+
const complementary = color.set('hsl.h', (color.get('hsl.h') + 180) % 360);
|
| 639 |
+
addColorToHarmony(complementaryColorsContainer, color.hex());
|
| 640 |
+
addColorToHarmony(complementaryColorsContainer, complementary.hex());
|
| 641 |
+
|
| 642 |
+
// Analogous colors
|
| 643 |
+
analogousColorsContainer.innerHTML = '';
|
| 644 |
+
const analogous1 = color.set('hsl.h', (color.get('hsl.h') + 30) % 360);
|
| 645 |
+
const analogous2 = color.set('hsl.h', (color.get('hsl.h') - 30 + 360) % 360);
|
| 646 |
+
addColorToHarmony(analogousColorsContainer, analogous2.hex());
|
| 647 |
+
addColorToHarmony(analogousColorsContainer, color.hex());
|
| 648 |
+
addColorToHarmony(analogousColorsContainer, analogous1.hex());
|
| 649 |
+
|
| 650 |
+
// Triadic colors
|
| 651 |
+
triadicColorsContainer.innerHTML = '';
|
| 652 |
+
const triadic1 = color.set('hsl.h', (color.get('hsl.h') + 120) % 360);
|
| 653 |
+
const triadic2 = color.set('hsl.h', (color.get('hsl.h') + 240) % 360);
|
| 654 |
+
addColorToHarmony(triadicColorsContainer, color.hex());
|
| 655 |
+
addColorToHarmony(triadicColorsContainer, triadic1.hex());
|
| 656 |
+
addColorToHarmony(triadicColorsContainer, triadic2.hex());
|
| 657 |
+
|
| 658 |
+
// Tetradic colors
|
| 659 |
+
tetradicColorsContainer.innerHTML = '';
|
| 660 |
+
const tetradic1 = color.set('hsl.h', (color.get('hsl.h') + 90) % 360);
|
| 661 |
+
const tetradic2 = color.set('hsl.h', (color.get('hsl.h') + 180) % 360);
|
| 662 |
+
const tetradic3 = color.set('hsl.h', (color.get('hsl.h') + 270) % 360);
|
| 663 |
+
addColorToHarmony(tetradicColorsContainer, color.hex());
|
| 664 |
+
addColorToHarmony(tetradicColorsContainer, tetradic1.hex());
|
| 665 |
+
addColorToHarmony(tetradicColorsContainer, tetradic2.hex());
|
| 666 |
+
addColorToHarmony(tetradicColorsContainer, tetradic3.hex());
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
+
// Add color to harmony container
|
| 670 |
+
function addColorToHarmony(container, hex) {
|
| 671 |
+
const colorBlock = document.createElement('div');
|
| 672 |
+
colorBlock.className = 'color-block h-16 rounded-lg flex flex-col items-center justify-center text-white text-xs font-medium';
|
| 673 |
+
colorBlock.style.backgroundColor = hex;
|
| 674 |
+
colorBlock.innerHTML = `
|
| 675 |
+
<span class="font-mono">${hex}</span>
|
| 676 |
+
<button class="copy-btn mt-1 px-2 py-1 bg-black bg-opacity-20 rounded-full text-xs" data-color="${hex}">
|
| 677 |
+
<i class="far fa-copy mr-1"></i> Copy
|
| 678 |
+
</button>
|
| 679 |
+
`;
|
| 680 |
+
|
| 681 |
+
// Add click event to show color info
|
| 682 |
+
colorBlock.addEventListener('click', () => {
|
| 683 |
+
showPickedColorInfo(hex);
|
| 684 |
+
});
|
| 685 |
+
|
| 686 |
+
// Add click event to copy button
|
| 687 |
+
const copyBtn = colorBlock.querySelector('button');
|
| 688 |
+
copyBtn.addEventListener('click', (e) => {
|
| 689 |
+
e.stopPropagation();
|
| 690 |
+
copyToClipboardFromAttribute(copyBtn, 'data-color');
|
| 691 |
+
|
| 692 |
+
// Show feedback
|
| 693 |
+
const originalText = copyBtn.innerHTML;
|
| 694 |
+
copyBtn.innerHTML = '<i class="fas fa-check mr-1"></i> Copied!';
|
| 695 |
+
setTimeout(() => {
|
| 696 |
+
copyBtn.innerHTML = originalText;
|
| 697 |
+
}, 1500);
|
| 698 |
+
});
|
| 699 |
+
|
| 700 |
+
container.appendChild(colorBlock);
|
| 701 |
+
}
|
| 702 |
+
|
| 703 |
+
// Update contrast ratio
|
| 704 |
+
function updateContrastRatio() {
|
| 705 |
+
const color = color1HexInput.value;
|
| 706 |
+
const bgColor = contrastBgInput.value;
|
| 707 |
+
const ratio = chroma.contrast(color, bgColor);
|
| 708 |
+
|
| 709 |
+
contrastRatioAA.textContent = ratio.toFixed(1) + ':1';
|
| 710 |
+
contrastRatioAAA.textContent = ratio.toFixed(1) + ':1';
|
| 711 |
+
|
| 712 |
+
// Update classes based on WCAG guidelines
|
| 713 |
+
contrastRatioAA.classList.remove('aa-pass', 'aa-fail');
|
| 714 |
+
contrastRatioAAA.classList.remove('aaa-pass', 'aaa-fail');
|
| 715 |
+
|
| 716 |
+
if (ratio >= 4.5) {
|
| 717 |
+
contrastRatioAA.classList.add('aa-pass');
|
| 718 |
+
} else {
|
| 719 |
+
contrastRatioAA.classList.add('aa-fail');
|
| 720 |
+
}
|
| 721 |
+
|
| 722 |
+
if (ratio >= 7) {
|
| 723 |
+
contrastRatioAAA.classList.add('aaa-pass');
|
| 724 |
+
} else {
|
| 725 |
+
contrastRatioAAA.classList.add('aaa-fail');
|
| 726 |
+
}
|
| 727 |
+
|
| 728 |
+
// Update preview
|
| 729 |
+
contrastPreview.style.backgroundColor = bgColor;
|
| 730 |
+
const previewText = contrastPreview.querySelectorAll('p');
|
| 731 |
+
previewText.forEach(text => {
|
| 732 |
+
text.style.color = color;
|
| 733 |
+
});
|
| 734 |
+
}
|
| 735 |
+
|
| 736 |
+
// Copy to clipboard
|
| 737 |
+
function copyToClipboard(elementId) {
|
| 738 |
+
const element = document.getElementById(elementId);
|
| 739 |
+
element.select();
|
| 740 |
+
document.execCommand('copy');
|
| 741 |
+
|
| 742 |
+
// Show feedback
|
| 743 |
+
const originalText = element.value;
|
| 744 |
+
if (elementId === 'css-gradient' || elementId === 'svg-gradient') {
|
| 745 |
+
const button = element.nextElementSibling;
|
| 746 |
+
const originalButtonText = button.innerHTML;
|
| 747 |
+
button.innerHTML = '<i class="fas fa-check mr-1"></i> Copied!';
|
| 748 |
+
setTimeout(() => {
|
| 749 |
+
button.innerHTML = originalButtonText;
|
| 750 |
+
}, 1500);
|
| 751 |
+
}
|
| 752 |
+
}
|
| 753 |
+
|
| 754 |
+
function copyToClipboardFromAttribute(element, attribute) {
|
| 755 |
+
const text = element.getAttribute(attribute);
|
| 756 |
+
navigator.clipboard.writeText(text);
|
| 757 |
+
}
|
| 758 |
+
|
| 759 |
+
// Download PNG
|
| 760 |
+
function downloadPng() {
|
| 761 |
+
alert('PNG download functionality would be implemented in a real application using a canvas library like html2canvas.');
|
| 762 |
+
// In a real implementation, you would use html2canvas or similar to capture the gradient
|
| 763 |
+
// and then create a download link for the PNG image.
|
| 764 |
+
}
|
| 765 |
+
|
| 766 |
+
// Event listeners
|
| 767 |
+
color1Input.addEventListener('input', () => {
|
| 768 |
+
color1HexInput.value = color1Input.value;
|
| 769 |
+
updateColorInfo(color1Input, color1HexInput, color1RgbInput, color1HslInput, color1NameInput);
|
| 770 |
+
updateGradient();
|
| 771 |
+
updateColorSteps();
|
| 772 |
+
updateColorHarmonies();
|
| 773 |
+
updateContrastRatio();
|
| 774 |
+
});
|
| 775 |
+
|
| 776 |
+
color1HexInput.addEventListener('change', () => {
|
| 777 |
+
if (chroma.valid(color1HexInput.value)) {
|
| 778 |
+
color1Input.value = chroma(color1HexInput.value).hex();
|
| 779 |
+
updateColorInfo(color1Input, color1HexInput, color1RgbInput, color1HslInput, color1NameInput);
|
| 780 |
+
updateGradient();
|
| 781 |
+
updateColorSteps();
|
| 782 |
+
updateColorHarmonies();
|
| 783 |
+
updateContrastRatio();
|
| 784 |
+
} else {
|
| 785 |
+
alert('Invalid HEX color code');
|
| 786 |
+
color1HexInput.value = color1Input.value;
|
| 787 |
+
}
|
| 788 |
+
});
|
| 789 |
+
|
| 790 |
+
color2Input.addEventListener('input', () => {
|
| 791 |
+
color2HexInput.value = color2Input.value;
|
| 792 |
+
updateColorInfo(color2Input, color2HexInput, color2RgbInput, color2HslInput, color2NameInput);
|
| 793 |
+
updateGradient();
|
| 794 |
+
updateColorSteps();
|
| 795 |
+
updateContrastRatio();
|
| 796 |
+
});
|
| 797 |
+
|
| 798 |
+
color2HexInput.addEventListener('change', () => {
|
| 799 |
+
if (chroma.valid(color2HexInput.value)) {
|
| 800 |
+
color2Input.value = chroma(color2HexInput.value).hex();
|
| 801 |
+
updateColorInfo(color2Input, color2HexInput, color2RgbInput, color2HslInput, color2NameInput);
|
| 802 |
+
updateGradient();
|
| 803 |
+
updateColorSteps();
|
| 804 |
+
updateContrastRatio();
|
| 805 |
+
} else {
|
| 806 |
+
alert('Invalid HEX color code');
|
| 807 |
+
color2HexInput.value = color2Input.value;
|
| 808 |
+
}
|
| 809 |
+
});
|
| 810 |
+
|
| 811 |
+
stepsInput.addEventListener('input', () => {
|
| 812 |
+
updateColorSteps();
|
| 813 |
+
});
|
| 814 |
+
|
| 815 |
+
// Gradient picker handle interaction
|
| 816 |
+
let isDragging = false;
|
| 817 |
+
|
| 818 |
+
colorPickerHandle.addEventListener('mousedown', () => {
|
| 819 |
+
isDragging = true;
|
| 820 |
+
});
|
| 821 |
+
|
| 822 |
+
document.addEventListener('mousemove', (e) => {
|
| 823 |
+
if (isDragging) {
|
| 824 |
+
const gradientRect = gradientPreview.getBoundingClientRect();
|
| 825 |
+
let x = e.clientX - gradientRect.left;
|
| 826 |
+
x = Math.max(0, Math.min(x, gradientRect.width));
|
| 827 |
+
|
| 828 |
+
const percentage = (x / gradientRect.width) * 100;
|
| 829 |
+
colorPickerHandle.style.left = `${percentage}%`;
|
| 830 |
+
|
| 831 |
+
// Calculate color at this position
|
| 832 |
+
const color1 = color1HexInput.value;
|
| 833 |
+
const color2 = color2HexInput.value;
|
| 834 |
+
const color = chroma.mix(color1, color2, percentage / 100);
|
| 835 |
+
|
| 836 |
+
// Update picked color info
|
| 837 |
+
pickedColorSwatch.style.backgroundColor = color.hex();
|
| 838 |
+
pickedColorHex.textContent = color.hex();
|
| 839 |
+
|
| 840 |
+
const rgb = color.rgb();
|
| 841 |
+
pickedColorRgb.value = `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`;
|
| 842 |
+
|
| 843 |
+
const hsl = color.hsl();
|
| 844 |
+
pickedColorHsl.value = `hsl(${Math.round(hsl[0])}, ${Math.round(hsl[1] * 100)}%, ${Math.round(hsl[2] * 100)}%)`;
|
| 845 |
+
|
| 846 |
+
pickedColorName.value = getColorName(color.hex());
|
| 847 |
+
|
| 848 |
+
pickedColorInfo.classList.remove('hidden');
|
| 849 |
+
}
|
| 850 |
+
});
|
| 851 |
+
|
| 852 |
+
document.addEventListener('mouseup', () => {
|
| 853 |
+
isDragging = false;
|
| 854 |
+
});
|
| 855 |
+
|
| 856 |
+
gradientPreview.addEventListener('click', (e) => {
|
| 857 |
+
const gradientRect = gradientPreview.getBoundingClientRect();
|
| 858 |
+
let x = e.clientX - gradientRect.left;
|
| 859 |
+
x = Math.max(0, Math.min(x, gradientRect.width));
|
| 860 |
+
|
| 861 |
+
const percentage = (x / gradientRect.width) * 100;
|
| 862 |
+
colorPickerHandle.style.left = `${percentage}%`;
|
| 863 |
+
|
| 864 |
+
// Calculate color at this position
|
| 865 |
+
const color1 = color1HexInput.value;
|
| 866 |
+
const color2 = color2HexInput.value;
|
| 867 |
+
const color = chroma.mix(color1, color2, percentage / 100);
|
| 868 |
+
|
| 869 |
+
// Update picked color info
|
| 870 |
+
pickedColorSwatch.style.backgroundColor = color.hex();
|
| 871 |
+
pickedColorHex.textContent = color.hex();
|
| 872 |
+
|
| 873 |
+
const rgb = color.rgb();
|
| 874 |
+
pickedColorRgb.value = `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`;
|
| 875 |
+
|
| 876 |
+
const hsl = color.hsl();
|
| 877 |
+
pickedColorHsl.value = `hsl(${Math.round(hsl[0])}, ${Math.round(hsl[1] * 100)}%, ${Math.round(hsl[2] * 100)}%)`;
|
| 878 |
+
|
| 879 |
+
pickedColorName.value = getColorName(color.hex());
|
| 880 |
+
|
| 881 |
+
pickedColorInfo.classList.remove('hidden');
|
| 882 |
+
});
|
| 883 |
+
|
| 884 |
+
copyPickedColorBtn.addEventListener('click', () => {
|
| 885 |
+
navigator.clipboard.writeText(pickedColorHex.textContent);
|
| 886 |
+
|
| 887 |
+
// Show feedback
|
| 888 |
+
const originalText = copyPickedColorBtn.innerHTML;
|
| 889 |
+
copyPickedColorBtn.innerHTML = '<i class="fas fa-check mr-1"></i> Copied!';
|
| 890 |
+
setTimeout(() => {
|
| 891 |
+
copyPickedColorBtn.innerHTML = originalText;
|
| 892 |
+
}, 1500);
|
| 893 |
+
});
|
| 894 |
+
|
| 895 |
+
contrastBgInput.addEventListener('input', () => {
|
| 896 |
+
updateContrastRatio();
|
| 897 |
+
});
|
| 898 |
+
|
| 899 |
+
downloadPngBtn.addEventListener('click', downloadPng);
|
| 900 |
+
|
| 901 |
+
// Initialize the app
|
| 902 |
+
init();
|
| 903 |
+
</script>
|
| 904 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Decide2Design/gradiant-picker" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 905 |
+
</html>
|
prompts.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Gradient Picker – A Precision Tool for Interactive Color Selection Gradient Picker is an intuitive and interactive web application that allows users to create, visualize, and explore custom gradients between two color values. By entering two HEX color codes, users can generate a seamless gradient and interact with it in real-time. The app provides a responsive gradient display that can be subdivided into a user-defined number of color steps – for example, from 2 to 20 – offering precise control over the level of color transition. Each intermediary color in the gradient is clearly displayed and can be clicked to reveal detailed color information. One of the core features of Gradient Picker is a live color picker tool (a draggable handle or a pipette-style selector), which enables users to manually select a point along the gradient and retrieve the exact HEX, RGB, or HSL value of that color. The interface updates immediately as users adjust input values or drag across the gradient, ensuring a fluid and responsive experience. To enhance usability for designers and developers, the application includes export functionalities. Users can copy any selected color value in various formats or export the entire gradient as a CSS linear-gradient string, an SVG asset, or even a high-resolution PNG image for offline use. Beyond the basic gradient functionality, the tool can optionally include advanced color analysis tools. These may offer automatic generation of color harmonies – such as complementary, analogous, or triadic schemes – based on the selected colors. For accessibility-conscious users, the tool can display real-time contrast ratios according to WCAG AA and AAA guidelines, making it easy to check legibility and design inclusivity. A thoughtful addition is the dark mode/light mode preview feature, which lets users test how their colors perform against different background contexts. Moreover, the selected colors can be mapped to known CSS color names or matched with descriptive names using external color name databases, helping users communicate color choices more effectively. The user interface is inspired by tools like Adobe Color (formerly Kuler), featuring clean layout design with large, clickable color blocks, a responsive slider to set step count, and drag-and-drop functionality to rearrange gradient endpoints. To make the application even more helpful, a small live preview area can demonstrate how selected colors look in UI elements like buttons, cards, or text blocks. Technically, the app could be built using modern web technologies such as React or Svelte for the frontend, TailwindCSS for styling, and color manipulation libraries like chroma.js or tinycolor2 to handle color interpolation and conversions. A lightweight Node.js backend may be included to store user presets or facilitate login-based functionality. Ideal for UI/UX designers, developers, digital artists, or anyone exploring visual aesthetics, Gradient Picker is more than a gradient generator – it’s a professional tool for discovering and refining color transitions with precision and creativity.
|