ananbhsal648aa's picture
ليش الواجهات ما يتغلين ممكن تتطوره
df6b307 verified
Raw
History Blame Contribute Delete
7.78 kB
class CustomHeader extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
header {
background-color: white;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
position: sticky;
top: 0;
z-index: 40;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 1rem;
}
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 0;
}
.logo {
display: flex;
align-items: center;
font-weight: 700;
font-size: 1.5rem;
color: #4f46e5;
text-decoration: none;
}
.logo-icon {
margin-left: 0.5rem;
color: #7c3aed;
}
.nav-links {
display: flex;
list-style: none;
}
.nav-links li {
margin-right: 2rem;
}
.nav-links a {
text-decoration: none;
color: #4b5563;
font-weight: 500;
transition: color 0.3s;
}
.nav-links a:hover {
color: #4f46e5;
}
.auth-buttons {
display: flex;
align-items: center;
}
.login-btn {
background: none;
border: none;
color: #4b5563;
font-weight: 500;
margin-left: 1rem;
cursor: pointer;
transition: color 0.3s;
text-decoration: none;
display: inline-flex;
align-items: center;
}
.login-btn:hover {
color: #4f46e5;
}
.signup-btn {
background-color: #4f46e5;
color: white;
border: none;
padding: 0.5rem 1.5rem;
border-radius: 9999px;
font-weight: 500;
cursor: pointer;
transition: background-color 0.3s;
text-decoration: none;
display: inline-flex;
align-items: center;
}
.signup-btn:hover {
background-color: #4338ca;
}
.mobile-menu-button {
display: none;
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
color: #4b5563;
}
/* Mobile menu */
.mobile-menu {
display: none;
position: absolute;
top: 100%;
left: 0;
right: 0;
background: white;
box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
z-index: 50;
padding: 1rem;
border-top: 1px solid #e5e7eb;
}
.mobile-menu.open {
display: block;
}
.mobile-nav-links {
list-style: none;
}
.mobile-nav-links li {
margin-bottom: 1rem;
}
.mobile-nav-links a {
text-decoration: none;
color: #4b5563;
font-weight: 500;
display: block;
padding: 0.5rem 0;
border-bottom: 1px solid #f3f4f6;
}
.mobile-nav-links a:hover {
color: #4f46e5;
}
.mobile-auth-buttons {
margin-top: 1rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
}
@media (max-width: 768px) {
.nav-links {
display: none;
}
.auth-buttons {
display: none;
}
.mobile-menu-button {
display: block;
}
}
</style>
<header>
<div class="container">
<nav class="navbar">
<a href="/" class="logo">
<i data-feather="bar-chart-2" class="logo-icon"></i>
<span>النظام المحاسبي</span>
</a>
<ul class="nav-links">
<li><a href="/">الرئيسية</a></li>
<li><a href="#features">المميزات</a></li>
<li><a href="#accounts">الحسابات</a></li>
<li><a href="#statistics">الإحصائيات</a></li>
<li><a href="/about.html">عن النظام</a></li>
<li><a href="/contact.html">اتصل بنا</a></li>
</ul>
<div class="auth-buttons">
<a href="/login.html" class="login-btn">تسجيل الدخول</a>
<a href="/signup.html" class="signup-btn">ابدأ مجاناً</a>
</div>
<button class="mobile-menu-button" id="mobile-menu-button">
<i data-feather="menu"></i>
</button>
</nav>
</div>
<!-- Mobile menu (hidden by default) -->
<div class="mobile-menu" id="mobile-menu">
<ul class="mobile-nav-links">
<li><a href="/">الرئيسية</a></li>
<li><a href="#features">المميزات</a></li>
<li><a href="#accounts">الحسابات</a></li>
<li><a href="#statistics">الإحصائيات</a></li>
<li><a href="/about.html">عن النظام</a></li>
<li><a href="/contact.html">اتصل بنا</a></li>
</ul>
<div class="mobile-auth-buttons">
<a href="/login.html" class="login-btn" style="justify-content: center;">تسجيل الدخول</a>
<a href="/signup.html" class="signup-btn" style="justify-content: center;">ابدأ مجاناً</a>
</div>
</div>
</header>
`;
// Initialize feather icons
const initFeatherIcons = () => {
if (typeof feather !== 'undefined') {
this.shadowRoot.querySelectorAll('[data-feather]').forEach(icon => {
const iconName = icon.getAttribute('data-feather');
icon.outerHTML = `<i data-feather="${iconName}"></i>`;
});
feather.replace();
}
};
// Check if feather is already loaded
if (typeof feather !== 'undefined') {
initFeatherIcons();
} else {
// Load feather icons script
const featherScript = document.createElement('script');
featherScript.src = 'https://unpkg.com/feather-icons';
featherScript.onload = initFeatherIcons;
this.shadowRoot.appendChild(featherScript);
}
// Mobile menu toggle
const mobileMenuButton = this.shadowRoot.getElementById('mobile-menu-button');
const mobileMenu = this.shadowRoot.getElementById('mobile-menu');
if (mobileMenuButton && mobileMenu) {
mobileMenuButton.addEventListener('click', () => {
mobileMenu.classList.toggle('open');
// Change icon
const icon = mobileMenuButton.querySelector('i');
if (mobileMenu.classList.contains('open')) {
icon.setAttribute('data-feather', 'x');
} else {
icon.setAttribute('data-feather', 'menu');
}
if (typeof feather !== 'undefined') {
feather.replace();
}
});
}
}
}
customElements.define('custom-header', CustomHeader);