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

feat(atomic, commerce): create atomic-product-multi-value-text component #4224

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7cab153
Create atomic-product-multi-value-text component
louis-bompart Jul 25, 2024
e415e63
correctif
louis-bompart Jul 29, 2024
979409f
building
louis-bompart Jul 30, 2024
b1aa3c9
example working
louis-bompart Jul 30, 2024
5d5fa54
clean-stories
louis-bompart Jul 30, 2024
81f81dc
Fix imports
fbeaudoincoveo Sep 11, 2024
b167c7c
Merge branch 'master' into louis-bompart/add-atomic-product-multi-val…
fbeaudoincoveo Sep 11, 2024
6d1b4b4
Add generated files
Sep 11, 2024
c1f3270
Rebuild
fbeaudoincoveo Sep 11, 2024
b09c743
Merge branch 'louis-bompart/add-atomic-product-multi-value-text' of g…
fbeaudoincoveo Sep 11, 2024
d4d762c
Merge branch 'master' into louis-bompart/add-atomic-product-multi-val…
fbeaudoincoveo Sep 13, 2024
533df2b
Add component to sample pages
fbeaudoincoveo Sep 16, 2024
7cbf887
Work on stories
fbeaudoincoveo Sep 16, 2024
348fd14
Merge branch 'master' into louis-bompart/add-atomic-product-multi-val…
fbeaudoincoveo Sep 18, 2024
230d6df
Merge branch 'master' into louis-bompart/add-atomic-product-multi-val…
fbeaudoincoveo Sep 26, 2024
cd39d0a
Fix story
fbeaudoincoveo Sep 26, 2024
47165a6
Add basic structure for e2e
fbeaudoincoveo Sep 26, 2024
f5cadfe
Work on tests/stories
fbeaudoincoveo Sep 26, 2024
787cc39
Work on tests
fbeaudoincoveo Sep 27, 2024
adce122
Add accessibility check
fbeaudoincoveo Sep 27, 2024
7087b4c
Reorganize stories
fbeaudoincoveo Sep 27, 2024
9266ac1
Small adjustments to tests
fbeaudoincoveo Sep 27, 2024
42c1627
Merge branch 'master' into louis-bompart/add-atomic-product-multi-val…
fbeaudoincoveo Sep 27, 2024
a1c5a25
Merge branch 'master' into louis-bompart/add-atomic-product-multi-val…
fbeaudoincoveo Oct 2, 2024
eab2f9f
Merge branch 'master' into louis-bompart/add-atomic-product-multi-val…
fbeaudoincoveo Oct 4, 2024
7f16e98
Remove unused file
fbeaudoincoveo Oct 7, 2024
c282a8c
Adjust component logic and documentation
fbeaudoincoveo Oct 7, 2024
9c48a2a
Add missing tests + stories & adjust existing tests
fbeaudoincoveo Oct 7, 2024
40c116a
Add generated files
Oct 7, 2024
90b14ef
Fix getNumberOfValuesToDisplay logic
fbeaudoincoveo Oct 7, 2024
b3e9542
Merge branch 'master' into louis-bompart/add-atomic-product-multi-val…
louis-bompart Oct 7, 2024
24d46a2
Merge branch 'master' into louis-bompart/add-atomic-product-multi-val…
fbeaudoincoveo Oct 8, 2024
fc60cc6
Fix broken test
fbeaudoincoveo Oct 8, 2024
77f01f0
Merge branch 'master' into louis-bompart/add-atomic-product-multi-val…
louis-bompart Oct 8, 2024
c1ac74e
Apply suggestions from code review
louis-bompart Oct 16, 2024
4fb7fd5
typo
louis-bompart Nov 4, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ AtomicProductDescription,
AtomicProductFieldCondition,
AtomicProductImage,
AtomicProductLink,
AtomicProductMultiValueText,
AtomicProductNumericFieldValue,
AtomicProductPrice,
AtomicProductRating,
Expand Down Expand Up @@ -208,6 +209,7 @@ AtomicProductDescription,
AtomicProductFieldCondition,
AtomicProductImage,
AtomicProductLink,
AtomicProductMultiValueText,
AtomicProductNumericFieldValue,
AtomicProductPrice,
AtomicProductRating,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,28 @@ export class AtomicProductLink {
export declare interface AtomicProductLink extends Components.AtomicProductLink {}


@ProxyCmp({
inputs: ['delimiter', 'field', 'maxValuesToDisplay']
})
@Component({
selector: 'atomic-product-multi-value-text',
changeDetection: ChangeDetectionStrategy.OnPush,
template: '<ng-content></ng-content>',
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
inputs: ['delimiter', 'field', 'maxValuesToDisplay'],
})
export class AtomicProductMultiValueText {
protected el: HTMLElement;
constructor(c: ChangeDetectorRef, r: ElementRef, protected z: NgZone) {
c.detach();
this.el = r.nativeElement;
}
}


export declare interface AtomicProductMultiValueText extends Components.AtomicProductMultiValueText {}


@ProxyCmp({
inputs: ['field']
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const AtomicProductDescription = /*@__PURE__*/createReactComponent<JSX.At
export const AtomicProductFieldCondition = /*@__PURE__*/createReactComponent<JSX.AtomicProductFieldCondition, HTMLAtomicProductFieldConditionElement>('atomic-product-field-condition');
export const AtomicProductImage = /*@__PURE__*/createReactComponent<JSX.AtomicProductImage, HTMLAtomicProductImageElement>('atomic-product-image');
export const AtomicProductLink = /*@__PURE__*/createReactComponent<JSX.AtomicProductLink, HTMLAtomicProductLinkElement>('atomic-product-link');
export const AtomicProductMultiValueText = /*@__PURE__*/createReactComponent<JSX.AtomicProductMultiValueText, HTMLAtomicProductMultiValueTextElement>('atomic-product-multi-value-text');
export const AtomicProductNumericFieldValue = /*@__PURE__*/createReactComponent<JSX.AtomicProductNumericFieldValue, HTMLAtomicProductNumericFieldValueElement>('atomic-product-numeric-field-value');
export const AtomicProductPrice = /*@__PURE__*/createReactComponent<JSX.AtomicProductPrice, HTMLAtomicProductPriceElement>('atomic-product-price');
export const AtomicProductRating = /*@__PURE__*/createReactComponent<JSX.AtomicProductRating, HTMLAtomicProductRatingElement>('atomic-product-rating');
Expand Down
49 changes: 49 additions & 0 deletions packages/atomic/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2076,6 +2076,23 @@ export namespace Components {
*/
"hrefTemplate"?: string;
}
/**
* The `atomic-product-multi-value-text` component renders the values of a multi-value string field.
*/
interface AtomicProductMultiValueText {
/**
* The delimiter used to separate values when the field isn't indexed as a multi value field.
*/
"delimiter": string | null;
/**
* The field that the component should use. The component will try to find this field in the `Product.additionalFields` object unless it finds it in the `Product` object first. Make sure this field is present in the `fieldsToInclude` property of the `atomic-commerce-interface` component.
*/
"field": string;
/**
* The maximum number of field values to display. If there are _n_ more values than the specified maximum, the last displayed value will be "_n_ more...".
*/
"maxValuesToDisplay": number;
}
/**
* @alpha The `atomic-product-numeric-field-value` component renders the value of a number product field.
* The number can be formatted by adding a `atomic-format-number`, `atomic-format-currency` or `atomic-format-unit` component into this component.
Expand Down Expand Up @@ -4816,6 +4833,15 @@ declare global {
prototype: HTMLAtomicProductLinkElement;
new (): HTMLAtomicProductLinkElement;
};
/**
* The `atomic-product-multi-value-text` component renders the values of a multi-value string field.
*/
interface HTMLAtomicProductMultiValueTextElement extends Components.AtomicProductMultiValueText, HTMLStencilElement {
}
var HTMLAtomicProductMultiValueTextElement: {
prototype: HTMLAtomicProductMultiValueTextElement;
new (): HTMLAtomicProductMultiValueTextElement;
};
/**
* @alpha The `atomic-product-numeric-field-value` component renders the value of a number product field.
* The number can be formatted by adding a `atomic-format-number`, `atomic-format-currency` or `atomic-format-unit` component into this component.
Expand Down Expand Up @@ -5940,6 +5966,7 @@ declare global {
"atomic-product-field-condition": HTMLAtomicProductFieldConditionElement;
"atomic-product-image": HTMLAtomicProductImageElement;
"atomic-product-link": HTMLAtomicProductLinkElement;
"atomic-product-multi-value-text": HTMLAtomicProductMultiValueTextElement;
"atomic-product-numeric-field-value": HTMLAtomicProductNumericFieldValueElement;
"atomic-product-price": HTMLAtomicProductPriceElement;
"atomic-product-rating": HTMLAtomicProductRatingElement;
Expand Down Expand Up @@ -7947,6 +7974,23 @@ declare namespace LocalJSX {
*/
"hrefTemplate"?: string;
}
/**
* The `atomic-product-multi-value-text` component renders the values of a multi-value string field.
*/
interface AtomicProductMultiValueText {
/**
* The delimiter used to separate values when the field isn't indexed as a multi value field.
*/
"delimiter"?: string | null;
/**
* The field that the component should use. The component will try to find this field in the `Product.additionalFields` object unless it finds it in the `Product` object first. Make sure this field is present in the `fieldsToInclude` property of the `atomic-commerce-interface` component.
*/
"field": string;
/**
* The maximum number of field values to display. If there are _n_ more values than the specified maximum, the last displayed value will be "_n_ more...".
*/
"maxValuesToDisplay"?: number;
}
/**
* @alpha The `atomic-product-numeric-field-value` component renders the value of a number product field.
* The number can be formatted by adding a `atomic-format-number`, `atomic-format-currency` or `atomic-format-unit` component into this component.
Expand Down Expand Up @@ -9562,6 +9606,7 @@ declare namespace LocalJSX {
"atomic-product-field-condition": AtomicProductFieldCondition;
"atomic-product-image": AtomicProductImage;
"atomic-product-link": AtomicProductLink;
"atomic-product-multi-value-text": AtomicProductMultiValueText;
"atomic-product-numeric-field-value": AtomicProductNumericFieldValue;
"atomic-product-price": AtomicProductPrice;
"atomic-product-rating": AtomicProductRating;
Expand Down Expand Up @@ -10023,6 +10068,10 @@ declare module "@stencil/core" {
* @alpha The `atomic-product-link` component automatically transforms a search product title into a clickable link that points to the original item.
*/
"atomic-product-link": LocalJSX.AtomicProductLink & JSXBase.HTMLAttributes<HTMLAtomicProductLinkElement>;
/**
* The `atomic-product-multi-value-text` component renders the values of a multi-value string field.
*/
"atomic-product-multi-value-text": LocalJSX.AtomicProductMultiValueText & JSXBase.HTMLAttributes<HTMLAtomicProductMultiValueTextElement>;
/**
* @alpha The `atomic-product-numeric-field-value` component renders the value of a number product field.
* The number can be formatted by adding a `atomic-format-number`, `atomic-format-currency` or `atomic-format-unit` component into this component.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import {wrapInCommerceInterface} from '@coveo/atomic-storybook-utils/commerce/commerce-interface-wrapper';
import {wrapInCommerceProductList} from '@coveo/atomic-storybook-utils/commerce/commerce-product-list-wrapper';
import {wrapInProductTemplate} from '@coveo/atomic-storybook-utils/commerce/commerce-product-template-wrapper';
import {parameters} from '@coveo/atomic-storybook-utils/common/common-meta-parameters';
import {renderComponent} from '@coveo/atomic-storybook-utils/common/render-component';
import {getSampleCommerceEngineConfiguration} from '@coveo/headless/commerce';
import type {Meta, StoryObj as Story} from '@storybook/web-components';
import {html} from 'lit/static-html.js';

const baseConfiguration = getSampleCommerceEngineConfiguration();

const {decorator: productDecorator} = wrapInProductTemplate();
const {decorator: commerceProductListDecorator} = wrapInCommerceProductList();
const {decorator: commerceInterfaceDecorator, play} = wrapInCommerceInterface({
engineConfig: {
...baseConfiguration,
context: {
...baseConfiguration.context,
view: {
url: 'https://sports.barca.group/browse/promotions/ui-kit-testing-product-multi-value-text',
},
},
},
type: 'product-listing',
});

const meta: Meta = {
component: 'atomic-product-multi-value-text',
title: 'Atomic-Commerce/Product Template Components/MultiValueText',
id: 'atomic-product-multi-value-text',
render: renderComponent,
parameters,
play,
args: {
'attributes-field': 'cat_available_sizes',
},
};

export default meta;

export const Default: Story = {
name: 'atomic-product-multi-value-text',
decorators: [
productDecorator,
commerceProductListDecorator,
commerceInterfaceDecorator,
],
};

export const WithDelimiter: Story = {
name: 'With delimiter',
decorators: [
productDecorator,
commerceProductListDecorator,
commerceInterfaceDecorator,
],
args: {
'attributes-field': 'ec_product_id',
'attributes-delimiter': '_',
},
};

export const WithMaxValuesToDisplaySetToMinimum: Story = {
name: 'With max values to display set to minimum',
decorators: [
productDecorator,
commerceProductListDecorator,
commerceInterfaceDecorator,
],
args: {
'attributes-max-values-to-display': 1,
},
};

export const WithMaxValuesToDisplaySetToTotalNumberOfValues: Story = {
name: 'With max values to display set to total number of values',
decorators: [
productDecorator,
commerceProductListDecorator,
commerceInterfaceDecorator,
],
args: {
'attributes-max-values-to-display': 6,
},
};

export const InAPageWithTheCorrespondingFacet: Story = {
name: 'In a page with the corresponding facet',
decorators: [
productDecorator,
commerceProductListDecorator,
(story) => {
return html`
<atomic-commerce-layout>
<atomic-layout-section section="facets"
><atomic-commerce-facets></atomic-commerce-facets>
</atomic-layout-section>
<atomic-layout-section section="main">
${story()}
</atomic-layout-section>
</atomic-commerce-layout>
`;
},
commerceInterfaceDecorator,
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
:host {
> ul {
display: flex;
list-style: none;
margin: 0;
padding: 0;

li {
display: inline-block;
}
}
}

.separator {
&::before {
display: inline;
content: ',\00a0';
}
}
Loading
Loading