| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Search - Animal.js</title>
- <link rel="stylesheet" href="demo.css">
- <style>
- body {
- padding: 20px;
- display: block; /* Override flex center */
- background-color: transparent; /* Allow iframe bg to show if needed */
- }
-
- .search-header {
- margin-bottom: 30px;
- }
-
- .search-title {
- font-size: 14px;
- font-weight: 600;
- color: #888;
- margin-bottom: 15px;
- }
-
- .search-input-container {
- position: relative;
- width: 100%;
- }
-
- .search-input {
- width: 100%;
- background: #1a1a1a;
- border: 1px solid #333;
- color: #fff;
- padding: 12px 40px;
- border-radius: 6px;
- font-size: 14px;
- box-sizing: border-box;
- outline: none;
- }
-
- .search-input:focus {
- border-color: var(--orange);
- }
-
- .search-icon {
- position: absolute;
- left: 15px;
- top: 50%;
- transform: translateY(-50%);
- width: 14px;
- height: 14px;
- border: 2px solid #666;
- border-radius: 50%;
- }
- .search-icon:after {
- content: '';
- position: absolute;
- top: 10px;
- left: 10px;
- width: 4px;
- height: 2px;
- background: #666;
- transform: rotate(45deg);
- }
- .grid-section {
- margin-bottom: 30px;
- }
-
- .section-title {
- font-size: 14px;
- color: #888;
- margin-bottom: 15px;
- font-weight: 500;
- }
-
- .card-grid {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
- gap: 15px;
- }
-
- .card {
- background: #1a1a1a;
- border-radius: 8px;
- padding: 20px;
- display: flex;
- flex-direction: column;
- cursor: pointer;
- transition: background 0.2s, border-color 0.2s;
- position: relative;
- min-height: 80px;
- justify-content: space-between;
- border: 1px solid transparent;
- }
-
- .card:hover {
- background: #222;
- border-color: #333;
- }
-
- .card-placeholder-line {
- height: 8px;
- width: 40px;
- background: #333;
- border-radius: 2px;
- }
-
- .card-large-icon {
- font-size: 40px;
- color: #444;
- display: flex;
- justify-content: center;
- align-items: center;
- height: 60px;
- background: #222;
- border-radius: 4px;
- margin-bottom: 10px;
- font-family: monospace;
- font-weight: bold;
- transition: transform 0.1s;
- }
-
- .card-footer {
- margin-top: 10px;
- background: #222;
- padding: 5px 10px;
- border-radius: 4px;
- font-size: 10px;
- color: #666;
- text-align: center;
- text-transform: uppercase;
- letter-spacing: 1px;
- }
-
- .dot {
- width: 8px;
- height: 8px;
- background: #444;
- border-radius: 2px;
- }
- </style>
- </head>
- <body>
- <!-- Search Section -->
- <div class="search-header">
- <div class="search-title">Search</div>
- <div class="search-input-container">
- <div class="search-icon"></div>
- <input type="text" class="search-input" placeholder="Search documentation...">
- </div>
- </div>
- <!-- Documentation Section -->
- <div class="grid-section">
- <div class="section-title">Documentation</div>
- <div class="card-grid">
- <div class="card" style="height: 100px;">
- <div style="display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; opacity: 0.1;">
- <div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div>
- <div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div>
- <div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div>
- <div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div><div class="dot"></div>
- </div>
- </div>
- </div>
- </div>
- <!-- Vanilla JS Section (Interactive) -->
- <div class="grid-section">
- <div class="section-title">Using with vanilla JS</div>
- <div class="card-grid">
- <div class="card" onclick="playRotation(this, 'js-icon', 'js-count', 'test_css_selector.html')">
- <div id="js-icon" class="card-large-icon">JS</div>
- <div id="js-count" class="card-footer">Rotations: 0</div>
- </div>
- </div>
- </div>
- <!-- React Section (Interactive) -->
- <div class="grid-section">
- <div class="section-title">Using with React</div>
- <div class="card-grid">
- <div class="card" onclick="playRotation(this, 'react-icon', 'react-count', 'test_on_update.html')">
- <div id="react-icon" class="card-large-icon" style="font-size: 30px;">⚛</div>
- <div id="react-count" class="card-footer">Rotations: 0</div>
- </div>
- </div>
- </div>
-
- <!-- Timer Section (Interactive) -->
- <div class="grid-section">
- <div class="section-title">Timer</div>
- <div class="card-grid">
- <div class="card" style="flex-direction: row; align-items: center; justify-content: space-between; padding: 15px; cursor: default;">
- <div style="font-size: 10px; color: #666;">current time</div>
- <div style="font-size: 10px; color: #666;">callback fired</div>
- </div>
- <div class="card" id="timer-card" onclick="toggleTimer()" style="flex-direction: row; align-items: center; justify-content: space-between; background: #1a1a1a;">
- <div id="timer-time" style="font-size: 24px; color: #666; font-family: monospace;">0</div>
- <div id="timer-cb" style="font-size: 24px; color: #666; font-family: monospace;">0</div>
- </div>
- </div>
- </div>
-
- <script src="../animal.js"></script>
- <script>
- // --- Rotation Logic ---
- let jsRotations = 0;
- let reactRotations = 0;
- function playRotation(card, iconId, countId, targetUrl) {
- // 1. Update Parent Content
- if (window.parent && window.parent.loadContent) {
- window.parent.loadContent(targetUrl);
- }
-
- // 2. Animate Icon
- const icon = document.getElementById(iconId);
- const count = document.getElementById(countId);
-
- // Increment logic
- let current = (iconId === 'js-icon') ? ++jsRotations : ++reactRotations;
-
- // Use animal.js to rotate
- // Rotate +360 from current visual state
- // Simplified: just set rotation to current * 360
- animal.animate(icon, {
- rotate: current * 360, // 1turn, 2turn...
- duration: 600,
- easing: 'ease-out'
- });
-
- count.textContent = 'Rotations: ' + current;
- }
-
- // --- Timer Logic ---
- let timerRunning = false;
- let timerId = null;
- let startTime = 0;
- let callbacks = 0;
-
- function toggleTimer() {
- if (timerRunning) {
- // Stop
- cancelAnimationFrame(timerId);
- timerRunning = false;
- document.getElementById('timer-card').style.borderColor = 'transparent';
- } else {
- // Start
- timerRunning = true;
- startTime = Date.now();
- callbacks = 0;
- document.getElementById('timer-card').style.borderColor = 'var(--orange)';
- tick();
- }
- }
-
- function tick() {
- if (!timerRunning) return;
-
- const now = Date.now();
- const elapsed = now - startTime;
-
- document.getElementById('timer-time').textContent = elapsed;
- document.getElementById('timer-cb').textContent = ++callbacks;
-
- timerId = requestAnimationFrame(tick);
- }
-
- // Start timer by default to look alive? Or wait for click?
- // Screenshot implies it's running (numbers > 0).
- toggleTimer();
-
- </script>
- </body>
- </html>
|