Spaces:
Running
Running
make the background dark buttins movable with a drop down menu
Browse files- components/profile-dropdown.js +70 -0
- index.html +3 -4
components/profile-dropdown.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class ProfileDropdown extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
:host {
|
| 7 |
+
position: relative;
|
| 8 |
+
display: inline-block;
|
| 9 |
+
}
|
| 10 |
+
button {
|
| 11 |
+
background: transparent;
|
| 12 |
+
border: none;
|
| 13 |
+
color: white;
|
| 14 |
+
cursor: pointer;
|
| 15 |
+
display: flex;
|
| 16 |
+
align-items: center;
|
| 17 |
+
gap: 0.5rem;
|
| 18 |
+
padding: 0.5rem;
|
| 19 |
+
border-radius: 0.5rem;
|
| 20 |
+
transition: background 0.2s;
|
| 21 |
+
}
|
| 22 |
+
button:hover {
|
| 23 |
+
background: rgba(255, 255, 255, 0.1);
|
| 24 |
+
}
|
| 25 |
+
.dropdown-content {
|
| 26 |
+
display: none;
|
| 27 |
+
position: absolute;
|
| 28 |
+
right: 0;
|
| 29 |
+
background-color: rgba(17, 24, 39, 0.95);
|
| 30 |
+
min-width: 160px;
|
| 31 |
+
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
|
| 32 |
+
border-radius: 0.5rem;
|
| 33 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 34 |
+
z-index: 1;
|
| 35 |
+
overflow: hidden;
|
| 36 |
+
}
|
| 37 |
+
.dropdown-content a {
|
| 38 |
+
color: white;
|
| 39 |
+
padding: 12px 16px;
|
| 40 |
+
text-decoration: none;
|
| 41 |
+
display: block;
|
| 42 |
+
}
|
| 43 |
+
.dropdown-content a:hover {
|
| 44 |
+
background-color: rgba(255, 255, 255, 0.1);
|
| 45 |
+
}
|
| 46 |
+
:host(:hover) .dropdown-content {
|
| 47 |
+
display: block;
|
| 48 |
+
}
|
| 49 |
+
</style>
|
| 50 |
+
<div>
|
| 51 |
+
<button>
|
| 52 |
+
<i data-feather="user"></i>
|
| 53 |
+
<i data-feather="chevron-down" class="w-4 h-4"></i>
|
| 54 |
+
</button>
|
| 55 |
+
<div class="dropdown-content">
|
| 56 |
+
<a href="/profile.html">Profile</a>
|
| 57 |
+
<a href="/settings.html">Settings</a>
|
| 58 |
+
<a href="/logout.html">Logout</a>
|
| 59 |
+
</div>
|
| 60 |
+
</div>
|
| 61 |
+
`;
|
| 62 |
+
|
| 63 |
+
setTimeout(() => {
|
| 64 |
+
if (window.feather) {
|
| 65 |
+
feather.replace({ class: 'feather', width: 20, height: 20 });
|
| 66 |
+
}
|
| 67 |
+
}, 100);
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
customElements.define('profile-dropdown', ProfileDropdown);
|
index.html
CHANGED
|
@@ -80,13 +80,12 @@
|
|
| 80 |
<script src="components/navbar.js"></script>
|
| 81 |
<script src="components/footer.js"></script>
|
| 82 |
<script src="components/ad-sidebar.js"></script>
|
| 83 |
-
|
| 84 |
-
|
| 85 |
<script>
|
| 86 |
feather.replace();
|
| 87 |
-
// Initialize Vanta.js globe
|
| 88 |
VANTA.GLOBE({
|
| 89 |
-
el: "#vanta-globe",
|
| 90 |
mouseControls: true,
|
| 91 |
touchControls: true,
|
| 92 |
gyroControls: false,
|
|
|
|
| 80 |
<script src="components/navbar.js"></script>
|
| 81 |
<script src="components/footer.js"></script>
|
| 82 |
<script src="components/ad-sidebar.js"></script>
|
| 83 |
+
<script src="components/profile-dropdown.js"></script>
|
| 84 |
+
<script src="script.js"></script>
|
| 85 |
<script>
|
| 86 |
feather.replace();
|
|
|
|
| 87 |
VANTA.GLOBE({
|
| 88 |
+
el: "#vanta-globe",
|
| 89 |
mouseControls: true,
|
| 90 |
touchControls: true,
|
| 91 |
gyroControls: false,
|