File size: 3,548 Bytes
9dfae78 | 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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | class CustomHeader extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
}
header {
background-color: white;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
position: sticky;
top: 0;
z-index: 100;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 16px;
}
nav {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px 0;
}
.logo {
font-size: 1.5rem;
font-weight: 700;
color: #3b82f6;
text-decoration: none;
display: flex;
align-items: center;
}
.logo i {
margin-right: 8px;
}
.nav-links {
display: flex;
list-style: none;
}
.nav-links li {
margin-left: 24px;
}
.nav-links a {
text-decoration: none;
color: #4b5563;
font-weight: 500;
transition: color 0.3s ease;
}
.nav-links a:hover {
color: #3b82f6;
}
.nav-buttons {
display: flex;
gap: 12px;
}
.btn-outline {
padding: 8px 16px;
border-radius: 6px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
border: 1px solid #d1d5db;
background: white;
}
.btn-outline:hover {
background-color: #f9fafb;
}
.btn-primary {
padding: 8px 16px;
border-radius: 6px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s ease;
background-color: #3b82f6;
color: white;
border: none;
}
.btn-primary:hover {
background-color: #2563eb;
}
@media (max-width: 768px) {
.nav-links {
display: none;
}
}
</style>
<header>
<div class="container">
<nav>
<a href="/" class="logo">
<i data-feather="aperture"></i>
<span>PromptCraft</span>
</a>
<ul class="nav-links">
<li><a href="/">Home</a></li>
<li><a href="#">Gallery</a></li>
<li><a href="#">Resources</a></li>
<li><a href="#">About</a></li>
</ul>
<div class="nav-buttons">
<button class="btn-outline">
<i data-feather="log-in"></i>
<span>Login</span>
</button>
<button class="btn-primary">
<i data-feather="user-plus"></i>
<span>Sign Up</span>
</button>
</div>
</nav>
</div>
</header>
`;
// Initialize Feather Icons
const script = document.createElement('script');
script.src = "https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js";
script.onload = () => {
if (this.shadowRoot) {
feather.replace();
}
};
this.shadowRoot.appendChild(script);
}
}
customElements.define('custom-header', CustomHeader); |