Initial commit: Basic structure and product display

#19
Files changed (4) hide show
  1. index.html +22 -11
  2. script.js +19 -57
  3. style.css +8 -76
  4. tailwind.config.js +15 -0
index.html CHANGED
@@ -1,17 +1,28 @@
1
  <!DOCTYPE html>
2
- <html>
3
  <head>
4
- <title>Google Clone</title>
5
- <link rel="stylesheet" href="style.css">
 
 
6
  </head>
7
  <body>
8
- <div class="logo-container"><img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" alt="Google Logo"></div><div class="search-container">
9
- <input type="text" id="search-input" placeholder="Search Google">
10
- <div id="suggestions"></div>
11
- </div>
12
- <div id="results-container">
13
- </div>
14
-
15
- <script src="script.js"></script>
 
 
 
 
 
 
 
 
 
16
  </body>
17
  </html>
 
1
  <!DOCTYPE html>
2
+ <html lang="en">
3
  <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Amazon Dummy</title>
7
+ <link href="style.css" rel="stylesheet">
8
  </head>
9
  <body>
10
+ <header class="bg-amazon-blue">
11
+ <div class="container mx-auto py-2">
12
+ <div class="flex items-center justify-between">
13
+ <div class="text-white font-bold text-2xl">Amazon Dummy</div>
14
+ <div class="flex items-center">
15
+ <input type="text" class="px-4 py-2 rounded-l-md focus:outline-none" placeholder="Search">
16
+ <button class="bg-amazon-orange hover:bg-yellow-500 text-white font-bold py-2 px-4 rounded-r-md">Search</button>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ </header>
21
+ <main class="container mx-auto mt-4">
22
+ <section id="products" class="grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4">
23
+ <!-- Products will be dynamically added here -->
24
+ </section>
25
+ </main>
26
+ <script src="script.js"></script>
27
  </body>
28
  </html>
script.js CHANGED
@@ -1,62 +1,24 @@
1
- const searchInput = document.getElementById("search-input");
2
- const suggestionsDiv = document.getElementById("suggestions");
3
- const resultsContainer = document.getElementById("results-container");
4
 
5
- const dummySuggestions = [
6
- "what is javascript",
7
- "how to make a website",
8
- "best restaurants near me",
9
- "weather today",
10
- "current news"
11
- ];
12
 
13
- searchInput.addEventListener("input", function() {
14
- const inputValue = searchInput.value.toLowerCase();
15
- const filteredSuggestions = dummySuggestions.filter(suggestion =>
16
- suggestion.toLowerCase().startsWith(inputValue)
17
- );
18
 
19
- displaySuggestions(filteredSuggestions);
20
- });
 
 
 
 
21
 
22
- function displaySuggestions(suggestions) {
23
- suggestionsDiv.innerHTML = "";
24
- if (suggestions.length > 0 && searchInput.value) {
25
- suggestions.forEach(suggestion => {
26
- const suggestionElement = document.createElement("div");
27
- suggestionElement.textContent = suggestion;
28
- suggestionElement.addEventListener("click", function() {
29
- searchInput.value = suggestion;
30
- suggestionsDiv.style.display = "none";
31
- displayResults(suggestion);
32
- });
33
- suggestionsDiv.appendChild(suggestionElement);
34
  });
35
- suggestionsDiv.style.display = "block";
36
- } else {
37
- suggestionsDiv.style.display = "none";
38
- }
39
- }
40
-
41
- searchInput.addEventListener("keydown", function(event) {
42
- if (event.key === "Enter") {
43
- const inputValue = searchInput.value;
44
- displayResults(inputValue);
45
- suggestionsDiv.style.display = "none";
46
- }
47
- });
48
-
49
- function displayResults(query) {
50
- resultsContainer.innerHTML = "";
51
- const dummyResults = [
52
- `Result 1 for ${query}`,
53
- `Result 2 for ${query}`,
54
- `Result 3 for ${query}`
55
- ];
56
-
57
- dummyResults.forEach(result => {
58
- const resultElement = document.createElement("div");
59
- resultElement.textContent = result;
60
- resultsContainer.appendChild(resultElement);
61
- });
62
- }
 
