Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

my account navigation #960

Draft
wants to merge 45 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
be99932
artificial commit
tobi-or-not-tobi Nov 9, 2023
c0b0584
chore: Navigation layout plugin implementation (#883)
tobi-or-not-tobi Nov 10, 2023
0fa5bea
Merge branch 'development' into feature/HRZ-2519-header-navigation
tobi-or-not-tobi Nov 10, 2023
db3b986
fix SSR
tobi-or-not-tobi Nov 10, 2023
1f2b129
ssr improvements
tobi-or-not-tobi Nov 10, 2023
e17d437
category list component
tobi-or-not-tobi Nov 11, 2023
9876bf3
style lint
tobi-or-not-tobi Nov 11, 2023
03ce240
fix
tobi-or-not-tobi Nov 11, 2023
12c410d
Merge branch 'development' into feature/HRZ-2519-header-navigation
tobi-or-not-tobi Nov 13, 2023
c60cbde
refactor: category links refactor (#893)
tobi-or-not-tobi Nov 13, 2023
3ba3889
fix
tobi-or-not-tobi Nov 14, 2023
68bbeec
Merge branch 'development' into feature/HRZ-2519-header-navigation
tobi-or-not-tobi Nov 14, 2023
d8d20bc
Merge branch 'development' into feature/HRZ-90382-category-list
tobi-or-not-tobi Nov 15, 2023
2847e1c
fix styles
tobi-or-not-tobi Nov 15, 2023
12defb6
Merge branch 'development' into feature/HRZ-90382-category-list
tobi-or-not-tobi Nov 15, 2023
7e87363
Merge branch 'development' into feature/HRZ-2519-header-navigation
tobi-or-not-tobi Nov 15, 2023
b01cb57
chore: category navigation e2e (#892)
tobi-or-not-tobi Nov 15, 2023
60f3a61
Merge branch 'feature/HRZ-2519-header-navigation' into feature/HRZ-90…
tobi-or-not-tobi Nov 15, 2023
541d636
dropdown
tobi-or-not-tobi Nov 15, 2023
c559022
Merge branch 'development' into feature/HRZ-90382-category-list
tobi-or-not-tobi Nov 21, 2023
ff9f9e9
tmp
tobi-or-not-tobi Nov 22, 2023
2d96118
Merge branch 'development' into feature/HRZ-90382-category-list
tobi-or-not-tobi Nov 24, 2023
a770221
temp
tobi-or-not-tobi Nov 25, 2023
b9c1860
cleanup
tobi-or-not-tobi Nov 25, 2023
ccac324
tmp
tobi-or-not-tobi Nov 26, 2023
214a783
Merge branch 'development' into feature/HRZ-90382-category-list
tobi-or-not-tobi Nov 27, 2023
33827ca
Merge branch 'development' into feature/HRZ-90382-category-list
tobi-or-not-tobi Nov 30, 2023
aa6b127
tmp
tobi-or-not-tobi Nov 30, 2023
9d89b8a
My account navigation and pages
tobi-or-not-tobi Nov 30, 2023
c052bb7
missing pages, simplify path
tobi-or-not-tobi Nov 30, 2023
6c3cfda
cleanup
tobi-or-not-tobi Nov 30, 2023
2bfec6e
move trigger component to user domain
tobi-or-not-tobi Nov 30, 2023
dda08a5
nav ref
tobi-or-not-tobi Nov 30, 2023
1f36472
Merge branch 'development' into feature/HRZ-90382-category-list
tobi-or-not-tobi Dec 3, 2023
9e7c3bb
my account control
tobi-or-not-tobi Dec 4, 2023
244ebe9
Merge branch 'development' into feature/HRZ-90382-category-list
tobi-or-not-tobi Dec 4, 2023
2cd6d34
clean up
tobi-or-not-tobi Dec 4, 2023
a7e0992
cleanup
tobi-or-not-tobi Dec 4, 2023
9edae87
cleanup
tobi-or-not-tobi Dec 4, 2023
946256c
add tests for logout
tobi-or-not-tobi Dec 4, 2023
f0b156b
Merge branch 'development' into feature/HRZ-90382-category-list
tobi-or-not-tobi Dec 7, 2023
41452d1
Merge branch 'development' into feature/HRZ-90382-category-list
tobi-or-not-tobi Dec 12, 2023
8b4c813
logout link component
tobi-or-not-tobi Dec 12, 2023
df723e3
Merge branch 'development' into feature/HRZ-90382-category-list
tobi-or-not-tobi Dec 13, 2023
0e0cca4
in between
tobi-or-not-tobi Dec 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/base/ui/graphical/icon/src/icon.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export enum IconTypes {
Carrier = 'carrier',
Location = 'location_on',
Login = 'login',
Logout = 'logout',
List = 'list',
ViewList = 'view_list',
BulletList = 'format_list_bulleted',
Expand Down
14 changes: 6 additions & 8 deletions libs/base/ui/overlays/dropdown/src/styles/base.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Position } from '../dropdown.model';

export const dropdownBaseStyles = css`
:host {
--oryx-popover-top-space: 4px;
--oryx-popover-vertical-offset: 10px;
--oryx-popover-maxwidth: 206px;

Expand All @@ -23,16 +22,16 @@ export const dropdownBaseStyles = css`
var(--oryx-popover-maxwidth)
);

z-index: 100;
overflow: auto;
/* z-index: 100; */
/* overflow: auto; */
max-height: min(
calc(
var(--_available-popover-height, ${unsafecss(POPOVER_HEIGHT)}px) +
var(--_bounding-element-height, 0)
),
var(--oryx-popover-maxheight, ${unsafecss(POPOVER_HEIGHT)}px)
);
width: var(--_oryx-dropdown-width);
width: var(--oryx-dropdown-width, var(--_oryx-dropdown-width));
inset-block-start: 0;
inset-inline: var(--_oryx-dropdown-start-offset, auto)
var(--_oryx-dropdown-end-offset, auto);
Expand All @@ -49,9 +48,8 @@ export const dropdownBaseStyles = css`

${featureVersion >= `1.3`
? css`
:host(:not([vertical-align])) oryx-popover {
transform: scaleX(var(--oryx-popover-visible, 0))
scaleY(var(--oryx-popover-visible, 0));
:host([vertical-align]) oryx-popover {
transform: scaleY(var(--oryx-popover-visible, 0));
}
`
: css``}
Expand Down Expand Up @@ -95,7 +93,7 @@ export const dropdownBaseStyles = css`
}

:host([vertical-align]:not([up])) oryx-popover {
inset-block-start: calc(100% + var(--oryx-popover-top-space));
inset-block-start: calc(100% + var(--oryx-popover-top-space, 4px));
}

:host([vertical-align][up]) oryx-popover {
Expand Down
8 changes: 6 additions & 2 deletions libs/base/ui/overlays/popover/src/styles/oryx.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import { css } from 'lit';
export const popoverStyles = css`
:host {
background-color: var(--oryx-color-neutral-1);
box-shadow: var(--oryx-elevation-2) var(--oryx-color-elevation);
border-radius: var(--oryx-border-radius-small);
box-shadow: var(--oryx-shadow-hovering) var(--oryx-color-elevation);
border-radius: var(
--oryx-popover-border-radius,
var(--oryx-border-radius-small)
);
transition: transform var(--oryx-transition-time) ease-in-out;
width: var(--oryx-popover-width);
}
`;
12 changes: 6 additions & 6 deletions libs/domain/content/link/link.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class ContentLinkComponent extends ContentMixin<
protected $link = computed(() => {
const { url, type, id, params } = this.$options();
if (url) return of(url);
if (type) return this.semanticLinkService.get({ type: type, id, params });
if (type) return this.semanticLinkService.get({ type, id, params });
return of(null);
});

Expand All @@ -56,9 +56,9 @@ export class ContentLinkComponent extends ContentMixin<
const { button, icon, singleLine, color } = this.$options();

if (button) {
return html`<oryx-button part="link" }
>${this.renderLink(true)}</oryx-button
>`;
return html`<oryx-button part="link">
${this.renderLink(true)}
</oryx-button>`;
}

return html`<oryx-link
Expand All @@ -78,7 +78,7 @@ export class ContentLinkComponent extends ContentMixin<

if (type === RouteType.Category && id) {
return this.categoryService
.get(id)
.get({ id })
.pipe(map((category) => category?.name));
}

Expand All @@ -94,7 +94,7 @@ export class ContentLinkComponent extends ContentMixin<
});

protected renderLink(custom?: boolean): TemplateResult {
if (!this.$link()) return html`${this.$text()}`;
if (!this.$link()) return html`<a tabindex="0">${this.$text()}</a>`;

const { label, target } = this.$options();

Expand Down
4 changes: 4 additions & 0 deletions libs/domain/product/categories/list/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './list.component';
export * from './list.model';
export * from './list.schema';
export * from './list.styles';
141 changes: 141 additions & 0 deletions libs/domain/product/categories/list/list.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import { resolve } from '@spryker-oryx/di';
import { ContentMixin, LayoutMixin } from '@spryker-oryx/experience';
import { ProductCategoryService, ProductMixin } from '@spryker-oryx/product';
import {
computed,
hydrate,
signal,
signalProperty,
} from '@spryker-oryx/utilities';
import { LitElement, TemplateResult, html } from 'lit';
import { property } from 'lit/decorators.js';
import { repeat } from 'lit/directives/repeat.js';
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
import {
ProductCategoryListAttributes,
ProductCategoryListOptions,
} from './list.model';
import { categoryListStyles } from './list.styles';

@hydrate()
export class ProductCategoryListComponent
extends ProductMixin(
LayoutMixin(ContentMixin<ProductCategoryListOptions>(LitElement))
)
implements ProductCategoryListAttributes
{
static styles = categoryListStyles;

@signalProperty() categoryId?: string;
@property({ type: 'boolean' }) dropdown?: boolean;

protected productCategoryService = resolve(ProductCategoryService);

protected $all = signal(this.productCategoryService.getTree());

protected $list = computed(() => {
const { id, nested } = this.$options();
if (!(id || this.categoryId) || !nested) {
return this.productCategoryService.getList();
} else {
return this.productCategoryService.getList({
parent: id || this.categoryId,
});
}
});

protected $filteredList = computed(() => {
const items = this.$list() ?? [];
const excludes = this.getExcludes(items.map((c) => c.id));
return items.filter((c) => !excludes.includes(c.id));
});

protected override render(): TemplateResult {
return html`
<section>
${repeat(
this.$filteredList(),
(c) => c.id,
(c) => this.renderItem(c.id)
)}
</section>
<section>
<oryx-content-link
.options=${{
id: 5,
type: 'category',
singleLine: true,
}}
></oryx-content-link>
</section>
${unsafeHTML(`<style>${this.layoutStyles()}</style>`)}
`;
}

protected renderItem(id: string): TemplateResult {
const hasChildren = this.hasChildren(id);
const iconSuffix =
this.dropdown && hasChildren ? 'navigate_next' : undefined;

const link = html`<oryx-content-link
.options=${{
id,
type: 'category',
iconSuffix: iconSuffix,
singleLine: true,
}}
></oryx-content-link>`;

const { nested } = this.$options();
if (nested && hasChildren) {
return html`<div>
${link}
<oryx-product-category-list
.options=${{ id, nested }}
></oryx-product-category-list>
</div>`;
} else {
return link;
}
}

protected hasChildren(categoryId: string): boolean {
return !!this.$all()?.find((c) => c.parent === categoryId);
}

protected getExcludes(categories: string[]): string[] {
const { exclude } = this.$options();
let excludedIds: string[] = [];

if (exclude) {
// Convert both string and array notations to array of strings
const excludeIds = Array.isArray(exclude)
? exclude.map(String)
: exclude.split(',').map((id) => id.trim());

// Handle range notations like >5, <4, 4..11
excludedIds = categories.filter((categoryId) => {
return excludeIds.some((excludedId) => {
if (excludedId.includes('..')) {
const [start, end] = excludedId
.split('..')
.map((num) => parseInt(num, 10));
const num = parseInt(categoryId, 10);
return num >= start && num <= end;
} else if (excludedId.startsWith('>')) {
const threshold = parseInt(excludedId.slice(1), 10);
return parseInt(categoryId, 10) > threshold;
} else if (excludedId.startsWith('<')) {
const threshold = parseInt(excludedId.slice(1), 10);
return parseInt(categoryId, 10) < threshold;
} else {
// Regular ID match
return categoryId === excludedId;
}
});
});
}

return excludedIds;
}
}
16 changes: 16 additions & 0 deletions libs/domain/product/categories/list/list.def.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { componentDef } from '@spryker-oryx/utilities';
import { ProductCategoryListOptions } from './list.model';

declare global {
interface FeatureOptions {
'oryx-product-category-list'?: ProductCategoryListOptions;
}
}

export const productCategoryListComponent = componentDef({
name: 'oryx-product-category-list',
impl: () =>
import('./list.component').then((m) => m.ProductCategoryListComponent),
schema: () =>
import('./list.schema').then((m) => m.productCategoryListSchema),
});
42 changes: 42 additions & 0 deletions libs/domain/product/categories/list/list.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export interface ProductCategoryListOptions {
heading?: string;

id?: string;

/**
* Whether to render nested categories or not.
*/
nested?: boolean;

/**
* Excludes categories from the list.
*
* The `exclude` property can be specified in different formats:
* - A comma-separated string of category IDs.
* - An array of category IDs.
*
* The category IDs can be an actual ID or a range notation, like `>5`, `<4`, `4..11`.
*
* Examples:
* ```ts
* const excludeString = "1, 2, 3";
* const excludeArray = [4, 5, 6];
* const excludeRange = ">8";
* ```
*
* @remarks
* The `exclude` string or array can contain notations to specify which IDs should be excluded.
* Notations include:
* - `>X` for excluding IDs greater than X.
* - `<X` for excluding IDs less than X.
* - `X..Y` for excluding IDs within the range of X to Y (inclusive).
*/
exclude?: string | string[];
}

export interface ProductCategoryListAttributes {
/**
* Optional category id to filter products by.
*/
categoryId?: string;
}
11 changes: 11 additions & 0 deletions libs/domain/product/categories/list/list.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ContentComponentSchema } from '@spryker-oryx/experience';
import { IconTypes } from '@spryker-oryx/ui/icon';
import { ProductCategoryListComponent } from './list.component';

export const productCategoryListSchema: ContentComponentSchema<ProductCategoryListComponent> =
{
name: 'Product Category List',
group: 'Product',
icon: IconTypes.ViewList,
options: {},
};
39 changes: 39 additions & 0 deletions libs/domain/product/categories/list/list.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { css } from 'lit';

export const categoryListStyles = css`
:host {
/* --oryx-popover-visible: 1; */

display: contents;
width: inherit;
}

section {
display: contents;
}

div {
/* position: relative; */
display: contents;
width: inherit;
}

div > oryx-product-category-list {
display: block;
}

oryx-product-category-list {
position: absolute;
inset-inline-start: 100%;
inset-block-start: 0;
/* outline: solid 1px red; */
height: 100%;
background-color: var(--oryx-color-neutral-1);
width: inherit;
}

div:not(:hover) oryx-product-category-list {
opacity: 0;
pointer-events: none;
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class DefaultProductCategoryService implements ProductCategoryService {
: of([category])
),
map((trail) => trail.sort((a, b) => (a.id === b.parent ? -1 : 1)))
// tap(console.log)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class ProductDetailsBreadcrumbResolver implements BreadcrumbResolver {
}

return combineLatest(
categoryIds.map((id) => this.categoryService.getTrail(id))
categoryIds.map((id) => this.categoryService.getTrail({ id }))
).pipe(
switchMap((trails) =>
combineLatest([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class CategoryBreadcrumbResolver implements BreadcrumbResolver {
switchMap((category) =>
this.categoryService
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
.getTrail(String((category as ValueFacet).selectedValues![0]))
.getTrail({ id: String((category as ValueFacet).selectedValues![0]) })
.pipe(
switchMap((trail) =>
combineLatest(
Expand Down
1 change: 1 addition & 0 deletions libs/domain/user/navigation-trigger/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './navigation-trigger.component.js';
Loading
Loading