CSNET commited on
Commit
6c05aa9
·
verified ·
1 Parent(s): 50bd240

ขอปุ่มเปลี่ยนสี background แบบให้เลือกได้หน่อย

Browse files
Files changed (1) hide show
  1. index.html +144 -26
index.html CHANGED
@@ -327,9 +327,43 @@
327
  -webkit-backdrop-filter: blur(10px);
328
  border: 1px solid rgba(255, 255, 255, 0.1);
329
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
 
331
- .tooltip.visible {
332
- opacity: 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  }
334
 
335
  @media (max-width: 768px) {
@@ -363,6 +397,48 @@
363
  .children {
364
  gap: 20px;
365
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  }
367
 
368
  @media (max-width: 480px) {
@@ -403,10 +479,19 @@
403
  <button id="zoomIn">+ Zoom In</button>
404
  <button id="expandAll">📂 Expand All</button>
405
  <button id="collapseAll">📁 Collapse All</button>
 
406
  </div>
407
  </header>
 
 
 
 
 
 
 
 
408
  <div class="tree-container" id="treeContainer">
409
- <div class="tree" id="tree"></div>
410
  </div>
411
  </div>
412
  <div class="tooltip" id="tooltip"></div>
@@ -618,35 +703,69 @@
618
  treeContainer.appendChild(createNodeElement(tree));
619
  }
620
  }
621
-
622
  // Initialize
623
  document.addEventListener('DOMContentLoaded', () => {
 
 
 
 
 
 
624
  renderTree();
625
- // Zoom Controls
626
- document.getElementById('zoomIn').addEventListener('click', () => {
627
- setZoom(zoomLevel + ZOOM_STEP);
628
- });
629
-
630
- document.getElementById('zoomOut').addEventListener('click', () => {
631
- setZoom(zoomLevel - ZOOM_STEP);
632
- });
633
-
634
- // Mouse wheel zoom (hold Ctrl/Cmd)
635
- document.getElementById('treeContainer').addEventListener('wheel', (e) => {
636
- if (e.ctrlKey || e.metaKey) {
637
- e.preventDefault();
638
- if (e.deltaY < 0) {
639
  setZoom(zoomLevel + ZOOM_STEP);
640
- } else {
 
 
641
  setZoom(zoomLevel - ZOOM_STEP);
642
- }
643
- }
644
- });
 
 
 
 
 
 
 
 
 
 
645
 
646
- // Expand/Collapse Controls
647
- document.getElementById('expandAll').addEventListener('click', () => expandAll(true));
648
  document.getElementById('collapseAll').addEventListener('click', () => expandAll(false));
649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
650
  // Mouse move for tooltip
651
  document.addEventListener('mousemove', (e) => {
652
  const tooltip = document.getElementById('tooltip');
@@ -666,8 +785,7 @@ document.getElementById('expandAll').addEventListener('click', () => expandAll(t
666
  }
667
  });
668
  });
669
-
670
- // Update tree on window resize
671
  window.addEventListener('resize', () => {
672
  const treeContainer = document.getElementById('treeContainer');
673
  const tree = document.getElementById('tree');
 
327
  -webkit-backdrop-filter: blur(10px);
328
  border: 1px solid rgba(255, 255, 255, 0.1);
329
  }
330
+ .color-dropdown {
331
+ position: absolute;
332
+ top: 80px;
333
+ right: 30px;
334
+ background: var(--bg-card);
335
+ backdrop-filter: var(--blur);
336
+ -webkit-backdrop-filter: var(--blur);
337
+ border: 1px solid var(--border-color);
338
+ border-radius: 10px;
339
+ box-shadow: var(--shadow);
340
+ padding: 10px;
341
+ z-index: 100;
342
+ min-width: 180px;
343
+ }
344
 
345
+ .color-option {
346
+ padding: 8px 12px;
347
+ cursor: pointer;
348
+ border-radius: 6px;
349
+ margin-bottom: 5px;
350
+ font-size: 14px;
351
+ font-weight: 600;
352
+ transition: var(--transition);
353
+ color: var(--text-primary);
354
+ }
355
+
356
+ .color-option:hover {
357
+ background: var(--bg-card-hover);
358
+ transform: translateX(5px);
359
+ }
360
+
361
+ .color-option:last-child {
362
+ margin-bottom: 0;
363
+ }
364
+
365
+ .hidden {
366
+ display: none;
367
  }
368
 
369
  @media (max-width: 768px) {
 
397
  .children {
398
  gap: 20px;
399
  }
400
+
401
+ .color-dropdown {
402
+ top: 70px;
403
+ right: 20px;
404
+ min-width: 150px;
405
+ }
406
+
407
+ .color-option {
408
+ font-size: 13px;
409
+ padding: 6px 10px;
410
+ }
411
+ }
412
+ header {
413
+ padding: 15px 20px;
414
+ }
415
+
416
+ h1 {
417
+ font-size: 22px;
418
+ }
419
+
420
+ button {
421
+ padding: 8px 15px;
422
+ font-size: 13px;
423
+ }
424
+
425
+ .node {
426
+ min-width: 150px;
427
+ padding: 12px;
428
+ }
429
+
430
+ .avatar {
431
+ width: 40px;
432
+ height: 40px;
433
+ }
434
+
435
+ .node-info h3 {
436
+ font-size: 14px;
437
+ }
438
+
439
+ .children {
440
+ gap: 20px;
441
+ }
442
  }
443
 
444
  @media (max-width: 480px) {
 
479
  <button id="zoomIn">+ Zoom In</button>
480
  <button id="expandAll">📂 Expand All</button>
481
  <button id="collapseAll">📁 Collapse All</button>
482
+ <button id="bgColorBtn">🎨 Background</button>
483
  </div>
484
  </header>
485
+ <div id="colorDropdown" class="color-dropdown hidden">
486
+ <div class="color-option" data-gradient="linear-gradient(135deg, #667eea 0%, #764ba2 100%)">🟣 Purple (Default)</div>
487
+ <div class="color-option" data-gradient="linear-gradient(135deg, #3B82F6 0%, #06B6D4 100%)">🔵 Blue</div>
488
+ <div class="color-option" data-gradient="linear-gradient(135deg, #10B981 0%, #34D399 100%)">🟢 Green</div>
489
+ <div class="color-option" data-gradient="linear-gradient(135deg, #F59E0B 0%, #F97316 100%)">🟠 Orange</div>
490
+ <div class="color-option" data-gradient="linear-gradient(135deg, #EC4899 0%, #F472B6 100%)">🌸 Pink</div>
491
+ <div class="color-option" data-gradient="linear-gradient(135deg, #6B7280 0%, #374151 100%)">🌑 Dark</div>
492
+ </div>
493
  <div class="tree-container" id="treeContainer">
494
+ <div class="tree" id="tree"></div>
495
  </div>
496
  </div>
497
  <div class="tooltip" id="tooltip"></div>
 
703
  treeContainer.appendChild(createNodeElement(tree));
704
  }
705
  }
 
