Spaces:
Running
Running
File size: 3,244 Bytes
db2676d | 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 | class CustomHeader extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 40px;
background-color: #ffffff;
border-bottom: 1px solid #e5e5e5;
flex-shrink: 0;
}
.header-left {
display: flex;
align-items: center;
gap: 12px;
}
.logo-container {
width: 60px;
height: 60px;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
border-radius: 12px;
}
.main-logo {
width: 100%;
height: 100%;
object-fit: contain;
}
.logo {
width: 50px;
height: 50px;
background-color: #22c55e;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 24px;
font-weight: bold;
}
.title {
line-height: 1.2;
}
.title h1 {
margin: 0;
font-size: 22px;
font-weight: bold;
color: #16a34a;
}
.title p {
margin: 0;
font-size: 15px;
color: #666;
margin-top: 2px;
}
.header-right {
display: flex;
align-items: center;
gap: 15px;
}
.user-name {
color: #374151;
font-size: 16px;
font-weight: 500;
}
.logout-btn {
padding: 10px 18px;
border: none;
border-radius: 10px;
background-color: #f3f4f6;
cursor: pointer;
font-size: 15px;
font-weight: 600;
display: flex;
align-items: center;
gap: 8px;
transition: all 0.2s ease;
font-family: inherit;
}
.logout-btn:hover {
background-color: #e5e7eb;
}
.logout-form {
margin: 0;
padding: 0;
}
</style>
<header class="header">
<div class="header-left">
<div class="logo-container">
<img src="images/logo.png" alt="FoodSave Logo" class="main-logo" onerror="this.onerror=null; this.src='http://static.photos/green/60x60/1';">
</div>
<div class="title">
<h1>FOODSAVE CHATBOT</h1>
<p>Get instant answers to your questions</p>
</div>
</div>
<div class="header-right">
<span class="user-name">Guest</span>
<form action="/logout" method="post" class="logout-form">
<button type="submit" class="logout-btn">↪ Logout</button>
</form>
</div>
</header>
`;
// Update user name if available from PHP session or localStorage
const userName = localStorage.getItem('userName') || 'Guest';
this.shadowRoot.querySelector('.user-name').textContent = userName;
}
}
customElements.define('custom-header', CustomHeader); |