File size: 5,182 Bytes
df62a7a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
class NavbarCustom extends HTMLElement {
    connectedCallback() {
        this.attachShadow({ mode: 'open' });
        this.shadowRoot.innerHTML = `
            <style>
                .navbar {
                    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
                    padding: 16px 20px;
                    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
                }
                .navbar-container {
                    max-width: 480px;
                    margin: 0 auto;
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                }
                .logo {
                    color: white;
                    font-size: 24px;
                    font-weight: bold;
                    text-decoration: none;
                    display: flex;
                    align-items: center;
                }
                .logo-icon {
                    width: 32px;
                    height: 32px;
                    margin-right: 8px;
                    background: white;
                    border-radius: 50%;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                }
                .notification-btn {
                    background: rgba(255, 255, 255, 0.2);
                    border: none;
                    border-radius: 50%;
                    width: 40px;
                    height: 40px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    cursor: pointer;
                    transition: all 0.3s ease;
                }
                .notification-btn:hover {
                    background: rgba(255, 255, 255, 0.3);
                    transform: scale(1.05);
                }
                .notification-badge {
                    position: absolute;
                    top: -4px;
                    right: -4px;
                    background: #ef4444;
                    color: white;
                    border-radius: 50%;
                    width: 16px;
                    height: 16px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    font-size: 10px;
                    font-weight: bold;
                }
            </style>
            <nav class="navbar">
                <div class="navbar-container">
                    <a href="#dashboard" class="logo">
                        <div class="logo-icon">
                            <span style="color: #667eea;">💗</span>
                        </div>
                        <span>ชีพจร</span>
                    </a>
                    <button class="notification-btn" onclick="showNotifications()">
                        <i data-feather="bell" style="width: 20px; height: 20px; color: white;"></i>
                        <span class="notification-badge">3</span>
                    </button>
                </div>
            </nav>
        `;
    }
}

customElements.define('nav-custom', NavbarCustom);

function showNotifications() {
    // Create notification modal
    const modal = document.createElement('div');
    modal.className = 'modal';
    modal.innerHTML = `
        <div class="modal-content">
            <h2 class="text-xl font-bold mb-4">การแจ้งเตือน</h2>
            <div class="space-y-3">
                <div class="p-3 bg-red-50 rounded-lg border-l-4 border-red-500">
                    <div class="font-semibold text-red-800">คำเตือน PM2.5</div>
                    <div class="text-sm text-red-600">ค่า PM2.5 สูงกว่ามาตรฐาน ควรหลีกเลี่ยงการออกกำลังกายกลางแจ้ง</div>
                </div>
                <div class="p-3 bg-orange-50 rounded-lg border-l-4 border-orange-500">
                    <div class="font-semibold text-orange-800">แจ้งเตือนออฟฟิศ</div>
                    <div class="text-sm text-orange-600">นั่งนิ่งมา 60 นาทีแล้ว ควรลุกขึ้นเดิน</div>
                </div>
                <div class="p-3 bg-blue-50 rounded-lg border-l-4 border-blue-500">
                    <div class="font-semibold text-blue-800">เวลาทานยา</div>
                    <div class="text-sm text-blue-600">ถึงเวลาทานวิตามินประจำวันแล้ว</div>
                </div>
            </div>
            <button class="w-full mt-4 bg-indigo-600 text-white rounded-lg py-2 font-semibold hover:bg-indigo-700 transition" onclick="this.closest('.modal').remove()">
                ปิด
            </button>
        </div>
    `;
    document.body.appendChild(modal);
    
    // Close modal when clicking outside
    modal.addEventListener('click', function(e) {
        if (e.target === modal) {
            modal.remove();
        }
    });
}