File size: 4,251 Bytes
8bbd13a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
class CustomNavbar extends HTMLElement {
    connectedCallback() {
        this.attachShadow({ mode: 'open' });
        this.shadowRoot.innerHTML = `
            <style>
                nav {
                    background: white;
                    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
                    position: sticky;
                    top: 0;
                    z-index: 100;
                }
                .nav-container {
                    max-width: 1200px;
                    margin: 0 auto;
                    padding: 0 1rem;
                }
                .nav-links {
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    gap: 2rem;
                    padding: 1rem 0;
                    flex-wrap: wrap;
                }
                .nav-link {
                    display: flex;
                    align-items: center;
                    padding: 0.5rem 1rem;
                    border-radius: 0.5rem;
                    text-decoration: none;
                    color: #4b5563;
                    font-weight: 500;
                    transition: all 0.3s ease;
                }
                .nav-link:hover {
                    background: linear-gradient(135deg, #10b981 0%, #f97316 100%);
                    color: white;
                    transform: translateY(-2px);
                }
                .nav-link.active {
                    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
                    color: white;
                }
                @media (max-width: 640px) {
                    .nav-links {
                        gap: 1rem;
                    }
                    .nav-link {
                        padding: 0.4rem 0.8rem;
                        font-size: 0.9rem;
                    }
                }
            </style>
            <nav>
                <div class="nav-container">
                    <div class="nav-links">
                        <a href="#capture" class="nav-link active">
                            <i data-feather="camera" style="width: 18px; height: 18px; margin-right: 5px;"></i>
                            ถ่ายรูป
                        </a>
                        <a href="#transform" class="nav-link">
                            <i data-feather="zap" style="width: 18px; height: 18px; margin-right: 5px;"></i>
                            แปลงรูป
                        </a>
                        <a href="#compare" class="nav-link">
                            <i data-feather="layers" style="width: 18px; height: 18px; margin-right: 5px;"></i>
                            เปรียบเทียบ
                        </a>
                        <a href="#download" class="nav-link">
                            <i data-feather="download" style="width: 18px; height: 18px; margin-right: 5px;"></i>
                            ดาวน์โหลด
                        </a>
                    </div>
                </div>
            </nav>
        `;
        
        // Add smooth scroll behavior
        this.shadowRoot.querySelectorAll('.nav-link').forEach(link => {
            link.addEventListener('click', (e) => {
                e.preventDefault();
                const targetId = link.getAttribute('href').substring(1);
                const targetElement = document.querySelector(`[id*="${targetId.toLowerCase()}"]`);
                
                if (targetElement) {
                    // Remove active class from all links
                    this.shadowRoot.querySelectorAll('.nav-link').forEach(l => l.classList.remove('active'));
                    // Add active class to clicked link
                    link.classList.add('active');
                    
                    // Smooth scroll to element
                    targetElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
                }
            });
        });
        
        // Re-initialize feather icons
        if (typeof feather !== 'undefined') {
            feather.replace();
        }
    }
}
customElements.define('custom-navbar', CustomNavbar);