search.html 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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>Search - Animal.js</title>
  7. <link rel="stylesheet" href="demo.css">
  8. <style>
  9. body {
  10. padding: 20px;
  11. display: block; /* Override flex center */
  12. background-color: transparent; /* Allow iframe bg to show if needed */
  13. }
  14. .search-header {
  15. margin-bottom: 30px;
  16. }
  17. .search-title {
  18. font-size: 14px;
  19. font-weight: 600;
  20. color: #888;
  21. margin-bottom: 15px;
  22. }
  23. .search-input-container {
  24. position: relative;
  25. width: 100%;
  26. }
  27. .search-input {
  28. width: 100%;
  29. background: #1a1a1a;
  30. border: 1px solid #333;
  31. color: #fff;
  32. padding: 12px 40px;
  33. border-radius: 6px;
  34. font-size: 14px;
  35. box-sizing: border-box;
  36. outline: none;
  37. }
  38. .search-input:focus {
  39. border-color: var(--orange);
  40. }
  41. .search-icon {
  42. position: absolute;
  43. left: 15px;
  44. top: 50%;
  45. transform: translateY(-50%);
  46. width: 14px;
  47. height: 14px;
  48. border: 2px solid #666;
  49. border-radius: 50%;
  50. }
  51. .search-icon:after {
  52. content: '';
  53. position: absolute;
  54. top: 10px;
  55. left: 10px;
  56. width: 4px;
  57. height: 2px;
  58. background: #666;
  59. transform: rotate(45deg);
  60. }
  61. .grid-section {
  62. margin-bottom: 30px;
  63. }
  64. .section-title {
  65. font-size: 14px;
  66. color: #888;
  67. margin-bottom: 15px;
  68. font-weight: 500;
  69. }
  70. .card-grid {
  71. display: grid;
  72. grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  73. gap: 15px;
  74. }
  75. .card {
  76. background: #1a1a1a;
  77. border-radius: 8px;
  78. padding: 20px;
  79. display: flex;
  80. flex-direction: column;
  81. cursor: pointer;
  82. transition: background 0.2s, border-color 0.2s;
  83. position: relative;
  84. min-height: 80px;
  85. justify-content: space-between;
  86. border: 1px solid transparent;
  87. }
  88. .card:hover {
  89. background: #222;
  90. border-color: #333;
  91. }
  92. .card-placeholder-line {
  93. height: 8px;
  94. width: 40px;
  95. background: #333;
  96. border-radius: 2px;
  97. }
  98. .card-large-icon {
  99. font-size: 40px;
  100. color: #444;
  101. display: flex;
  102. justify-content: center;
  103. align-items: center;
  104. height: 60px;
  105. background: #222;
  106. border-radius: 4px;
  107. margin-bottom: 10px;
  108. font-family: monospace;
  109. font-weight: bold;
  110. transition: transform 0.1s;
  111. }
  112. .card-footer {
  113. margin-top: 10px;
  114. background: #222;
  115. padding: 5px 10px;
  116. border-radius: 4px;
  117. font-size: 10px;
  118. color: #666;
  119. text-align: center;
  120. text-transform: uppercase;
  121. letter-spacing: 1px;
  122. }
  123. .dot {
  124. width: 8px;
  125. height: 8px;
  126. background: #444;
  127. border-radius: 2px;
  128. }
  129. </style>
  130. </head>
  131. <body>
  132. <!-- Search Section -->
  133. <div class="search-header">
  134. <div class="search-title">Search</div>
  135. <div class="search-input-container">
  136. <div class="search-icon"></div>
  137. <input type="text" class="search-input" placeholder="Search documentation...">
  138. </div>
  139. </div>
  140. <!-- Documentation Section -->
  141. <div class="grid-section">
  142. <div class="section-title">Documentation</div>
  143. <div class="card-grid">
  144. <div class="card" style="height: 100px;">
  145. <div style="display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; opacity: 0.1;">
  146. <div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div>
  147. <div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div>
  148. <div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div>
  149. <div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div>
  150. </div>
  151. </div>
  152. </div>
  153. </div>
  154. <!-- Vanilla JS Section (Interactive) -->
  155. <div class="grid-section">
  156. <div class="section-title">Using with vanilla JS</div>
  157. <div class="card-grid">
  158. <div class="card" onclick="playRotation(this, 'js-icon', 'js-count', 'test_css_selector.html')">
  159. <div id="js-icon" class="card-large-icon">JS</div>
  160. <div id="js-count" class="card-footer">Rotations: 0</div>
  161. </div>
  162. </div>
  163. </div>
  164. <!-- React Section (Interactive) -->
  165. <div class="grid-section">
  166. <div class="section-title">Using with React</div>
  167. <div class="card-grid">
  168. <div class="card" onclick="playRotation(this, 'react-icon', 'react-count', 'test_on_update.html')">
  169. <div id="react-icon" class="card-large-icon" style="font-size: 30px;">⚛</div>
  170. <div id="react-count" class="card-footer">Rotations: 0</div>
  171. </div>
  172. </div>
  173. </div>
  174. <!-- Timer Section (Interactive) -->
  175. <div class="grid-section">
  176. <div class="section-title">Timer</div>
  177. <div class="card-grid">
  178. <div class="card" style="flex-direction: row; align-items: center; justify-content: space-between; padding: 15px; cursor: default;">
  179. <div style="font-size: 10px; color: #666;">current time</div>
  180. <div style="font-size: 10px; color: #666;">callback fired</div>
  181. </div>
  182. <div class="card" id="timer-card" onclick="toggleTimer()" style="flex-direction: row; align-items: center; justify-content: space-between; background: #1a1a1a;">
  183. <div id="timer-time" style="font-size: 24px; color: #666; font-family: monospace;">0</div>
  184. <div id="timer-cb" style="font-size: 24px; color: #666; font-family: monospace;">0</div>
  185. </div>
  186. </div>
  187. </div>
  188. <script src="../animal.js"></script>
  189. <script>
  190. // --- Rotation Logic ---
  191. let jsRotations = 0;
  192. let reactRotations = 0;
  193. function playRotation(card, iconId, countId, targetUrl) {
  194. // 1. Update Parent Content
  195. if (window.parent && window.parent.loadContent) {
  196. window.parent.loadContent(targetUrl);
  197. }
  198. // 2. Animate Icon
  199. const icon = document.getElementById(iconId);
  200. const count = document.getElementById(countId);
  201. // Increment logic
  202. let current = (iconId === 'js-icon') ? ++jsRotations : ++reactRotations;
  203. // Use animal.js to rotate
  204. // Rotate +360 from current visual state
  205. // Simplified: just set rotation to current * 360
  206. animal.animate(icon, {
  207. rotate: current * 360, // 1turn, 2turn...
  208. duration: 600,
  209. easing: 'ease-out'
  210. });
  211. count.textContent = 'Rotations: ' + current;
  212. }
  213. // --- Timer Logic ---
  214. let timerRunning = false;
  215. let timerId = null;
  216. let startTime = 0;
  217. let callbacks = 0;
  218. function toggleTimer() {
  219. if (timerRunning) {
  220. // Stop
  221. cancelAnimationFrame(timerId);
  222. timerRunning = false;
  223. document.getElementById('timer-card').style.borderColor = 'transparent';
  224. } else {
  225. // Start
  226. timerRunning = true;
  227. startTime = Date.now();
  228. callbacks = 0;
  229. document.getElementById('timer-card').style.borderColor = 'var(--orange)';
  230. tick();
  231. }
  232. }
  233. function tick() {
  234. if (!timerRunning) return;
  235. const now = Date.now();
  236. const elapsed = now - startTime;
  237. document.getElementById('timer-time').textContent = elapsed;
  238. document.getElementById('timer-cb').textContent = ++callbacks;
  239. timerId = requestAnimationFrame(tick);
  240. }
  241. // Start timer by default to look alive? Or wait for click?
  242. // Screenshot implies it's running (numbers > 0).
  243. toggleTimer();
  244. </script>
  245. </body>
  246. </html>