-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(atomic, commerce): create atomic-product-multi-value-text compon…
…ent (#4224) https://coveord.atlassian.net/browse/KIT-3440 Implement the `atomic-product-multi-value-text` component to render the values of a multi-value string field. * **New Component**: Add `atomic-product-multi-value-text` component in `packages/atomic/src/components/commerce/product-template-components/atomic-product-multi-value-text/atomic-product-multi-value-text.tsx`. - Combine functionalities from `atomic-product-text`, `atomic-result-text`, and `atomic-result-multi-value-text`. - Use `ProductContext` to get the product data. - Use `getFieldValueCaption` to get the field value caption. - Render the multi-value text field values. * **Storybook**: Add a new story for `atomic-product-multi-value-text` in `packages/atomic/src/components/commerce/product-template-components/atomic-product-multi-value-text/atomic-product-multi-value-text.new.stories.tsx`. - Test rendering of multi-value text field values. - Test rendering with different `max-values-to-display` values. - Test rendering with custom slot values. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/coveo/ui-kit?shareId=02336614-673d-4772-9196-21872fd10d36). --- KIT-3440 --------- Co-authored-by: Frederic Beaudoin <[email protected]> Co-authored-by: GitHub Actions Bot <> Co-authored-by: ylakhdar <[email protected]>
- Loading branch information
1 parent
38970c3
commit 949d6ca
Showing
17 changed files
with
647 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
...omponents/atomic-product-multi-value-text/atomic-product-multi-value-text.new.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
], | ||
}; |
19 changes: 19 additions & 0 deletions
19
...-template-components/atomic-product-multi-value-text/atomic-product-multi-value-text.pcss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
} | ||
} |
Oops, something went wrong.