Skip to content

Commit

Permalink
Move PR to new repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferri0 committed Sep 17, 2024
1 parent 1170869 commit ca86a23
Show file tree
Hide file tree
Showing 265 changed files with 4,639 additions and 393 deletions.
53 changes: 53 additions & 0 deletions blocks/commerce-account-sidebar/commerce-account-sidebar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.commerce-account-sidebar-wrapper .commerce-account-sidebar .commerce-account-sidebar-item {
display: flex;
align-items: center;
padding: var(--spacing-medium);
margin-bottom: var(--spacing-small);
border: var(--shape-border-width-1) solid var(--color-neutral-400);
border-radius: var(--shape-border-radius-1);
text-decoration: none;
}

.commerce-account-sidebar-wrapper .commerce-account-sidebar .commerce-account-sidebar-item-active {
border-color: var(--color-neutral-800);
background-color: var(--color-neutral-200);
}

.commerce-account-sidebar-item-icon {
flex: 0 0 auto;
margin-right: var(--spacing-small);
}

.commerce-account-sidebar-item-icon > div {
display: flex;
align-items: center;
justify-content: center;
}

.commerce-account-sidebar-item-content {
flex: 1 1 auto;
}

.commerce-account-sidebar-item-title {
font: var(--type-button-1-font);
margin: 0 0 var(--spacing-xxsmall);
border: none;
text-decoration: none;
}

.commerce-account-sidebar-item-subtitle {
font: var(--type-button-2-font);
margin: 0;
text-decoration: none;
}

.commerce-account-sidebar-item-arrow {
flex: 0 0 auto;
margin-left: var(--spacing-small);
}

.commerce-account-sidebar-item-arrow > div {
display: flex;
align-items: center;
justify-content: center;
}
79 changes: 79 additions & 0 deletions blocks/commerce-account-sidebar/commerce-account-sidebar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { Icon, provider as uiProvider } from '@dropins/tools/components.js';
import { render as accountRenderer } from '@dropins/storefront-account/render.js';
import { loadFragment } from '../fragment/fragment.js';

export default async function decorate(block) {
const fragment = await loadFragment('/customer/sidebar-fragment');
const sidebarItemsConfig = fragment.querySelectorAll('.default-content-wrapper > ol > li');
const sidebarItems = Array.from(sidebarItemsConfig).map((item) => {
const itemParams = Array.from(item.querySelectorAll('ol > li'));
const itemConfig = {
itemTitle: item.childNodes[0]?.textContent.trim() || 'Default Title',
itemSubtitle: itemParams[0]?.innerText || '',
itemLink: itemParams[1]?.innerText || '#',
itemIcon: itemParams[2]?.innerText || 'Placeholder',
};

const menuItemEl = document.createElement('a');
menuItemEl.classList.add('commerce-account-sidebar-item');
menuItemEl.href = itemConfig.itemLink;

const isItemActive = (
itemConfig.itemLink === '/customer/orders'
? window.location.href.includes('/customer/order')
: window.location.href.includes(itemConfig.itemLink)
);
if (isItemActive) {
menuItemEl.classList.add('commerce-account-sidebar-item-active');
}

const iconEl = createMenuItemIcon(itemConfig.itemIcon);
const contentEl = createMenuItemContent(itemConfig.itemTitle, itemConfig.itemSubtitle);
const arrowEl = createMenuItemArrow();

menuItemEl.appendChild(iconEl);
menuItemEl.appendChild(contentEl);
menuItemEl.appendChild(arrowEl);

return menuItemEl;
});

block.innerHTML = '';
sidebarItems.forEach((el) => {
block.appendChild(el);
});
}

function createMenuItemIcon(iconSource) {
const iconEl = document.createElement('div');
iconEl.classList.add('commerce-account-sidebar-item-icon');
accountRenderer.render(Icon, { source: iconSource, size: 32 })(iconEl);
return iconEl;
}

function createMenuItemContent(title, subtitle) {
const contentEl = document.createElement('div');
contentEl.classList.add('commerce-account-sidebar-item-content');

const titleEl = document.createElement('p');
titleEl.classList.add('commerce-account-sidebar-item-title');
titleEl.innerText = title;

const subtitleEl = document.createElement('p');
subtitleEl.classList.add('commerce-account-sidebar-item-subtitle');
subtitleEl.innerText = subtitle;

contentEl.appendChild(titleEl);
contentEl.appendChild(subtitleEl);
return contentEl;
}

function createMenuItemArrow() {
const arrowEl = document.createElement('div');
arrowEl.classList.add('commerce-account-sidebar-item-arrow');
uiProvider.render(Icon, {
source: 'ChevronRight',
size: 32,
})(arrowEl);
return arrowEl;
}
141 changes: 0 additions & 141 deletions blocks/commerce-account/api/getCustomer.js

This file was deleted.

67 changes: 0 additions & 67 deletions blocks/commerce-account/commerce-account.css

This file was deleted.

Loading

0 comments on commit ca86a23

Please sign in to comment.