706
  // Initialize
707
  document.addEventListener('DOMContentLoaded', () => {
708
+ // Load saved background color
709
+ const savedGradient = localStorage.getItem('bgGradient');
710
+ if (savedGradient) {
711
+ document.documentElement.style.setProperty('--bg-main', savedGradient);
712
+ }
713
+
714
  renderTree();
715
+ // Zoom Controls
716
+ document.getElementById('zoomIn').addEventListener('click', () => {
 
 
 
 
 
 
 
 
 
 
 
 
717
  setZoom(zoomLevel + ZOOM_STEP);
718
+ });
719
+
720
+ document.getElementById('zoomOut').addEventListener('click', () => {
721
  setZoom(zoomLevel - ZOOM_STEP);
722
+ });
723
+
724
+ // Mouse wheel zoom (hold Ctrl/Cmd)
725
+ document.getElementById('treeContainer').addEventListener('wheel', (e) => {
726
+ if (e.ctrlKey || e.metaKey) {
727
+ e.preventDefault();
728
+ if (e.deltaY < 0) {
729
+ setZoom(zoomLevel + ZOOM_STEP);
730
+ } else {
731
+ setZoom(zoomLevel - ZOOM_STEP);
732
+ }
733
+ }
734
+ });
735
 
736
+ // Expand/Collapse Controls
737
+ document.getElementById('expandAll').addEventListener('click', () => expandAll(true));
738
  document.getElementById('collapseAll').addEventListener('click', () => expandAll(false));
739
 
740
+ // Background Color Controls
741
+ const bgColorBtn = document.getElementById('bgColorBtn');
742
+ const colorDropdown = document.getElementById('colorDropdown');
743
+ const colorOptions = document.querySelectorAll('.color-option');
744
+
745
+ bgColorBtn.addEventListener('click', (e) => {
746
+ e.stopPropagation();
747
+ colorDropdown.classList.toggle('hidden');
748
+ });
749
+
750
+ colorOptions.forEach(option => {
751
+ option.addEventListener('click', () => {
752
+ const gradient = option.dataset.gradient;
753
+ document.documentElement.style.setProperty('--bg-main', gradient);
754
+ localStorage.setItem('bgGradient', gradient);
755
+ colorDropdown.classList.add('hidden');
756
+ });
757
+ });
758
+
759
+ // Close dropdown when clicking outside
760
+ document.addEventListener('click', () => {
761
+ colorDropdown.classList.add('hidden');
762
+ });
763
+
764
+ // Prevent dropdown from closing when clicking inside it
765
+ colorDropdown.addEventListener('click', (e) => {
766
+ e.stopPropagation();
767
+ });
768
+
769
  // Mouse move for tooltip
770
  document.addEventListener('mousemove', (e) => {
771
  const tooltip = document.getElementById('tooltip');
 
785
  }
786
  });
787
  });
788
+ // Update tree on window resize
 
789
  window.addEventListener('resize', () => {
790
  const treeContainer = document.getElementById('treeContainer');
791
  const tree = document.getElementById('tree');