Skip to content

Commit

Permalink
navigation with editor check
Browse files Browse the repository at this point in the history
  • Loading branch information
st-angelo-adobe committed Dec 12, 2024
1 parent 95de01d commit 0e82d3e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
10 changes: 2 additions & 8 deletions studio/src/mas-side-nav.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LitElement, html, css } from 'lit';
import Store from './store.js';
import Store, { navigateToPage } from './store.js';

class MasSideNav extends LitElement {
static styles = css`
Expand Down Expand Up @@ -56,12 +56,6 @@ class MasSideNav extends LitElement {
}
`;

navigateTo(target) {
return function () {
Store.currentPage.set(target);
};
}

render() {
return html`<side-nav>
<div class="dropdown-container">
Expand All @@ -71,7 +65,7 @@ class MasSideNav extends LitElement {
<sp-sidenav-item
label="Home"
value="home"
@click="${this.navigateTo('splash')}"
@click="${navigateToPage('splash')}"
selected
>
<sp-icon-home slot="icon"></sp-icon-home>
Expand Down
14 changes: 5 additions & 9 deletions studio/src/mas-splash-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { LitElement, html } from 'lit';
import { contentIcon } from './img/content-icon.js';
import { promosIcon } from './img/promos-icon.js';
import { ostIcon } from './img/ost-icon.js';
import Store from './store.js';
import { navigateToPage } from './store.js';
import './mas-recently-updated.js';
import { getMerchCardEditor } from './editors/merch-card-editor.js';
import { openOfferSelectorTool } from './rte/ost.js';

class MasSplashScreen extends LitElement {
static properties = {
Expand All @@ -15,12 +15,8 @@ class MasSplashScreen extends LitElement {
return this;
}

navigateTo(value) {
return function () {
const editor = getMerchCardEditor();
if (editor && !editor.close()) return;
Store.currentPage.set(value);
};
openOst() {
openOfferSelectorTool();
}

render() {
Expand All @@ -31,7 +27,7 @@ class MasSplashScreen extends LitElement {
<div class="actions-grid">
<div
class="quick-action-card"
@click=${this.navigateTo('content')}
@click=${navigateToPage('content')}
heading="Go to Content"
>
<div slot="cover-photo">${contentIcon}</div>
Expand Down
9 changes: 9 additions & 0 deletions studio/src/store.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Fragment } from './aem/fragment.js';
import { getMerchCardEditor } from './editors/merch-card-editor.js';
import MasFilters from './entities/filters.js';
import MasSearch from './entities/search.js';
import { reactiveStore } from './reactivity/reactiveStore.js';
Expand Down Expand Up @@ -43,3 +44,11 @@ export function toggleSelection(id) {
);
else Store.selection.set([...selection, id]);
}

export function navigateToPage(value) {
return function () {
const editor = getMerchCardEditor();
if (editor && !editor.close()) return;
Store.currentPage.set(value);
};
}

0 comments on commit 0e82d3e

Please sign in to comment.