ceeeth's picture
Make everything free no credit needed for generating content
3d28543 verified
class CustomNavbar extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.isMenuOpen = false;
}
connectedCallback() {
this.render();
this.setupEventListeners();
}
render() {
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
width: 100%;
position: fixed;
top: 0;
z-index: 50;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
nav {
background: rgba(15, 23, 42, 0.8);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
transition: all 0.3s ease;
}
nav.scrolled {
background: rgba(15, 23, 42, 0.95);
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}
.container {
max-width: 1280px;
margin: 0 auto;
padding: 0 1.5rem;
display: flex;
justify-content: space-between;
align-items: center;
height: 4rem;
}
.logo {
display: flex;
align-items: center;
gap: 0.5rem;
text-decoration: none;
color: white;
font-weight: 700;
font-size: 1.25rem;
letter-spacing: -0.02em;
}
.logo-icon {
width: 2rem;
height: 2rem;
background: linear-gradient(135deg, #8b5cf6, #06b6d4);
border-radius: 0.5rem;
display: flex;
align-items: center;
justify-content: center;
}
.nav-links {
display: none;
align-items: center;
gap: 2rem;
list-style: none;
}
@media (min-width: 768px) {
.nav-links {
display: flex;
}
}
.nav-links a {
color: #94a3b8;
text-decoration: none;
font-size: 0.875rem;
font-weight: 500;
transition: color 0.2s;
position: relative;
}
.nav-links a:hover {
color: white;
}
.nav-links a::after {
content: '';
position: absolute;
bottom: -4px;
left: 0;
width: 0;
height: 2px;
background: linear-gradient(90deg, #8b5cf6, #06b6d4);
transition: width 0.3s;
}
.nav-links a:hover::after {
width: 100%;
}
.cta-button {
background: linear-gradient(135deg, #8b5cf6, #7c3aed);
color: white;
padding: 0.5rem 1.25rem;
border-radius: 9999px;
text-decoration: none;
font-size: 0.875rem;
font-weight: 600;
transition: all 0.3s;
border: none;
cursor: pointer;
}
.cta-button:hover {
transform: translateY(-2px);
box-shadow: 0 10px 25px -5px rgba(139, 92, 246, 0.4);
}
.mobile-menu-btn {
display: flex;
align-items: center;
justify-content: center;
width: 2.5rem;
height: 2.5rem;
background: rgba(255, 255, 255, 0.1);
border: none;
border-radius: 0.5rem;
color: white;
cursor: pointer;
transition: background 0.2s;
}
.mobile-menu-btn:hover {
background: rgba(255, 255, 255, 0.2);
}
@media (min-width: 768px) {
.mobile-menu-btn {
display: none;
}
}
.mobile-menu {
display: none;
position: absolute;
top: 100%;
left: 0;
right: 0;
background: rgba(15, 23, 42, 0.98);
backdrop-filter: blur(12px);
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
padding: 1.5rem;
flex-direction: column;
gap: 1rem;
}
.mobile-menu.open {
display: flex;
}
.mobile-menu a {
color: #94a3b8;
text-decoration: none;
font-size: 1rem;
font-weight: 500;
padding: 0.5rem 0;
transition: color 0.2s;
}
.mobile-menu a:hover {
color: white;
}
.mobile-cta {
margin-top: 1rem;
text-align: center;
}
.free-badge {
background: rgba(139, 92, 246, 0.2);
color: #c4b5fd;
padding: 0.25rem 0.75rem;
border-radius: 9999px;
font-size: 0.75rem;
font-weight: 600;
margin-left: 0.5rem;
border: 1px solid rgba(139, 92, 246, 0.3);
}
</style>
<nav id="navbar">
<div class="container">
<a href="index.html" class="logo">
<div class="logo-icon">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<polygon points="5 3 19 12 5 21 5 3"></polygon>
</svg>
</div>
Viewmax<span class="free-badge">FREE</span>
</a>
<ul class="nav-links">
<li><a href="index.html">Home</a></li>
<li><a href="#tools">Tools</a></li>
<li><a href="#videos">Videos</a></li>
<li><a href="#community">Community</a></li>
<li><a href="#course">Learn</a></li>
</ul>
<div style="display: flex; align-items: center; gap: 1rem;">
<a href="#tools" class="cta-button">Create Free</a>
<button class="mobile-menu-btn" aria-label="Toggle menu">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<line x1="3" y1="12" x2="21" y2="12"></line>
<line x1="3" y1="6" x2="21" y2="6"></line>
<line x1="3" y1="18" x2="21" y2="18"></line>
</svg>
</button>
</div>
</div>
<div class="mobile-menu">
<a href="index.html">Home</a>
<a href="#tools">Tools</a>
<a href="#videos">Videos</a>
<a href="#community">Community</a>
<a href="#course">Learn</a>
<div class="mobile-cta">
<a href="#tools" class="cta-button" style="display: block; width: 100%; padding: 0.75rem;">Create Free</a>
</div>
</div>
</nav>
`;
}
setupEventListeners() {
const navbar = this.shadowRoot.getElementById('navbar');
const mobileBtn = this.shadowRoot.querySelector('.mobile-menu-btn');
const mobileMenu = this.shadowRoot.querySelector('.mobile-menu');
// Scroll effect
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Mobile menu toggle
mobileBtn.addEventListener('click', () => {
this.isMenuOpen = !this.isMenuOpen;
mobileMenu.classList.toggle('open', this.isMenuOpen);
// Animate hamburger to X
const svg = mobileBtn.querySelector('svg');
if (this.isMenuOpen) {
svg.innerHTML = `
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
`;
} else {
svg.innerHTML = `
<line x1="3" y1="12" x2="21" y2="12"></line>
<line x1="3" y1="6" x2="21" y2="6"></line>
<line x1="3" y1="18" x2="21" y2="18"></line>
`;
}
});
// Close mobile menu when clicking a link
mobileMenu.querySelectorAll('a').forEach(link => {
link.addEventListener('click', () => {
this.isMenuOpen = false;
mobileMenu.classList.remove('open');
const svg = mobileBtn.querySelector('svg');
svg.innerHTML = `
<line x1="3" y1="12" x2="21" y2="12"></line>
<line x1="3" y1="6" x2="21" y2="6"></line>
<line x1="3" y1="18" x2="21" y2="18"></line>
`;
});
});
}
}
customElements.define('custom-navbar', CustomNavbar);