Skip to content

Commit

Permalink
Solara
Browse files Browse the repository at this point in the history
  • Loading branch information
ideyaa committed Sep 9, 2024
1 parent e589138 commit cd5103e
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 158 deletions.
21 changes: 2 additions & 19 deletions solara/lib/core/dashboard/brand/BrandView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {DataSource} from './BrandModel.js';
import '../component/OnboardBottomSheet.js';
import './AddFieldSheet.js';
import '../component/ConfirmationDialog.js';
import '../component/MessageBottomSheet.js';

class BrandView {
constructor(model) {
Expand Down Expand Up @@ -442,25 +443,7 @@ class BrandView {
}

showMessage(message) {
const messageContent = document.getElementById('messageContent');
const closeMessageButton = document.getElementById('closeMessage');

messageContent.innerHTML = message.replace(/\n/g, '<br>');

this.messageBottomSheet.style.display = 'block';
this.overlay.style.display = 'block';
setTimeout(() => this.messageBottomSheet.classList.add('show'), 10);

closeMessageButton.onclick = () => this.hideMessage();
this.overlay.onclick = () => this.hideMessage();
}

hideMessage() {
this.messageBottomSheet.classList.remove('show');
setTimeout(() => {
this.messageBottomSheet.style.display = 'none';
this.overlay.style.display = 'none';
}, 300);
this.messageBottomSheet.showMessage(message);
}

setOnSectionChangedHandler(handler) {
Expand Down
55 changes: 2 additions & 53 deletions solara/lib/core/dashboard/brand/brand.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,7 @@
button:hover {
background-color: #3CC2A3;
}
.add-field-btn {
background-color: var(--primary-color);
margin-top: 10px;
}
.add-field-btn:hover {
background-color: #3A7BC8;
}

.save-section-btn {
background-color: #28a745;
margin-top: 10px;
Expand Down Expand Up @@ -343,48 +337,6 @@
align-items: center;
}

.message-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: 1000px;
margin: 0 auto;
width: 100%;
}

.message-bottom-sheet.show {
transform: translateY(0);
}
.message-content {
max-height: 300px; /* Set a maximum height */
overflow-y: auto; /* Enable vertical scrolling */
margin-bottom: 20px;
}

.close-message {
width: 10%;
padding: 10px;
background-color: var(--primary-color);
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}

.close-message:hover {
background-color: #0056b3; /* Darker shade on hover */
}

.add-brand-container {
position: fixed;
top: 50%;
Expand Down Expand Up @@ -480,10 +432,7 @@ <h1><span id="brandNametitle"></span></h1>

<add-field-sheet id="addFieldSheet"></add-field-sheet>

<div class="message-bottom-sheet" id="messageBottomSheet">
<div class="message-content" id="messageContent"></div>
<button class="close-message" id="closeMessage">Close</button>
</div>
<message-bottom-sheet id="messageBottomSheet"></message-bottom-sheet>

<confirmation-dialog id="confirmationDialog"></confirmation-dialog>

Expand Down
18 changes: 2 additions & 16 deletions solara/lib/core/dashboard/brands/BrandsView.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import '../component/OnboardBottomSheet.js';
import '../component/ConfirmationDialog.js';
import '../component/MessageBottomSheet.js';

class BrandsView {
constructor() {
Expand Down Expand Up @@ -145,22 +146,7 @@ class BrandsView {
}

showMessage(message) {
const messageContent = document.getElementById('messageContent');
const closeMessageButton = document.getElementById('closeMessage');
messageContent.innerHTML = message.replace(/\n/g, '<br>');
this.messageBottomSheet.style.display = 'block';
this.overlay.style.display = 'block';
this.overlay.onclick = () => this.hideMessage();
closeMessageButton.onclick = () => this.hideMessage();
setTimeout(() => this.messageBottomSheet.classList.add('show'), 10);
}

hideMessage() {
this.messageBottomSheet.classList.remove('show');
setTimeout(() => {
this.messageBottomSheet.style.display = 'none';
this.overlay.style.display = 'none';
}, 300);
this.messageBottomSheet.showMessage(message);
}

updateErrorCount(count) {
Expand Down
72 changes: 2 additions & 70 deletions solara/lib/core/dashboard/brands/brands.html
Original file line number Diff line number Diff line change
Expand Up @@ -227,72 +227,7 @@
cursor: pointer;
color: var(--primary-color);
}
.tooltip {
position: relative;
display: inline-block;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 200px;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px;
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -100px;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
.message-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: 1000px;
margin: 0 auto;
width: 100%;
}

.message-bottom-sheet.show {
transform: translateY(0);
}

.message-content {
max-height: 300px; /* Set a maximum height */
overflow-y: auto; /* Enable vertical scrolling */
margin-bottom: 20px;
}

.close-message {
width: 10%;
padding: 10px;
background-color: var(--primary-color);
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}

.close-message:hover {
background-color: #0056b3; /* Darker shade on hover */
}
.aliases-bottom-sheet {
display: none;
position: fixed;
Expand Down Expand Up @@ -478,7 +413,7 @@ <h1>Solara Dashboard</h1>
</button>

<div class="container">
<div class="current-brand" id="currentBrandSection" style=" display: none;">
<div class="current-brand" id="currentBrandSection" style=" display: none;">
<h2>Current Brand</h2>
<div id="currentBrandItem"></div>
</div>
Expand Down Expand Up @@ -514,10 +449,7 @@ <h2>All Brands</h2>

<onboard-bottom-sheet id="onboardBottomSheet"></onboard-bottom-sheet>

<div class="message-bottom-sheet" id="messageBottomSheet">
<div class="message-content" id="messageContent"></div>
<button class="close-message" id="closeMessage">Close</button>
</div>
<message-bottom-sheet id="messageBottomSheet"></message-bottom-sheet>

<div class="aliases-bottom-sheet" id="aliasesBottomSheet">
<h3>Aliases</h3>
Expand Down
80 changes: 80 additions & 0 deletions solara/lib/core/dashboard/component/MessageBottomSheet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
class MessageBottomSheet extends HTMLElement {
constructor() {
super();
this.attachShadow({mode: 'open'});
this.shadowRoot.innerHTML = `
<style>
.message-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: 1000px;
margin: 0 auto;
width: 100%;
}
.message-bottom-sheet.show {
transform: translateY(0);
}
.message-content {
max-height: 300px; /* Set a maximum height */
overflow-y: auto; /* Enable vertical scrolling */
margin-bottom: 20px;
}
.close-message {
width: 10%;
margin: 20px;
padding: 10px;
background-color: var(--primary-color);
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.close-message:hover {
background-color: #0056b3; /* Darker shade on hover */
}
</style>
<div class="message-bottom-sheet" id="messageBottomSheet">
<div class="message-content" id="messageContent"></div>
<button class="close-message" id="closeMessage">Close</button>
</div>
<div class="overlay" style="display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); z-index: 999;"></div>
`;

this.messageBottomSheet = this.shadowRoot.getElementById('messageBottomSheet');
this.messageContent = this.shadowRoot.getElementById('messageContent');
this.closeMessageButton = this.shadowRoot.getElementById('closeMessage');
this.overlay = this.shadowRoot.querySelector('.overlay');

this.closeMessageButton.onclick = () => this.hideMessage();
this.overlay.onclick = () => this.hideMessage();
}

showMessage(message) {
this.messageContent.innerHTML = message.replace(/\n/g, '<br>');
this.messageBottomSheet.style.display = 'block';
this.overlay.style.display = 'block';
setTimeout(() => this.messageBottomSheet.classList.add('show'), 10);
}

hideMessage() {
this.messageBottomSheet.classList.remove('show');
setTimeout(() => {
this.messageBottomSheet.style.display = 'none';
this.overlay.style.display = 'none';
}, 300);
}
}

customElements.define('message-bottom-sheet', MessageBottomSheet);

0 comments on commit cd5103e

Please sign in to comment.