-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: configure demos on 3d playground
- Loading branch information
1 parent
0fe5165
commit f8a7635
Showing
5 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
export class Navbar { | ||
private __DOM__: HTMLElement | ||
private __DOM_TOGGLE__: HTMLElement | ||
|
||
constructor() { | ||
// Create the navbar | ||
this.__DOM__ = document.createElement('nav') | ||
this.__DOM__.id = 'demo-navbar' | ||
this.__DOM__.innerHTML = ` | ||
<a href="/playground-3d/">Home</a> | ||
<a href="/playground-3d/demos/rainbowls/">Rainbowls</a> | ||
<style> | ||
#demo-navbar { | ||
position: fixed; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
padding: 1rem; | ||
width: 180px; | ||
height: 90vh; | ||
background-color: rgba(0, 0, 0, 0.6); | ||
color: white; | ||
border-radius: 0 10px 10px 0; | ||
transform: translateX(-100%); | ||
transition: transform 0.3s ease; | ||
} | ||
#demo-navbar a { | ||
width: 100%; | ||
color: white; | ||
padding: 0.5rem 1rem; | ||
text-decoration: none; | ||
background-color: transparent; | ||
transition: background-color 0.3s ease; | ||
} | ||
#demo-navbar a:hover { | ||
background-color: rgba(255, 255, 255, 0.1); | ||
} | ||
/* Gets applied if supported only */ | ||
@supports ( | ||
(-webkit-backdrop-filter: blur(8px)) or (backdrop-filter: blur(8px)) | ||
) { | ||
#demo-navbar { | ||
background-color: rgba(0, 0, 0, 0.2); | ||
backdrop-filter: blur(10px); | ||
-webkit-backdrop-filter: blur(10px); | ||
} | ||
} | ||
</style> | ||
` | ||
|
||
// Create the toggle button | ||
this.__DOM_TOGGLE__ = document.createElement('div') | ||
this.__DOM_TOGGLE__.id = 'demo-navbar-toggle' | ||
this.__DOM_TOGGLE__.innerHTML = ` | ||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="-5 -7 24 24"><path fill="currentColor" d="M1 0h5a1 1 0 1 1 0 2H1a1 1 0 1 1 0-2m7 8h5a1 1 0 0 1 0 2H8a1 1 0 1 1 0-2M1 4h12a1 1 0 0 1 0 2H1a1 1 0 1 1 0-2"/></svg> | ||
<style> | ||
#demo-navbar-toggle { | ||
position: absolute; | ||
top: 1rem; | ||
left: 1rem; | ||
width: 2rem; | ||
height: 2rem; | ||
background-color: rgba(0, 0, 0, 0.6); | ||
border: none; | ||
border-radius: 50%; | ||
cursor: pointer; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
z-index: 1000; | ||
} | ||
#demo-navbar-toggle svg { | ||
width: 1.5rem; | ||
height: 1.5rem; | ||
fill: white; | ||
} | ||
#demo-navbar-toggle:focus { | ||
outline: none; | ||
} | ||
</style> | ||
` | ||
let toggle = false | ||
this.__DOM_TOGGLE__.addEventListener('click', () => { | ||
this.__DOM__.style.transform = toggle ? 'translateX(-100%)' : 'translateX(0)' | ||
toggle = !toggle | ||
}) | ||
|
||
document.body.appendChild(this.__DOM__) | ||
document.body.appendChild(this.__DOM_TOGGLE__) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
apps/playground-3d/pages/rainbowls/main.ts → apps/playground-3d/demos/rainbowls/main.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters