Spaces:
Running
Running
File size: 61,781 Bytes
a66212d | 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 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SpiceClassify - Automatic Spice Classification</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/* Custom styles */
:root {
--primary: #d97706;
--primary-dark: #92400e;
--secondary: #f59e0b;
--accent: #f97316;
--light: #f5f5f4;
--dark: #1c1917;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
background-color: var(--light);
color: var(--dark);
}
.camera-preview {
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
box-shadow: 0 4px 20px rgba(0,0,0,0.08);
border-radius: 16px;
position: relative;
overflow: hidden;
}
.camera-preview::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.8) 0%, transparent 70%);
z-index: 1;
}
.spice-card {
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
border-radius: 12px;
overflow: hidden;
cursor: pointer;
}
.spice-card:hover {
transform: translateY(-5px) scale(1.02);
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
.spice-card .icon-container {
transition: all 0.3s ease;
}
.spice-card:hover .icon-container {
transform: scale(1.1);
}
.tab-active {
border-bottom: 3px solid var(--primary);
color: var(--primary-dark);
font-weight: 600;
}
.flavor-badge {
transition: all 0.2s ease;
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.flavor-badge:hover {
transform: translateY(-2px) scale(1.05);
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.slide-in {
animation: slideIn 0.3s forwards cubic-bezier(0.175, 0.885, 0.32, 1.1);
}
@keyframes slideIn {
from { transform: translateX(100%); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
.fade-in {
animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
/* Header styles */
header {
background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
position: relative;
z-index: 10;
}
header::after {
content: '';
position: absolute;
bottom: -10px;
left: 0;
right: 0;
height: 10px;
background: linear-gradient(to bottom, rgba(0,0,0,0.05), transparent);
}
/* Button styles */
button {
transition: all 0.2s ease;
}
button:active {
transform: scale(0.96);
}
.nav-btn {
transition: all 0.2s ease;
position: relative;
}
.nav-btn::after {
content: '';
position: absolute;
bottom: -2px;
left: 50%;
transform: translateX(-50%);
width: 0;
height: 3px;
background: var(--primary);
transition: all 0.2s ease;
}
.nav-btn.text-amber-600::after {
width: 20px;
}
/* Modal styles */
#feedbackModal > div {
animation: modalFadeIn 0.3s ease-out;
box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}
@keyframes modalFadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.feedback-btn {
transition: all 0.2s ease;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.feedback-btn:hover {
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
/* Input styles */
input {
transition: all 0.2s ease;
border: 1px solid #e5e7eb;
}
input:focus {
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.2);
}
/* Scrollbar styles */
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 10px;
}
::-webkit-scrollbar-thumb {
background: var(--secondary);
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--primary);
}
/* Pulse animation for camera buttons */
@keyframes pulse {
0% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.4); }
70% { box-shadow: 0 0 0 10px rgba(217, 119, 6, 0); }
100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); }
}
#openCamera, #uploadImage {
animation: pulse 2s infinite;
z-index: 2;
}
/* Loading animation */
.loading-spinner {
display: inline-block;
width: 20px;
height: 20px;
border: 3px solid rgba(255,255,255,0.3);
border-radius: 50%;
border-top-color: white;
animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Ripple effect */
.ripple {
position: relative;
overflow: hidden;
}
.ripple:after {
content: "";
display: block;
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
pointer-events: none;
background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
background-repeat: no-repeat;
background-position: 50%;
transform: scale(10,10);
opacity: 0;
transition: transform .5s, opacity 1s;
}
.ripple:active:after {
transform: scale(0,0);
opacity: .3;
transition: 0s;
}
/* Shimmer effect for loading */
.shimmer {
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
background-size: 200% 100%;
animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
0% { background-position: 200% 0; }
100% { background-position: -200% 0; }
}
/* Toast notification */
.toast {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
background: rgba(0,0,0,0.8);
color: white;
padding: 12px 24px;
border-radius: 8px;
z-index: 100;
animation: toastIn 0.3s ease-out, toastOut 0.3s ease-out 2.7s forwards;
}
@keyframes toastIn {
from { opacity: 0; transform: translateX(-50%) translateY(20px); }
to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
from { opacity: 1; transform: translateX(-50%) translateY(0); }
to { opacity: 0; transform: translateX(-50%) translateY(20px); }
}
/* Tooltip */
.tooltip {
position: relative;
}
.tooltip:hover .tooltip-text {
visibility: visible;
opacity: 1;
}
.tooltip-text {
visibility: hidden;
opacity: 0;
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(-50%);
background: #333;
color: white;
padding: 4px 8px;
border-radius: 4px;
font-size: 12px;
white-space: nowrap;
transition: all 0.2s ease;
margin-bottom: 5px;
}
.tooltip-text::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #333 transparent transparent transparent;
}
</style>
</head>
<body class="bg-gray-50 font-sans">
<!-- App Container -->
<div class="max-w-md mx-auto bg-white min-h-screen shadow-lg overflow-hidden relative">
<!-- Header -->
<header class="bg-gradient-to-r from-amber-600 to-amber-800 p-4 text-white flex justify-between items-center">
<div class="flex items-center">
<i class="fas fa-pepper-hot text-2xl mr-2"></i>
<h1 class="text-xl font-bold">SpiceClassify</h1>
</div>
<div class="flex space-x-3">
<button id="searchBtn" class="text-white ripple tooltip">
<i class="fas fa-search"></i>
<span class="tooltip-text">Search spices</span>
</button>
<button id="historyBtn" class="text-white ripple tooltip">
<i class="fas fa-history"></i>
<span class="tooltip-text">History</span>
</button>
<button id="favoritesBtn" class="text-white ripple tooltip">
<i class="fas fa-heart"></i>
<span class="tooltip-text">Favorites</span>
</button>
</div>
</header>
<!-- Main Content -->
<main class="p-4 pb-20">
<!-- Search Modal -->
<div id="searchModal" class="hidden absolute inset-0 bg-white z-50 p-4 slide-in">
<div class="flex items-center mb-4">
<button id="closeSearch" class="mr-2 text-gray-600 ripple">
<i class="fas fa-arrow-left"></i>
</button>
<div class="relative flex-grow">
<input type="text" placeholder="Search spices..."
class="w-full p-2 pl-10 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-amber-500">
<i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
</div>
</div>
<div class="mb-4">
<h3 class="font-semibold text-gray-700 mb-2">Search by:</h3>
<div class="flex flex-wrap gap-2">
<span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Name</span>
<span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Flavor</span>
<span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Cuisine</span>
<span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Category</span>
</div>
</div>
<div>
<h3 class="font-semibold text-gray-700 mb-2">Recent Searches</h3>
<div class="space-y-2">
<div class="p-2 border-b border-gray-100 flex justify-between">
<span>Cumin</span>
<i class="fas fa-times text-gray-400"></i>
</div>
<div class="p-2 border-b border-gray-100 flex justify-between">
<span>Hot spices</span>
<i class="fas fa-times text-gray-400"></i>
</div>
</div>
</div>
</div>
<!-- Camera Section -->
<section id="cameraSection" class="mb-8">
<div class="camera-preview rounded-xl h-64 flex flex-col items-center justify-center mb-4 relative overflow-hidden">
<div id="imagePreview" class="hidden w-full h-full bg-cover bg-center"></div>
<i class="fas fa-camera text-4xl text-gray-500 mb-2"></i>
<p class="text-gray-600">Capture or upload spice image</p>
<div class="absolute bottom-4 flex space-x-4">
<button id="openCamera" class="bg-white p-3 rounded-full shadow-lg text-amber-600 ripple tooltip">
<i class="fas fa-camera"></i>
<span class="tooltip-text">Take photo</span>
</button>
<button id="uploadImage" class="bg-white p-3 rounded-full shadow-lg text-amber-600 ripple tooltip">
<i class="fas fa-images"></i>
<span class="tooltip-text">Upload image</span>
</button>
</div>
</div>
<div class="text-center text-sm text-gray-500">
<p>For best results, take a clear photo in good lighting</p>
</div>
</section>
<!-- Results Section -->
<section id="resultsSection" class="hidden fade-in">
<div class="bg-amber-50 rounded-xl p-4 mb-4 shadow-sm">
<div class="flex justify-between items-center mb-2">
<h2 class="font-bold text-lg text-amber-900" id="spiceName">Cumin</h2>
<span class="bg-amber-100 text-amber-800 px-2 py-1 rounded-full text-xs shadow-sm" id="matchPercentage">88% match</span>
</div>
<p class="text-sm text-gray-700 mb-2" id="scientificName"><i>Cuminum cyminum</i></p>
<div class="flex flex-wrap gap-2 mb-3" id="flavorBadges">
<span class="flavor-badge bg-red-100 text-red-800 px-2 py-1 rounded-full text-xs">Earthy</span>
<span class="flavor-badge bg-yellow-100 text-yellow-800 px-2 py-1 rounded-full text-xs">Warm</span>
<span class="flavor-badge bg-orange-100 text-orange-800 px-2 py-1 rounded-full text-xs">Nutty</span>
</div>
<button id="saveFavorite" class="text-amber-600 text-sm flex items-center ripple">
<i class="far fa-heart mr-1"></i> Add to favorites
</button>
</div>
<!-- Spice Info Tabs -->
<div class="mb-4">
<div class="flex border-b border-gray-200">
<button class="tab-btn py-2 px-4 font-medium tab-active" data-tab="overview">Overview</button>
<button class="tab-btn py-2 px-4 font-medium text-gray-500" data-tab="uses">Uses</button>
<button class="tab-btn py-2 px-4 font-medium text-gray-500" data-tab="health">Health</button>
</div>
</div>
<!-- Tab Content -->
<div id="overview" class="tab-content">
<p class="text-gray-700 mb-4" id="overviewText">Cumin is a flowering plant in the family Apiaceae, native to the Irano-Turanian Region. Its seeds are used in the cuisines of many cultures in both whole and ground form.</p>
<div class="bg-gray-50 p-3 rounded-lg mb-4 shadow-sm">
<h4 class="font-semibold text-gray-800 mb-1">Origin</h4>
<p class="text-gray-700" id="originText">Middle East, India, Mediterranean</p>
</div>
<div class="bg-gray-50 p-3 rounded-lg shadow-sm">
<h4 class="font-semibold text-gray-800 mb-1">Similar Spices</h4>
<div class="flex flex-wrap gap-2 mt-2" id="similarSpices">
<span class="bg-gray-200 px-3 py-1 rounded-full text-sm">Caraway</span>
<span class="bg-gray-200 px-3 py-1 rounded-full text-sm">Coriander</span>
<span class="bg-gray-200 px-3 py-1 rounded-full text-sm">Fennel</span>
</div>
</div>
</div>
<div id="uses" class="tab-content hidden">
<div class="bg-gray-50 p-3 rounded-lg mb-4 shadow-sm">
<h4 class="font-semibold text-gray-800 mb-2">Culinary Uses</h4>
<ul class="list-disc pl-5 text-gray-700 space-y-1" id="culinaryUses">
<li>Essential in Indian curries and spice blends</li>
<li>Used in Mexican and Tex-Mex dishes</li>
<li>Common in Middle Eastern and North African cuisine</li>
<li>Flavor base for soups and stews</li>
</ul>
</div>
<div class="bg-gray-50 p-3 rounded-lg shadow-sm">
<h4 class="font-semibold text-gray-800 mb-2">Pairings</h4>
<div class="flex flex-wrap gap-2" id="pairings">
<span class="bg-gray-200 px-3 py-1 rounded-full text-sm">Lentils</span>
<span class="bg-gray-200 px-3 py-1 rounded-full text-sm">Chickpeas</span>
<span class="bg-gray-200 px-3 py-1 rounded-full text-sm">Lamb</span>
<span class="bg-gray-200 px-3 py-1 rounded-full text-sm">Rice</span>
</div>
</div>
</div>
<div id="health" class="tab-content hidden">
<div class="bg-gray-50 p-3 rounded-lg mb-4 shadow-sm">
<h4 class="font-semibold text-gray-800 mb-2">Health Benefits</h4>
<ul class="list-disc pl-5 text-gray-700 space-y-1" id="healthBenefits">
<li>Rich in iron and antioxidants</li>
<li>May aid digestion and improve gut health</li>
<li>Contains anti-inflammatory properties</li>
<li>May help regulate blood sugar</li>
</ul>
</div>
<div class="bg-gray-50 p-3 rounded-lg shadow-sm">
<h4 class="font-semibold text-gray-800 mb-2">Nutritional Info (per 1 tsp)</h4>
<div class="grid grid-cols-2 gap-2 text-sm" id="nutritionInfo">
<div class="bg-gray-100 p-2 rounded">Calories: 8</div>
<div class="bg-gray-100 p-2 rounded">Fiber: 0.6g</div>
<div class="bg-gray-100 p-2 rounded">Iron: 1.4mg</div>
<div class="bg-gray-100 p-2 rounded">Calcium: 20mg</div>
</div>
</div>
</div>
</section>
<!-- Alternative Predictions -->
<section id="altPredictions" class="hidden mt-6">
<h3 class="font-semibold text-gray-700 mb-3">Other possibilities:</h3>
<div class="space-y-3" id="altPredictionsList">
<div class="flex items-center p-3 bg-gray-50 rounded-lg shadow-sm hover:bg-amber-50 transition-colors">
<div class="w-10 h-10 bg-amber-200 rounded-full flex items-center justify-center mr-3">
<i class="fas fa-pepper-hot text-amber-700"></i>
</div>
<div class="flex-grow">
<h4 class="font-medium">Caraway</h4>
<p class="text-xs text-gray-500">65% match</p>
</div>
<button class="text-amber-600 ripple">View</button>
</div>
<div class="flex items-center p-3 bg-gray-50 rounded-lg shadow-sm hover:bg-amber-50 transition-colors">
<div class="w-10 h-10 bg-amber-200 rounded-full flex items-center justify-center mr-3">
<i class="fas fa-pepper-hot text-amber-700"></i>
</div>
<div class="flex-grow">
<h4 class="font-medium">Fennel</h4>
<p class="text-xs text-gray-500">52% match</p>
</div>
<button class="text-amber-600 ripple">View</button>
</div>
</div>
</section>
<!-- Browse Section -->
<section id="browseSection" class="hidden">
<div class="mb-4">
<div class="relative">
<input type="text" placeholder="Search spices..."
class="w-full p-2 pl-10 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-amber-500">
<i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
</div>
</div>
<div class="mb-4">
<h3 class="font-semibold text-gray-700 mb-2">Categories</h3>
<div class="flex flex-wrap gap-2" id="categoriesList">
<span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Seeds</span>
<span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Roots</span>
<span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Herbs</span>
<span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Peppers</span>
<span class="bg-amber-100 text-amber-800 px-3 py-1 rounded-full text-sm">Blends</span>
</div>
</div>
<div>
<h3 class="font-semibold text-gray-700 mb-2">Popular Spices</h3>
<div class="grid grid-cols-2 gap-3" id="popularSpices">
<div class="spice-card bg-white p-3 rounded-lg shadow-sm border border-gray-100">
<div class="w-full h-20 bg-amber-100 rounded-lg mb-2 flex items-center justify-center icon-container">
<i class="fas fa-pepper-hot text-2xl text-amber-600"></i>
</div>
<h4 class="font-medium text-center">Cumin</h4>
</div>
<div class="spice-card bg-white p-3 rounded-lg shadow-sm border border-gray-100">
<div class="w-full h-20 bg-red-100 rounded-lg mb-2 flex items-center justify-center icon-container">
<i class="fas fa-pepper-hot text-2xl text-red-600"></i>
</div>
<h4 class="font-medium text-center">Paprika</h4>
</div>
<div class="spice-card bg-white p-3 rounded-lg shadow-sm border border-gray-100">
<div class="w-full h-20 bg-green-100 rounded-lg mb-2 flex items-center justify-center icon-container">
<i class="fas fa-pepper-hot text-2xl text-green-600"></i>
</div>
<h4 class="font-medium text-center">Cardamom</h4>
</div>
<div class="spice-card bg-white p-3 rounded-lg shadow-sm border border-gray-100">
<div class="w-full h-20 bg-yellow-100 rounded-lg mb-2 flex items-center justify-center icon-container">
<i class="fas fa-pepper-hot text-2xl text-yellow-600"></i>
</div>
<h4 class="font-medium text-center">Turmeric</h4>
</div>
</div>
</div>
</section>
<!-- History Section -->
<section id="historySection" class="hidden">
<div class="mb-4">
<h3 class="font-semibold text-gray-700 mb-3">Recent Classifications</h3>
<div class="space-y-3" id="historyList">
<div class="flex items-center p-3 bg-white rounded-lg shadow-sm border border-gray-100 hover:bg-amber-50 transition-colors">
<div class="w-12 h-12 bg-amber-100 rounded-lg flex items-center justify-center mr-3">
<i class="fas fa-pepper-hot text-amber-600"></i>
</div>
<div class="flex-grow">
<h4 class="font-medium">Cumin</h4>
<p class="text-xs text-gray-500">Today, 10:24 AM • 88% match</p>
</div>
<button class="text-amber-600 ripple">
<i class="fas fa-chevron-right"></i>
</button>
</div>
<div class="flex items-center p-3 bg-white rounded-lg shadow-sm border border-gray-100 hover:bg-amber-50 transition-colors">
<div class="w-12 h-12 bg-red-100 rounded-lg flex items-center justify-center mr-3">
<i class="fas fa-pepper-hot text-red-600"></i>
</div>
<div class="flex-grow">
<h4 class="font-medium">Chili Powder</h4>
<p class="text-xs text-gray-500">Yesterday, 4:12 PM • 92% match</p>
</div>
<button class="text-amber-600 ripple">
<i class="fas fa-chevron-right"></i>
</button>
</div>
</div>
</div>
</section>
<!-- Favorites Section -->
<section id="favoritesSection" class="hidden">
<div class="mb-4">
<h3 class="font-semibold text-gray-700 mb-3">Your Favorites</h3>
<div class="space-y-3" id="favoritesList">
<div class="flex items-center p-3 bg-white rounded-lg shadow-sm border border-gray-100 hover:bg-amber-50 transition-colors">
<div class="w-12 h-12 bg-green-100 rounded-lg flex items-center justify-center mr-3">
<i class="fas fa-pepper-hot text-green-600"></i>
</div>
<div class="flex-grow">
<h4 class="font-medium">Cardamom</h4>
<p class="text-xs text-gray-500">Saved on Jun 12</p>
</div>
<button class="text-red-400 ripple">
<i class="fas fa-heart"></i>
</button>
</div>
<div class="flex items-center p-3 bg-white rounded-lg shadow-sm border border-gray-100 hover:bg-amber-50 transition-colors">
<div class="w-12 h-12 bg-purple-100 rounded-lg flex items-center justify-center mr-3">
<i class="fas fa-pepper-hot text-purple-600"></i>
</div>
<div class="flex-grow">
<h4 class="font-medium">Cinnamon</h4>
<p class="text-xs text-gray-500">Saved on May 28</p>
</div>
<button class="text-red-400 ripple">
<i class="fas fa-heart"></i>
</button>
</div>
</div>
</div>
</section>
</main>
<!-- Bottom Navigation -->
<nav class="fixed bottom-0 w-full max-w-md bg-white border-t border-gray-200 flex justify-around py-2 shadow-lg">
<button class="nav-btn p-2 text-amber-600 flex flex-col items-center ripple" data-section="cameraSection">
<i class="fas fa-camera text-xl"></i>
<span class="text-xs mt-1">Scan</span>
</button>
<button class="nav-btn p-2 text-gray-500 flex flex-col items-center ripple" data-section="browseSection">
<i class="fas fa-book text-xl"></i>
<span class="text-xs mt-1">Browse</span>
</button>
<button class="nav-btn p-2 text-gray-500 flex flex-col items-center ripple" data-section="historySection">
<i class="fas fa-history text-xl"></i>
<span class="text-xs mt-1">History</span>
</button>
<button class="nav-btn p-2 text-gray-500 flex flex-col items-center ripple" data-section="favoritesSection">
<i class="fas fa-heart text-xl"></i>
<span class="text-xs mt-1">Favorites</span>
</button>
</nav>
<!-- Feedback Modal -->
<div id="feedbackModal" class="hidden absolute inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4">
<div class="bg-white rounded-xl p-6 w-full max-w-sm">
<h3 class="font-bold text-lg mb-3">Was this correct?</h3>
<p class="text-gray-700 mb-4">Help improve SpiceClassify by confirming if we identified your spice correctly.</p>
<div class="flex justify-between mb-4">
<button class="feedback-btn bg-green-100 text-green-800 px-4 py-2 rounded-lg ripple" data-feedback="correct">
<i class="fas fa-check mr-1"></i> Yes
</button>
<button class="feedback-btn bg-red-100 text-red-800 px-4 py-2 rounded-lg ripple" data-feedback="incorrect">
<i class="fas fa-times mr-1"></i> No
</button>
</div>
<div id="incorrectFeedback" class="hidden">
<p class="text-gray-700 mb-2">What was it actually?</p>
<input type="text" placeholder="Enter spice name" class="w-full p-2 border border-gray-300 rounded-lg mb-2">
<button id="submitFeedback" class="w-full bg-amber-600 text-white py-2 rounded-lg ripple">Submit</button>
</div>
<button id="closeFeedback" class="w-full mt-3 text-gray-500 ripple">Close</button>
</div>
</div>
<!-- Loading Overlay -->
<div id="loadingOverlay" class="hidden absolute inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center">
<div class="bg-white p-6 rounded-xl flex flex-col items-center">
<div class="loading-spinner mb-4"></div>
<p class="text-gray-700">Analyzing your spice...</p>
</div>
</div>
</div>
<script>
// DOM Elements
const cameraSection = document.getElementById('cameraSection');
const resultsSection = document.getElementById('resultsSection');
const browseSection = document.getElementById('browseSection');
const historySection = document.getElementById('historySection');
const favoritesSection = document.getElementById('favoritesSection');
const searchModal = document.getElementById('searchModal');
const feedbackModal = document.getElementById('feedbackModal');
const loadingOverlay = document.getElementById('loadingOverlay');
const imagePreview = document.getElementById('imagePreview');
const altPredictions = document.getElementById('altPredictions');
const navBtns = document.querySelectorAll('.nav-btn');
const tabBtns = document.querySelectorAll('.tab-btn');
const tabContents = document.querySelectorAll('.tab-content');
const searchBtn = document.getElementById('searchBtn');
const closeSearch = document.getElementById('closeSearch');
const openCamera = document.getElementById('openCamera');
const uploadImage = document.getElementById('uploadImage');
const saveFavorite = document.getElementById('saveFavorite');
const feedbackBtns = document.querySelectorAll('.feedback-btn');
const closeFeedback = document.getElementById('closeFeedback');
const submitFeedback = document.getElementById('submitFeedback');
const incorrectFeedback = document.getElementById('incorrectFeedback');
// Spice database
const spiceDatabase = {
'cumin': {
name: 'Cumin',
scientificName: 'Cuminum cyminum',
matchPercentage: '88%',
flavors: ['Earthy', 'Warm', 'Nutty'],
origin: 'Middle East, India, Mediterranean',
similarSpices: ['Caraway', 'Coriander', 'Fennel'],
overview: 'Cumin is a flowering plant in the family Apiaceae, native to the Irano-Turanian Region. Its seeds are used in the cuisines of many cultures in both whole and ground form.',
culinaryUses: [
'Essential in Indian curries and spice blends',
'Used in Mexican and Tex-Mex dishes',
'Common in Middle Eastern and North African cuisine',
'Flavor base for soups and stews'
],
pairings: ['Lentils', 'Chickpeas', 'Lamb', 'Rice'],
healthBenefits: [
'Rich in iron and antioxidants',
'May aid digestion and improve gut health',
'Contains anti-inflammatory properties',
'May help regulate blood sugar'
],
nutritionInfo: [
'Calories: 8',
'Fiber: 0.6g',
'Iron: 1.4mg',
'Calcium: 20mg'
],
color: 'amber'
},
'paprika': {
name: 'Paprika',
scientificName: 'Capsicum annuum',
matchPercentage: '92%',
flavors: ['Sweet', 'Smoky', 'Mild'],
origin: 'Central America, Spain, Hungary',
similarSpices: ['Cayenne', 'Chili Powder', 'Smoked Paprika'],
overview: 'Paprika is a spice made from dried and ground red peppers. It is traditionally made from Capsicum annuum varieties in the Longum group, which also includes chili peppers.',
culinaryUses: [
'Common in Hungarian cuisine (goulash)',
'Used as garnish for deviled eggs',
'Key ingredient in Spanish chorizo',
'Adds color to stews and soups'
],
pairings: ['Potatoes', 'Chicken', 'Eggs', 'Cheese'],
healthBenefits: [
'High in vitamin A',
'Contains capsaicin (anti-inflammatory)',
'May boost metabolism',
'Rich in antioxidants'
],
nutritionInfo: [
'Calories: 20',
'Vitamin A: 71% DV',
'Vitamin E: 10% DV',
'Iron: 8% DV'
],
color: 'red'
},
'cardamom': {
name: 'Cardamom',
scientificName: 'Elettaria cardamomum',
matchPercentage: '85%',
flavors: ['Floral', 'Citrusy', 'Sweet'],
origin: 'India, Guatemala, Sri Lanka',
similarSpices: ['Cinnamon', 'Cloves', 'Nutmeg'],
overview: 'Cardamom is a spice made from the seeds of several plants in the genera Elettaria and Amomum in the family Zingiberaceae. It is native to the Indian subcontinent and Indonesia.',
culinaryUses: [
'Used in Indian sweets and chai tea',
'Common in Scandinavian baking',
'Flavors Arabic coffee',
'Used in savory dishes in Middle East'
],
pairings: ['Coffee', 'Rice', 'Pork', 'Desserts'],
healthBenefits: [
'May lower blood pressure',
'Contains antimicrobial properties',
'May improve breathing',
'May help with digestion'
],
nutritionInfo: [
'Calories: 18',
'Fiber: 2g',
'Manganese: 80% DV',
'Iron: 10% DV'
],
color: 'green'
},
'turmeric': {
name: 'Turmeric',
scientificName: 'Curcuma longa',
matchPercentage: '90%',
flavors: ['Earthy', 'Bitter', 'Peppery'],
origin: 'India, Southeast Asia',
similarSpices: ['Saffron', 'Ginger', 'Galangal'],
overview: 'Turmeric is a flowering plant of the ginger family, Zingiberaceae, the roots of which are used in cooking. The plant is a perennial, rhizomatous, herbaceous plant native to the Indian subcontinent and Southeast Asia.',
culinaryUses: [
'Key ingredient in curry powders',
'Used to color mustard',
'Common in Southeast Asian dishes',
'Used in golden milk'
],
pairings: ['Rice', 'Chicken', 'Cauliflower', 'Lentils'],
healthBenefits: [
'Contains curcumin (anti-inflammatory)',
'May improve brain function',
'May lower risk of heart disease',
'May help prevent cancer'
],
nutritionInfo: [
'Calories: 9',
'Fiber: 1g',
'Manganese: 26% DV',
'Iron: 16% DV'
],
color: 'yellow'
}
};
// Alternative predictions
const alternativePredictions = {
'cumin': [
{ name: 'Caraway', match: '65%', color: 'amber' },
{ name: 'Fennel', match: '52%', color: 'green' }
],
'paprika': [
{ name: 'Cayenne', match: '70%', color: 'red' },
{ name: 'Chili Powder', match: '60%', color: 'red' }
],
'cardamom': [
{ name: 'Cinnamon', match: '58%', color: 'amber' },
{ name: 'Cloves', match: '45%', color: 'purple' }
],
'turmeric': [
{ name: 'Saffron', match: '40%', color: 'yellow' },
{ name: 'Ginger', match: '38%', color: 'amber' }
]
};
// Current state
let currentSpice = null;
let favorites = ['cardamom', 'turmeric']; // Initial favorites
let history = [
{ spice: 'cumin', date: 'Today, 10:24 AM', match: '88%' },
{ spice: 'paprika', date: 'Yesterday, 4:12 PM', match: '92%' }
];
// Event Listeners
navBtns.forEach(btn => {
btn.addEventListener('click', () => {
// Hide all sections
cameraSection.classList.add('hidden');
resultsSection.classList.add('hidden');
browseSection.classList.add('hidden');
historySection.classList.add('hidden');
favoritesSection.classList.add('hidden');
// Show selected section
const sectionId = btn.getAttribute('data-section');
document.getElementById(sectionId).classList.remove('hidden');
// Update active nav button
navBtns.forEach(navBtn => {
navBtn.classList.remove('text-amber-600');
navBtn.classList.add('text-gray-500');
});
btn.classList.remove('text-gray-500');
btn.classList.add('text-amber-600');
// If showing history or favorites, update the lists
if (sectionId === 'historySection') {
updateHistoryList();
} else if (sectionId === 'favoritesSection') {
updateFavoritesList();
}
});
});
tabBtns.forEach(btn => {
btn.addEventListener('click', () => {
// Update active tab
tabBtns.forEach(tabBtn => {
tabBtn.classList.remove('tab-active');
tabBtn.classList.add('text-gray-500');
});
btn.classList.add('tab-active');
btn.classList.remove('text-gray-500');
// Show selected tab content
const tabId = btn.getAttribute('data-tab');
tabContents.forEach(content => {
content.classList.add('hidden');
});
document.getElementById(tabId).classList.remove('hidden');
});
});
searchBtn.addEventListener('click', () => {
searchModal.classList.remove('hidden');
});
closeSearch.addEventListener('click', () => {
searchModal.classList.add('hidden');
});
openCamera.addEventListener('click', () => {
// Simulate camera opening
showToast('Opening camera...');
// In a real app, this would open the camera
setTimeout(() => {
// Simulate image capture
captureSpice('cumin');
}, 1000);
});
uploadImage.addEventListener('click', () => {
// Simulate image picker
showToast('Opening image gallery...');
// In a real app, this would open the gallery
setTimeout(() => {
// Simulate image selection
captureSpice('paprika');
}, 1000);
});
saveFavorite.addEventListener('click', function() {
if (!currentSpice) return;
const spiceId = currentSpice.toLowerCase();
const isFavorite = favorites.includes(spiceId);
if (isFavorite) {
// Remove from favorites
favorites = favorites.filter(item => item !== spiceId);
this.innerHTML = '<i class="far fa-heart mr-1"></i> Add to favorites';
this.classList.add('text-amber-600');
this.classList.remove('text-red-500');
showToast('Removed from favorites');
} else {
// Add to favorites
favorites.push(spiceId);
this.innerHTML = '<i class="fas fa-heart mr-1"></i> Added to favorites';
this.classList.add('text-red-500');
this.classList.remove('text-amber-600');
showToast('Added to favorites');
}
// Update favorites list if on that section
if (!favoritesSection.classList.contains('hidden')) {
updateFavoritesList();
}
});
feedbackBtns.forEach(btn => {
btn.addEventListener('click', function() {
if (this.getAttribute('data-feedback') === 'incorrect') {
incorrectFeedback.classList.remove('hidden');
} else {
feedbackModal.classList.add('hidden');
showToast('Thank you for your feedback!');
}
});
});
closeFeedback.addEventListener('click', () => {
feedbackModal.classList.add('hidden');
incorrectFeedback.classList.add('hidden');
});
submitFeedback.addEventListener('click', () => {
const feedbackInput = incorrectFeedback.querySelector('input');
if (feedbackInput.value.trim() !== '') {
feedbackModal.classList.add('hidden');
incorrectFeedback.classList.add('hidden');
feedbackInput.value = '';
showToast('Thank you for helping us improve!');
}
});
// Initialize app with camera section visible
document.addEventListener('DOMContentLoaded', () => {
cameraSection.classList.remove('hidden');
navBtns[0].classList.remove('text-gray-500');
navBtns[0].classList.add('text-amber-600');
// Add click handlers for spice cards in browse section
document.querySelectorAll('.spice-card').forEach(card => {
card.addEventListener('click', function() {
const spiceName = this.querySelector('h4').textContent.toLowerCase();
showSpiceDetails(spiceName);
// Switch to results view
cameraSection.classList.add('hidden');
browseSection.classList.add('hidden');
resultsSection.classList.remove('hidden');
// Update nav button
navBtns.forEach(navBtn => {
navBtn.classList.remove('text-amber-600');
navBtn.classList.add('text-gray-500');
});
});
});
// Add click handlers for history items
document.getElementById('historyList').addEventListener('click', function(e) {
if (e.target.closest('.flex.items-center')) {
const item = e.target.closest('.flex.items-center');
const spiceName = item.querySelector('h4').textContent.toLowerCase();
showSpiceDetails(spiceName);
// Switch to results view
cameraSection.classList.add('hidden');
historySection.classList.add('hidden');
resultsSection.classList.remove('hidden');
// Update nav button
navBtns.forEach(navBtn => {
navBtn.classList.remove('text-amber-600');
navBtn.classList.add('text-gray-500');
});
}
});
// Add click handlers for alternative predictions
document.getElementById('altPredictionsList').addEventListener('click', function(e) {
if (e.target.classList.contains('ripple') || e.target.closest('.ripple')) {
const item = e.target.closest('.flex.items-center');
const spiceName = item.querySelector('h4').textContent.toLowerCase();
showSpiceDetails(spiceName);
}
});
});
// Functions
function captureSpice(spiceId) {
loadingOverlay.classList.remove('hidden');
// Simulate processing delay
setTimeout(() => {
loadingOverlay.classList.add('hidden');
// Set the image preview
const spice = spiceDatabase[spiceId];
imagePreview.style.backgroundImage = `url(https://source.unsplash.com/300x300/?${spiceId},spice)`;
imagePreview.classList.remove('hidden');
cameraSection.querySelector('i.fa-camera').classList.add('hidden');
cameraSection.querySelector('p').classList.add('hidden');
// Show results
showSpiceDetails(spiceId);
// Switch to results view
cameraSection.classList.add('hidden');
resultsSection.classList.remove('hidden');
altPredictions.classList.remove('hidden');
// Add to history if not already there
const existingHistory = history.find(item => item.spice === spiceId);
if (!existingHistory) {
const now = new Date();
const timeString = now.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
const dateString = now.toLocaleDateString([], { month: 'short', day: 'numeric' });
history.unshift({
spice: spiceId,
date: `Today, ${timeString}`,
match: spiceDatabase[spiceId].matchPercentage
});
}
// Show feedback modal after a delay
setTimeout(() => {
feedbackModal.classList.remove('hidden');
}, 1000);
}, 2000);
}
function showSpiceDetails(spiceId) {
const spice = spiceDatabase[spiceId];
if (!spice) return;
currentSpice = spiceId;
// Update main info
document.getElementById('spiceName').textContent = spice.name;
document.getElementById('scientificName').textContent = spice.scientificName;
document.getElementById('matchPercentage').textContent = `${spice.matchPercentage} match`;
// Update flavor badges
const flavorBadges = document.getElementById('flavorBadges');
flavorBadges.innerHTML = '';
spice.flavors.forEach(flavor => {
const color = flavor === 'Earthy' ? 'red' :
flavor === 'Warm' ? 'yellow' :
flavor === 'Nutty' ? 'orange' :
flavor === 'Sweet' ? 'green' :
flavor === 'Smoky' ? 'gray' :
flavor === 'Floral' ? 'purple' :
flavor === 'Citrusy' ? 'blue' :
flavor === 'Bitter' ? 'indigo' :
flavor === 'Peppery' ? 'pink' : 'amber';
const badge = document.createElement('span');
badge.className = `flavor-badge bg-${color}-100 text-${color}-800 px-2 py-1 rounded-full text-xs`;
badge.textContent = flavor;
flavorBadges.appendChild(badge);
});
// Update favorite button
const isFavorite = favorites.includes(spiceId);
saveFavorite.innerHTML = isFavorite ?
'<i class="fas fa-heart mr-1"></i> Added to favorites' :
'<i class="far fa-heart mr-1"></i> Add to favorites';
saveFavorite.className = isFavorite ?
'text-red-500 text-sm flex items-center ripple' :
'text-amber-600 text-sm flex items-center ripple';
// Update tab content
document.getElementById('overviewText').textContent = spice.overview;
document.getElementById('originText').textContent = spice.origin;
// Update similar spices
const similarSpices = document.getElementById('similarSpices');
similarSpices.innerHTML = '';
spice.similarSpices.forEach(similar => {
const span = document.createElement('span');
span.className = 'bg-gray-200 px-3 py-1 rounded-full text-sm';
span.textContent = similar;
similarSpices.appendChild(span);
});
// Update uses
const culinaryUses = document.getElementById('culinaryUses');
culinaryUses.innerHTML = '';
spice.culinaryUses.forEach(use => {
const li = document.createElement('li');
li.textContent = use;
culinaryUses.appendChild(li);
});
// Update pairings
const pairings = document.getElementById('pairings');
pairings.innerHTML = '';
spice.pairings.forEach(pairing => {
const span = document.createElement('span');
span.className = 'bg-gray-200 px-3 py-1 rounded-full text-sm';
span.textContent = pairing;
pairings.appendChild(span);
});
// Update health benefits
const healthBenefits = document.getElementById('healthBenefits');
healthBenefits.innerHTML = '';
spice.healthBenefits.forEach(benefit => {
const li = document.createElement('li');
li.textContent = benefit;
healthBenefits.appendChild(li);
});
// Update nutrition info
const nutritionInfo = document.getElementById('nutritionInfo');
nutritionInfo.innerHTML = '';
spice.nutritionInfo.forEach(info => {
const div = document.createElement('div');
div.className = 'bg-gray-100 p-2 rounded';
div.textContent = info;
nutritionInfo.appendChild(div);
});
// Update alternative predictions
const altPredictionsList = document.getElementById('altPredictionsList');
altPredictionsList.innerHTML = '';
const alts = alternativePredictions[spiceId] || [];
alts.forEach(alt => {
const div = document.createElement('div');
div.className = 'flex items-center p-3 bg-gray-50 rounded-lg shadow-sm hover:bg-amber-50 transition-colors';
div.innerHTML = `
<div class="w-10 h-10 bg-${alt.color}-100 rounded-full flex items-center justify-center mr-3">
<i class="fas fa-pepper-hot text-${alt.color}-600"></i>
</div>
<div class="flex-grow">
<h4 class="font-medium">${alt.name}</h4>
<p class="text-xs text-gray-500">${alt.match} match</p>
</div>
<button class="text-amber-600 ripple">View</button>
`;
altPredictionsList.appendChild(div);
});
}
function updateHistoryList() {
const historyList = document.getElementById('historyList');
historyList.innerHTML = '';
history.forEach(item => {
const spice = spiceDatabase[item.spice];
if (!spice) return;
const div = document.createElement('div');
div.className = 'flex items-center p-3 bg-white rounded-lg shadow-sm border border-gray-100 hover:bg-amber-50 transition-colors';
div.innerHTML = `
<div class="w-12 h-12 bg-${spice.color}-100 rounded-lg flex items-center justify-center mr-3">
<i class="fas fa-pepper-hot text-${spice.color}-600"></i>
</div>
<div class="flex-grow">
<h4 class="font-medium">${spice.name}</h4>
<p class="text-xs text-gray-500">${item.date} • ${item.match} match</p>
</div>
<button class="text-amber-600 ripple">
<i class="fas fa-chevron-right"></i>
</button>
`;
historyList.appendChild(div);
});
}
function updateFavoritesList() {
const favoritesList = document.getElementById('favoritesList');
favoritesList.innerHTML = '';
if (favorites.length === 0) {
favoritesList.innerHTML = `
<div class="text-center py-8 text-gray-500">
<i class="fas fa-heart text-4xl mb-2 text-gray-300"></i>
<p>No favorites yet</p>
</div>
`;
return;
}
favorites.forEach(spiceId => {
const spice = spiceDatabase[spiceId];
if (!spice) return;
const now = new Date();
const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
const savedDate = `${monthNames[now.getMonth()]} ${now.getDate()}`;
const div = document.createElement('div');
div.className = 'flex items-center p-3 bg-white rounded-lg shadow-sm border border-gray-100 hover:bg-amber-50 transition-colors';
div.innerHTML = `
<div class="w-12 h-12 bg-${spice.color}-100 rounded-lg flex items-center justify-center mr-3">
<i class="fas fa-pepper-hot text-${spice.color}-600"></i>
</div>
<div class="flex-grow">
<h4 class="font-medium">${spice.name}</h4>
<p class="text-xs text-gray-500">Saved on ${savedDate}</p>
</div>
<button class="text-red-400 ripple" data-spice="${spiceId}">
<i class="fas fa-heart"></i>
</button>
`;
favoritesList.appendChild(div);
// Add click handler to remove favorite
div.querySelector('button').addEventListener('click', function() {
favorites = favorites.filter(item => item !== spiceId);
updateFavoritesList();
// If we're viewing this spice, update the favorite button
if (currentSpice === spiceId) {
saveFavorite.innerHTML = '<i class="far fa-heart mr-1"></i> Add to favorites';
saveFavorite.className = 'text-amber-600 text-sm flex items-center ripple';
}
showToast('Removed from favorites');
});
});
}
function showToast(message) {
const toast = document.createElement('div');
toast.className = 'toast';
toast.textContent = message;
document.body.appendChild(toast);
setTimeout(() => {
toast.remove();
}, 3000);
}
// Add ripple effect to all ripple buttons
document.querySelectorAll('.ripple').forEach(button => {
button.addEventListener('click', function(e) {
const rect = this.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
const ripple = document.createElement('span');
ripple.className = 'ripple-effect';
ripple.style.left = `${x}px`;
ripple.style.top = `${y}px`;
this.appendChild(ripple);
setTimeout(() => {
ripple.remove();
}, 600);
});
});
</script>
<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=aminekaa/spiceclassify" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |