-
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.
- Loading branch information
Showing
4 changed files
with
177 additions
and
86 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
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
130 changes: 130 additions & 0 deletions
130
solara/lib/core/dashboard/component/BrandOptionsBottomSheet.js
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,130 @@ | ||
class BrandOptionsBottomSheet extends HTMLElement { | ||
constructor() { | ||
super(); | ||
this.attachShadow({mode: 'open'}); | ||
|
||
this.shadowRoot.innerHTML = ` | ||
<head> | ||
<style> | ||
.bottom-sheet { | ||
display: none; | ||
position: fixed; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
background-color: white; | ||
border-top-left-radius: 20px; | ||
border-top-right-radius: 20px; | ||
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1); | ||
z-index: 1000; | ||
padding: 20px; | ||
transition: transform 0.3s ease-out; | ||
transform: translateY(100%); | ||
max-width: 700px; | ||
margin: 0 auto; | ||
width: 100%; | ||
} | ||
.bottom-sheet.show { | ||
transform: translateY(0); | ||
} | ||
.bottom-sheet ul { | ||
list-style-type: none; | ||
padding: 0; | ||
margin: 0; | ||
} | ||
.bottom-sheet li { | ||
padding: 15px 20px; | ||
cursor: pointer; | ||
transition: background-color 0.3s ease; | ||
display: flex; | ||
align-items: center; | ||
} | ||
.bottom-sheet li:hover { | ||
background-color: var(--background-color); | ||
} | ||
.bottom-sheet li i { | ||
margin-right: 15px; | ||
font-size: 20px; | ||
width: 24px; | ||
text-align: center; | ||
} | ||
.overlay { | ||
display: none; | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background: rgba(0, 0, 0, 0.5); | ||
z-index: 999; | ||
} | ||
</style> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css"> | ||
</head> | ||
<div class="overlay"></div> | ||
<div class="bottom-sheet" id="bottomSheet"> | ||
<ul> | ||
<li id="cloneOption" class="clone-option"><i class="fas fa-copy"></i>Clone</li> | ||
<li id="doctorOption" class="doctor-option"><i class="fas fa-stethoscope"></i>Doctor</li> | ||
<li id="offboardOption" class="offboard-option"><i class="fas fa-trash-alt"></i>Offboard</li> | ||
<li id="aliasesOption" class="aliases-option"><i class="fas fa-terminal"></i>Terminal aliases</li> | ||
<li id="settingsOption" class="settings-option"><i class="fas fa-cog"></i>Settings</li> | ||
</ul> | ||
</div> | ||
`; | ||
|
||
this.bottomSheet = this.shadowRoot.getElementById('bottomSheet'); | ||
this.overlay = this.shadowRoot.querySelector('.overlay'); | ||
|
||
this.shadowRoot.getElementById('cloneOption').onclick = this.handleCloneOption.bind(this); | ||
this.shadowRoot.getElementById('offboardOption').onclick = this.handleOffboardOption.bind(this); | ||
this.shadowRoot.getElementById('doctorOption').onclick = this.handleDoctorOption.bind(this); | ||
this.shadowRoot.getElementById('aliasesOption').onclick = this.handleAliasesOption.bind(this); | ||
this.shadowRoot.getElementById('settingsOption').onclick = this.handleSettingsOption.bind(this); | ||
|
||
this.overlay.onclick = this.hideBrandOptionsBottomSheet.bind(this); | ||
} | ||
|
||
show() { | ||
this.bottomSheet.style.display = 'block'; | ||
this.overlay.style.display = 'block'; | ||
setTimeout(() => this.bottomSheet.classList.add('show'), 10); | ||
} | ||
|
||
hideBrandOptionsBottomSheet() { | ||
this.bottomSheet.classList.remove('show'); | ||
this.overlay.style.display = 'none'; | ||
} | ||
|
||
handleCloneOption(event) { | ||
event.stopPropagation(); | ||
this.hideBrandOptionsBottomSheet(); | ||
this.dispatchEvent(new CustomEvent('clone', {detail: this.bottomSheet.dataset})); | ||
} | ||
|
||
handleOffboardOption(event) { | ||
event.stopPropagation(); | ||
this.hideBrandOptionsBottomSheet(); | ||
this.dispatchEvent(new CustomEvent('offboard', {detail: this.bottomSheet.dataset})); | ||
} | ||
|
||
handleDoctorOption(event) { | ||
event.stopPropagation(); | ||
this.hideBrandOptionsBottomSheet(); | ||
this.dispatchEvent(new CustomEvent('doctor', {detail: this.bottomSheet.dataset})); | ||
} | ||
|
||
handleAliasesOption(event) { | ||
event.stopPropagation(); | ||
this.hideBrandOptionsBottomSheet(); | ||
this.dispatchEvent(new CustomEvent('aliases', {detail: this.bottomSheet.dataset})); | ||
} | ||
|
||
handleSettingsOption(event) { | ||
event.stopPropagation(); | ||
this.hideBrandOptionsBottomSheet(); | ||
this.dispatchEvent(new CustomEvent('settings', {detail: this.bottomSheet.dataset})); | ||
} | ||
} | ||
|
||
customElements.define('brand-options-bottom-sheet', BrandOptionsBottomSheet); |