diff --git a/solara/lib/core/dashboard/brands/BrandsView.js b/solara/lib/core/dashboard/brands/BrandsView.js index a277f2d..dcb282b 100644 --- a/solara/lib/core/dashboard/brands/BrandsView.js +++ b/solara/lib/core/dashboard/brands/BrandsView.js @@ -1,14 +1,16 @@ +import './OnboardBottomSheet.js'; + class BrandsView { constructor() { this.brandList = document.getElementById('brandList'); this.currentBrandSection = document.getElementById('currentBrandSection'); this.currentBrandItem = document.getElementById('currentBrandItem'); - this.onboardBrandSheet = document.getElementById('onboardBrandSheet'); this.overlay = document.getElementById('overlay'); this.aliasesBottomSheet = document.getElementById('aliasesBottomSheet'); this.bottomSheet = document.getElementById('bottomSheet'); this.confirmationDialog = document.getElementById('confirmationDialog'); this.messageBottomSheet = document.getElementById('messageBottomSheet'); + this.onboardSheet = document.getElementById('onboardBottomSheet'); } createBrandItem(brand, isCurrent = false) { @@ -29,11 +31,11 @@ class BrandsView { `; - + brandItem.addEventListener('click', () => { window.location.href = this.brandUrl(brand.key); }); - + const switchButton = brandItem.querySelector('.switch-button'); if (isCurrent && brand.content_changed) { switchButton.textContent = "Apply Changes"; @@ -78,16 +80,14 @@ class BrandsView { } showOnboardBrandForm() { - this.onboardBrandSheet.style.display = 'block'; + this.onboardSheet.show(); this.overlay.style.display = 'block'; this.overlay.onclick = () => this.hideOnboardBrandForm(); - setTimeout(() => this.onboardBrandSheet.classList.add('show'), 10); } async hideOnboardBrandForm() { - this.onboardBrandSheet.classList.remove('show'); + this.onboardSheet.hide(); setTimeout(() => { - this.onboardBrandSheet.style.display = 'none'; this.overlay.style.display = 'none'; }, 300); } @@ -115,10 +115,10 @@ class BrandsView { this.aliasesBottomSheet.style.display = 'block'; this.overlay.style.display = 'block'; - + this.overlay.onclick = () => this.hideAliasesBottomSheet(); closeAliasesBtn.onclick = () => this.hideAliasesBottomSheet(); - + setTimeout(() => this.aliasesBottomSheet.classList.add('show'), 10); } @@ -196,7 +196,7 @@ class BrandsView { setOnSwitch(handler) { this.onSwitch = handler; } - + brandUrl(brandKey) { return `../brand/brand.html?brand_key=${encodeURIComponent(brandKey)}&source=${this.source}`; } diff --git a/solara/lib/core/dashboard/brands/OnboardBottomSheet.js b/solara/lib/core/dashboard/brands/OnboardBottomSheet.js new file mode 100644 index 0000000..5340fe7 --- /dev/null +++ b/solara/lib/core/dashboard/brands/OnboardBottomSheet.js @@ -0,0 +1,53 @@ +class OnboardBottomSheet extends HTMLElement { + constructor() { + super(); + this.attachShadow({mode: 'open'}); + } + + async connectedCallback() { + await this.render(); + this.setupEventListeners(); + } + + async render() { + try { + const response = await fetch('onboard-bottom-sheet.html'); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + const html = await response.text(); + this.shadowRoot.innerHTML = html; + } catch (error) { + console.error('Error loading HTML:', error); + } + } + + setupEventListeners() { + const form = this.shadowRoot.getElementById('onboardBrandForm'); + form.addEventListener('submit', (e) => { + e.preventDefault(); + const brandKey = this.shadowRoot.getElementById('brandKey').value; + const brandName = this.shadowRoot.getElementById('brandName').value; + this.dispatchEvent(new CustomEvent('onboard', { + detail: {brandKey, brandName}, + bubbles: true, + composed: true + })); + this.hide(); + }); + } + + show() { + const sheet = this.shadowRoot.getElementById('onboardBrandSheet'); + sheet.style.display = 'block'; + setTimeout(() => sheet.classList.add('show'), 10); + } + + hide() { + const sheet = this.shadowRoot.getElementById('onboardBrandSheet'); + sheet.classList.remove('show'); + setTimeout(() => sheet.style.display = 'none', 300); + } +} + +customElements.define('onboard-bottom-sheet', OnboardBottomSheet); \ No newline at end of file diff --git a/solara/lib/core/dashboard/brands/brands.html b/solara/lib/core/dashboard/brands/brands.html index da00c92..81b475f 100644 --- a/solara/lib/core/dashboard/brands/brands.html +++ b/solara/lib/core/dashboard/brands/brands.html @@ -521,7 +521,7 @@

Solara Dashboard

-
+

Current Brand

@@ -562,32 +562,7 @@

Confirm Action

-
-

Onboard New Brand

-
-
- - -
-
- - -
- -
-
+
diff --git a/solara/lib/core/dashboard/brands/onboard-bottom-sheet.html b/solara/lib/core/dashboard/brands/onboard-bottom-sheet.html new file mode 100644 index 0000000..896fa78 --- /dev/null +++ b/solara/lib/core/dashboard/brands/onboard-bottom-sheet.html @@ -0,0 +1,111 @@ + +
+

Onboard New Brand

+
+
+ + +
+
+ + +
+ +
+
\ No newline at end of file