@faststore/ui 1.11.8 → 1.11.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/molecules/OrderSummary/OrderSummary.d.ts +35 -0
- package/dist/molecules/OrderSummary/OrderSummary.js +16 -0
- package/dist/molecules/OrderSummary/OrderSummary.js.map +1 -0
- package/dist/molecules/OrderSummary/index.d.ts +2 -0
- package/dist/molecules/OrderSummary/index.js +2 -0
- package/dist/molecules/OrderSummary/index.js.map +1 -0
- package/package.json +3 -3
- package/src/index.ts +3 -0
- package/src/molecules/OrderSummary/OrderSummary.test.tsx +103 -0
- package/src/molecules/OrderSummary/OrderSummary.tsx +109 -0
- package/src/molecules/OrderSummary/index.tsx +2 -0
- package/src/molecules/OrderSummary/stories/OrderSummary.mdx +29 -0
- package/src/molecules/OrderSummary/stories/OrderSummary.stories.tsx +29 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.11.18](https://github.com/vtex/faststore/compare/v1.11.17...v1.11.18) (2022-09-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Adds OrderSummary component to FastStore UI ([#1456](https://github.com/vtex/faststore/issues/1456)) ([f1d983c](https://github.com/vtex/faststore/commit/f1d983cf5684053ad810455d2b6f6ac77bfc7b76))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
## 1.11.8 (2022-09-01)
|
|
7
16
|
|
|
8
17
|
|
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export { default as Gift, GiftContent, GiftImage } from './molecules/Gift';
|
|
|
38
38
|
export type { GiftProps, GiftContentProps, GiftImageProps, } from './molecules/Gift';
|
|
39
39
|
export { default as ProductTitle } from './molecules/ProductTitle';
|
|
40
40
|
export type { ProductTitleProps } from './molecules/ProductTitle';
|
|
41
|
+
export { default as OrderSummary } from './molecules/OrderSummary';
|
|
42
|
+
export type { OrderSummaryProps } from './molecules/OrderSummary';
|
|
41
43
|
export { default as AggregateRating } from './molecules/AggregateRating';
|
|
42
44
|
export type { AggregateRatingProps } from './molecules/AggregateRating';
|
|
43
45
|
export { default as ProductCard, ProductCardImage, ProductCardContent, ProductCardActions, } from './molecules/ProductCard';
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ export { default as Incentive } from './atoms/Incentive';
|
|
|
20
20
|
// Molecules
|
|
21
21
|
export { default as Gift, GiftContent, GiftImage } from './molecules/Gift';
|
|
22
22
|
export { default as ProductTitle } from './molecules/ProductTitle';
|
|
23
|
+
export { default as OrderSummary } from './molecules/OrderSummary';
|
|
23
24
|
export { default as AggregateRating } from './molecules/AggregateRating';
|
|
24
25
|
export { default as ProductCard, ProductCardImage, ProductCardContent, ProductCardActions, } from './molecules/ProductCard';
|
|
25
26
|
export { default as Card, CardImage, CardContent, CardActions, } from './molecules/Card';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,cAAc,CAAA;AAG9C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAGlD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAGhD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,cAAc,CAAA;AAG9C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAGpD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MA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TMLElement> extends Omit<ListProps<T>, 'variant'> {
|
|
4
|
+
/**
|
|
5
|
+
* ID to find this component in testing tools (e.g.: cypress,
|
|
6
|
+
* testing-library, and jest).
|
|
7
|
+
*/
|
|
8
|
+
testId?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Label for the subtotal value of the order. Will only show if subtotalValue is provided.
|
|
11
|
+
*/
|
|
12
|
+
subtotalLabel?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Subtotal value of the order. If provided, subtotal label and value will be shown.
|
|
15
|
+
*/
|
|
16
|
+
subtotalValue?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Label for the discount value for the order. Will only show if discountValue is provided.
|
|
19
|
+
*/
|
|
20
|
+
discountLabel?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Discount value for the order. If provided, discount label and value will be shown.
|
|
23
|
+
*/
|
|
24
|
+
discountValue?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Label for the total value of the order.
|
|
27
|
+
*/
|
|
28
|
+
totalLabel?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Total value of the order.
|
|
31
|
+
*/
|
|
32
|
+
totalValue?: string;
|
|
33
|
+
}
|
|
34
|
+
declare const OrderSummary: React.ForwardRefExoticComponent<OrderSummaryProps<HTMLElement> & React.RefAttributes<HTMLUListElement>>;
|
|
35
|
+
export default OrderSummary;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import List from '../../atoms/List';
|
|
3
|
+
const OrderSummary = forwardRef(function OrderSummary({ testId = 'store-order-summary', children, subtotalLabel, subtotalValue, discountLabel, discountValue, totalLabel, totalValue, ...otherProps }, ref) {
|
|
4
|
+
return (React.createElement(List, Object.assign({ ref: ref, "data-fs-order-summary": true, "data-testid": testId }, otherProps),
|
|
5
|
+
subtotalValue ? (React.createElement("li", { "data-fs-order-summary-subtotal": true },
|
|
6
|
+
React.createElement("span", { "data-fs-order-summary-subtotal-label": true, "data-testid": `${testId}-subtotal-label` }, subtotalLabel),
|
|
7
|
+
React.createElement("span", { "data-fs-order-summary-subtotal-value": true, "data-testid": `${testId}-subtotal-value` }, subtotalValue))) : null,
|
|
8
|
+
discountValue ? (React.createElement("li", { "data-fs-order-summary-discount": true },
|
|
9
|
+
React.createElement("span", { "data-fs-order-summary-discount-label": true, "data-testid": `${testId}-discount-label` }, discountLabel),
|
|
10
|
+
React.createElement("span", { "data-fs-order-summary-discount-value": true, "data-testid": `${testId}-discount-value` }, discountValue))) : null,
|
|
11
|
+
React.createElement("li", { "data-fs-order-summary-total": true },
|
|
12
|
+
React.createElement("span", { "data-fs-order-summary-total-label": true, "data-testid": `${testId}-total-label` }, totalLabel),
|
|
13
|
+
React.createElement("span", { "data-fs-order-summary-total-value": true, "data-testid": `${testId}-total-value` }, totalValue))));
|
|
14
|
+
});
|
|
15
|
+
export default OrderSummary;
|
|
16
|
+
//# sourceMappingURL=OrderSummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrderSummary.js","sourceRoot":"","sources":["../../../src/molecules/OrderSummary/OrderSummary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,IAAmB,MAAM,kBAAkB,CAAA;AAkClD,MAAM,YAAY,GAAG,UAAU,CAC7B,SAAS,YAAY,CACnB,EACE,MAAM,GAAG,qBAAqB,EAC9B,QAAQ,EACR,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,UAAU,EACV,UAAU,EACV,GAAG,UAAU,EACd,EACD,GAAG;IAEH,OAAO,CACL,oBAAC,IAAI,kBACH,GAAG,EAAE,GAAG,gDAEK,MAAM,IACf,UAAU;QAEb,aAAa,CAAC,CAAC,CAAC,CACf;YACE,2FAEe,GAAG,MAAM,iBAAiB,IAEtC,aAAa,CACT;YACP,2FAEe,GAAG,MAAM,iBAAiB,IAEtC,aAAa,CACT,CACJ,CACN,CAAC,CAAC,CAAC,IAAI;QACP,aAAa,CAAC,CAAC,CAAC,CACf;YACE,2FAEe,GAAG,MAAM,iBAAiB,IAEtC,aAAa,CACT;YACP,2FAEe,GAAG,MAAM,iBAAiB,IAEtC,aAAa,CACT,CACJ,CACN,CAAC,CAAC,CAAC,IAAI;QACR;YACE,wFAEe,GAAG,MAAM,cAAc,IAEnC,UAAU,CACN;YACP,wFAEe,GAAG,MAAM,cAAc,IAEnC,UAAU,CACN,CACJ,CACA,CACR,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molecules/OrderSummary/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/ui",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.18",
|
|
4
4
|
"description": "A lightweight, framework agnostic component library for React",
|
|
5
5
|
"author": "emersonlaurentino",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"react-dom": "^17.0.2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@faststore/styles": "^1.11.
|
|
60
|
+
"@faststore/styles": "^1.11.18",
|
|
61
61
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
62
62
|
"@storybook/addon-actions": "^6.4.4",
|
|
63
63
|
"@storybook/addon-docs": "^6.4.4",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"tsdx": "^0.14.1",
|
|
86
86
|
"typescript": "^4.2.4"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "0d01ff2f997acf54f9066d7245c521ddfdbc5bea"
|
|
89
89
|
}
|
package/src/index.ts
CHANGED
|
@@ -64,6 +64,9 @@ export type {
|
|
|
64
64
|
export { default as ProductTitle } from './molecules/ProductTitle'
|
|
65
65
|
export type { ProductTitleProps } from './molecules/ProductTitle'
|
|
66
66
|
|
|
67
|
+
export { default as OrderSummary } from './molecules/OrderSummary'
|
|
68
|
+
export type { OrderSummaryProps } from './molecules/OrderSummary'
|
|
69
|
+
|
|
67
70
|
export { default as AggregateRating } from './molecules/AggregateRating'
|
|
68
71
|
export type { AggregateRatingProps } from './molecules/AggregateRating'
|
|
69
72
|
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { render } from '@testing-library/react'
|
|
2
|
+
import { axe } from 'jest-axe'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
import OrderSummary from './OrderSummary'
|
|
6
|
+
|
|
7
|
+
const ELEMENT_NOT_FOUND_MESSAGE = 'Unable to find an element by:'
|
|
8
|
+
|
|
9
|
+
describe('OrderSummary', () => {
|
|
10
|
+
it('should have `data-fs-order-summary` attribute', () => {
|
|
11
|
+
const { getByTestId } = render(<OrderSummary />)
|
|
12
|
+
|
|
13
|
+
expect(getByTestId('store-order-summary')).toHaveAttribute(
|
|
14
|
+
'data-fs-order-summary'
|
|
15
|
+
)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('should always render total labels and values elements', async () => {
|
|
19
|
+
const { getByTestId } = render(<OrderSummary />)
|
|
20
|
+
|
|
21
|
+
expect(getByTestId('store-order-summary-total-label')).toBeInTheDocument()
|
|
22
|
+
expect(getByTestId('store-order-summary-total-value')).toBeInTheDocument()
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('should not render subtotal or discount labels and values if subtotalValue or discountValue are not provided', async () => {
|
|
26
|
+
const { getByTestId } = render(
|
|
27
|
+
<OrderSummary totalLabel="Total" totalValue="250$" />
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
expect(() =>
|
|
31
|
+
getByTestId('store-order-summary-subtotal-label')
|
|
32
|
+
).toThrowError(ELEMENT_NOT_FOUND_MESSAGE)
|
|
33
|
+
expect(() => getByTestId('store-order-summary-subtotal-value')).toThrow(
|
|
34
|
+
ELEMENT_NOT_FOUND_MESSAGE
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
expect(() => getByTestId('store-order-summary-discount-label')).toThrow(
|
|
38
|
+
ELEMENT_NOT_FOUND_MESSAGE
|
|
39
|
+
)
|
|
40
|
+
expect(() => getByTestId('store-order-summary-discount-value')).toThrow(
|
|
41
|
+
ELEMENT_NOT_FOUND_MESSAGE
|
|
42
|
+
)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('should render subtotal label and value if subtotalValue is provided', async () => {
|
|
46
|
+
const { getByTestId } = render(
|
|
47
|
+
<OrderSummary
|
|
48
|
+
subtotalLabel="Subtotal"
|
|
49
|
+
totalLabel="Total"
|
|
50
|
+
subtotalValue="300$"
|
|
51
|
+
totalValue="250$"
|
|
52
|
+
/>
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
expect(
|
|
56
|
+
getByTestId('store-order-summary-subtotal-label')
|
|
57
|
+
).toBeInTheDocument()
|
|
58
|
+
expect(getByTestId('store-order-summary-subtotal-label')).toHaveTextContent(
|
|
59
|
+
'Subtotal'
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
expect(
|
|
63
|
+
getByTestId('store-order-summary-subtotal-value')
|
|
64
|
+
).toBeInTheDocument()
|
|
65
|
+
expect(getByTestId('store-order-summary-subtotal-value')).toHaveTextContent(
|
|
66
|
+
'300$'
|
|
67
|
+
)
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('should render discount label and value if discountValue is provided', async () => {
|
|
71
|
+
const { getByTestId } = render(
|
|
72
|
+
<OrderSummary
|
|
73
|
+
subtotalLabel="Subtotal"
|
|
74
|
+
totalLabel="Total"
|
|
75
|
+
subtotalValue="300$"
|
|
76
|
+
totalValue="250$"
|
|
77
|
+
discountLabel="Discount"
|
|
78
|
+
discountValue="-50$"
|
|
79
|
+
/>
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
expect(
|
|
83
|
+
getByTestId('store-order-summary-discount-label')
|
|
84
|
+
).toBeInTheDocument()
|
|
85
|
+
expect(getByTestId('store-order-summary-discount-label')).toHaveTextContent(
|
|
86
|
+
'Discount'
|
|
87
|
+
)
|
|
88
|
+
expect(
|
|
89
|
+
getByTestId('store-order-summary-discount-value')
|
|
90
|
+
).toBeInTheDocument()
|
|
91
|
+
expect(getByTestId('store-order-summary-discount-value')).toHaveTextContent(
|
|
92
|
+
'-50$'
|
|
93
|
+
)
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
describe('Accessibility', () => {
|
|
97
|
+
it('should have no violations', async () => {
|
|
98
|
+
const { getByTestId } = render(<OrderSummary />)
|
|
99
|
+
|
|
100
|
+
expect(await axe(getByTestId('store-order-summary'))).toHaveNoViolations()
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
})
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react'
|
|
2
|
+
import List, { ListProps } from '../../atoms/List'
|
|
3
|
+
|
|
4
|
+
export interface OrderSummaryProps<T = HTMLElement> extends Omit<ListProps<T>, 'variant'> {
|
|
5
|
+
/**
|
|
6
|
+
* ID to find this component in testing tools (e.g.: cypress,
|
|
7
|
+
* testing-library, and jest).
|
|
8
|
+
*/
|
|
9
|
+
testId?: string
|
|
10
|
+
/**
|
|
11
|
+
* Label for the subtotal value of the order. Will only show if subtotalValue is provided.
|
|
12
|
+
*/
|
|
13
|
+
subtotalLabel?: string
|
|
14
|
+
/**
|
|
15
|
+
* Subtotal value of the order. If provided, subtotal label and value will be shown.
|
|
16
|
+
*/
|
|
17
|
+
subtotalValue?: string
|
|
18
|
+
/**
|
|
19
|
+
* Label for the discount value for the order. Will only show if discountValue is provided.
|
|
20
|
+
*/
|
|
21
|
+
discountLabel?: string
|
|
22
|
+
/**
|
|
23
|
+
* Discount value for the order. If provided, discount label and value will be shown.
|
|
24
|
+
*/
|
|
25
|
+
discountValue?: string
|
|
26
|
+
/**
|
|
27
|
+
* Label for the total value of the order.
|
|
28
|
+
*/
|
|
29
|
+
totalLabel?: string
|
|
30
|
+
/**
|
|
31
|
+
* Total value of the order.
|
|
32
|
+
*/
|
|
33
|
+
totalValue?: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const OrderSummary = forwardRef<HTMLUListElement, OrderSummaryProps>(
|
|
37
|
+
function OrderSummary(
|
|
38
|
+
{
|
|
39
|
+
testId = 'store-order-summary',
|
|
40
|
+
children,
|
|
41
|
+
subtotalLabel,
|
|
42
|
+
subtotalValue,
|
|
43
|
+
discountLabel,
|
|
44
|
+
discountValue,
|
|
45
|
+
totalLabel,
|
|
46
|
+
totalValue,
|
|
47
|
+
...otherProps
|
|
48
|
+
},
|
|
49
|
+
ref
|
|
50
|
+
) {
|
|
51
|
+
return (
|
|
52
|
+
<List
|
|
53
|
+
ref={ref}
|
|
54
|
+
data-fs-order-summary
|
|
55
|
+
data-testid={testId}
|
|
56
|
+
{...otherProps}
|
|
57
|
+
>
|
|
58
|
+
{subtotalValue ? (
|
|
59
|
+
<li data-fs-order-summary-subtotal>
|
|
60
|
+
<span
|
|
61
|
+
data-fs-order-summary-subtotal-label
|
|
62
|
+
data-testid={`${testId}-subtotal-label`}
|
|
63
|
+
>
|
|
64
|
+
{subtotalLabel}
|
|
65
|
+
</span>
|
|
66
|
+
<span
|
|
67
|
+
data-fs-order-summary-subtotal-value
|
|
68
|
+
data-testid={`${testId}-subtotal-value`}
|
|
69
|
+
>
|
|
70
|
+
{subtotalValue}
|
|
71
|
+
</span>
|
|
72
|
+
</li>
|
|
73
|
+
) : null}
|
|
74
|
+
{discountValue ? (
|
|
75
|
+
<li data-fs-order-summary-discount>
|
|
76
|
+
<span
|
|
77
|
+
data-fs-order-summary-discount-label
|
|
78
|
+
data-testid={`${testId}-discount-label`}
|
|
79
|
+
>
|
|
80
|
+
{discountLabel}
|
|
81
|
+
</span>
|
|
82
|
+
<span
|
|
83
|
+
data-fs-order-summary-discount-value
|
|
84
|
+
data-testid={`${testId}-discount-value`}
|
|
85
|
+
>
|
|
86
|
+
{discountValue}
|
|
87
|
+
</span>
|
|
88
|
+
</li>
|
|
89
|
+
) : null}
|
|
90
|
+
<li data-fs-order-summary-total>
|
|
91
|
+
<span
|
|
92
|
+
data-fs-order-summary-total-label
|
|
93
|
+
data-testid={`${testId}-total-label`}
|
|
94
|
+
>
|
|
95
|
+
{totalLabel}
|
|
96
|
+
</span>
|
|
97
|
+
<span
|
|
98
|
+
data-fs-order-summary-total-value
|
|
99
|
+
data-testid={`${testId}-total-value`}
|
|
100
|
+
>
|
|
101
|
+
{totalValue}
|
|
102
|
+
</span>
|
|
103
|
+
</li>
|
|
104
|
+
</List>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
export default OrderSummary
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Canvas, Props, Story, ArgsTable } from '@storybook/addon-docs'
|
|
2
|
+
|
|
3
|
+
import OrderSummary from '../OrderSummary'
|
|
4
|
+
|
|
5
|
+
# OrderSummary
|
|
6
|
+
|
|
7
|
+
<Canvas>
|
|
8
|
+
<Story id="molecules-ordersummary--order-summary" />
|
|
9
|
+
</Canvas>
|
|
10
|
+
|
|
11
|
+
## Props
|
|
12
|
+
|
|
13
|
+
<ArgsTable of={ OrderSummary } />
|
|
14
|
+
|
|
15
|
+
## CSS Selectors
|
|
16
|
+
|
|
17
|
+
```css
|
|
18
|
+
[data-fs-order-summary] {}
|
|
19
|
+
[data-fs-order-summary-subtotal] {}
|
|
20
|
+
[data-fs-order-summary-subtotal-label] {}
|
|
21
|
+
[data-fs-order-summary-subtotal-value] {}
|
|
22
|
+
[data-fs-order-summary-discount] {}
|
|
23
|
+
[data-fs-order-summary-discount-label] {}
|
|
24
|
+
[data-fs-order-summary-discount-value] {}
|
|
25
|
+
[data-fs-order-summary-total] {}
|
|
26
|
+
[data-fs-order-summary-total-label] {}
|
|
27
|
+
[data-fs-order-summary-total-value] {}
|
|
28
|
+
|
|
29
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Story, Meta } from '@storybook/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import type { OrderSummaryProps } from '../OrderSummary'
|
|
5
|
+
import Component from '../OrderSummary'
|
|
6
|
+
import mdx from './OrderSummary.mdx'
|
|
7
|
+
|
|
8
|
+
const OrderSummaryTemplate: Story<OrderSummaryProps> = () => (
|
|
9
|
+
<Component
|
|
10
|
+
subtotalLabel='Subtotal (3 products)'
|
|
11
|
+
subtotalValue='$300'
|
|
12
|
+
discountLabel='Discount'
|
|
13
|
+
discountValue='-$50'
|
|
14
|
+
totalLabel='Total'
|
|
15
|
+
totalValue='250$'
|
|
16
|
+
/>
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
export const OrderSummary = OrderSummaryTemplate.bind({})
|
|
20
|
+
OrderSummary.storyName = 'OrderSummary'
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
title: 'Molecules/OrderSummary',
|
|
24
|
+
parameters: {
|
|
25
|
+
docs: {
|
|
26
|
+
page: mdx,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
} as Meta
|