1
+ document.addEventListener('DOMContentLoaded', () => {
2
+ const productsSection = document.getElementById('products');
 
3
 
4
+ const products = [
5
+ { id: 1, name: 'Product 1', image: 'https://via.placeholder.com/150', price: 19.99 },
6
+ { id: 2, name: 'Product 2', image: 'https://via.placeholder.com/150', price: 29.99 },
7
+ { id: 3, name: 'Product 3', image: 'https://via.placeholder.com/150', price: 39.99 },
8
+ { id: 4, name: 'Product 4', image: 'https://via.placeholder.com/150', price: 49.99 },
9
+ ];
 
10
 
11
+ products.forEach(product => {
12
+ const productDiv = document.createElement('div');
13
+ productDiv.classList.add('border', 'p-4', 'rounded-md');
 
 
14
 
15
+ productDiv.innerHTML = `
16
+ <img src="${product.image}" alt="${product.name}" class="w-full h-40 object-cover mb-2">
17
+ <h3 class="text-lg font-bold">${product.name}</h3>
18
+ <p class="text-gray-700">$${product.price}</p>
19
+ <button class="bg-amazon-orange hover:bg-yellow-500 text-white font-bold py-2 px-4 rounded mt-2">Add to Cart</button>
20
+ `;
21
 
22
+ productsSection.appendChild(productDiv);
 
 
 
 
 
 
 
 
 
 
 
23
  });
24
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
style.css CHANGED
@@ -1,79 +1,11 @@
 
 
 
1
 
2
- body {
3
- font-family: Arial, sans-serif;
4
- margin: 0;
5
- padding: 0;
6
- display: flex;
7
- flex-direction: column;
8
- align-items: center;
9
- min-height: 100vh; /* Use min-height for better centering */
10
  }
11
 
12
- .logo-container {
13
- margin-top: 100px; /* Adjust as needed */
14
- margin-bottom: 20px; /* Space between logo and search bar */
15
- text-align: center;
16
- }
17
-
18
- .logo-container img {
19
- width: auto; /* Maintain aspect ratio */
20
- height: 92px; /* Google logo height */
21
- }
22
-
23
- .search-container {
24
- /* margin-top: 100px; */ /* Removed, logo container handles top margin */
25
- position: relative;
26
- }
27
-
28
- #search-input {
29
- width: 580px; /* Increased width slightly */
30
- padding: 13px 20px; /* Adjusted padding */
31
- font-size: 16px;
32
- border: 1px solid #dfe1e5; /* Softer border color */
33
- border-radius: 24px;
34
- outline: none;
35
- box-shadow: 0 1px 6px rgb(32 33 36 / 28%); /* Add a subtle shadow */
36
- transition: box-shadow 0.3s ease-in-out; /* Smooth transition */
37
- }
38
-
39
- #search-input:focus {
40
- border-color: #adadad; /* Slightly darker border on focus */
41
- box-shadow: 0 1px 6px rgb(32 33 36 / 28%); /* Keep shadow on focus */
42
- }
43
-
44
-
45
- #suggestions {
46
- position: absolute;
47
- top: 100%;
48
- left: 0;
49
- width: calc(580px + 40px); /* Match input width + padding */
50
- background-color: #fff;
51
- border: 1px solid #dfe1e5;
52
- border-top: none;
53
- border-radius: 0 0 8px 8px;
54
- box-shadow: 0 4px 6px rgb(32 33 36 / 10%); /* Softer shadow */
55
- display: none;
56
- z-index: 1;
57
- }
58
-
59
- #suggestions div {
60
- padding: 10px 16px; /* Adjusted padding */
61
- cursor: pointer;
62
- font-size: 14px;
63
- }
64
-
65
- #suggestions div:hover {
66
- background-color: #f0f0f0;
67
- }
68
-
69
- #results-container {
70
- margin-top: 40px; /* Increased margin for results */
71
- width: 600px; /* Adjusted width */
72
- }
73
-
74
- #results-container div {
75
- margin-bottom: 15px; /* Space between results */
76
- padding: 10px 0;
77
- border-bottom: 1px solid #eee; /* Separator line */
78
- font-size: 14px;
79
- }
 
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
 
5
+ .bg-amazon-blue {
6
+ background-color: #232F3E;
 
 
 
 
 
 
7
  }
8
 
9
+ .bg-amazon-orange {
10
+ background-color: #FF9900;
11
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tailwind.config.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: ["./*.{html,js}"],
4
+ theme: {
5
+ extend: {
6
+ colors: {
7
+ amazon: {
8
+ blue: '#232F3E',
9
+ orange: '#FF9900',
10
+ }
11
+ }
12
+ },
13
+ },
14
+ plugins: [],
15
+ }