dewaldpetzer's picture
How do i use this script in wordpress so that i can do design changes
2f7542e verified
class CustomHeader extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
width: 100%;
background-color: white;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.header-container {
max-width: 1200px;
margin: 0 auto;
padding: 1rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.logo {
font-weight: 700;
font-size: 1.5rem;
color: var(--primary);
text-decoration: none;
}
.nav-links {
display: flex;
gap: 1.5rem;
}
.nav-links a {
color: var(--dark);
text-decoration: none;
font-weight: 500;
transition: color 0.2s;
}
.nav-links a:hover {
color: var(--primary);
}
@media (max-width: 768px) {
.header-container {
flex-direction: column;
gap: 1rem;
}
}
</style>
<header class="header-container">
<a href="/" class="logo">WordPress Wizard</a>
<nav class="nav-links">
<a href="#">Home</a>
<a href="#">Design</a>
<a href="#">Components</a>
<a href="#">Settings</a>
</nav>
</header>
`;
}
}
customElements.define('custom-header', CustomHeader);