@faststore/ui 2.0.6-alpha.0 → 2.0.9-alpha.0
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 +18 -0
- package/dist/components/molecules/PriceRange/PriceRange.d.ts +1 -1
- package/dist/components/molecules/PriceRange/PriceRange.js +1 -1
- package/dist/components/molecules/PriceRange/PriceRange.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/atoms/Price/styles.scss +27 -0
- package/src/components/molecules/DiscountBadge/DiscountBadge.stories.mdx +38 -0
- package/src/components/molecules/DiscountBadge/styles.scss +57 -0
- package/src/components/molecules/Gift/stories/Gift.stories.tsx +1 -2
- package/src/components/molecules/PriceRange/PriceRange.tsx +3 -2
- package/src/components/molecules/ProductCard/stories/ProductCard.stories.tsx +1 -2
- package/src/index.ts +0 -3
- package/src/styles/components.scss +2 -0
- package/dist/components/atoms/Price/Price.d.ts +0 -28
- package/dist/components/atoms/Price/Price.js +0 -7
- package/dist/components/atoms/Price/Price.js.map +0 -1
- package/dist/components/atoms/Price/index.d.ts +0 -2
- package/dist/components/atoms/Price/index.js +0 -2
- package/dist/components/atoms/Price/index.js.map +0 -1
- package/src/components/atoms/Price/Price.tsx +0 -65
- package/src/components/atoms/Price/index.ts +0 -2
- package/src/components/atoms/Price/stories/Price.mdx +0 -51
- package/src/components/atoms/Price/stories/Price.stories.tsx +0 -123
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
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
|
+
## [2.0.9-alpha.0](https://github.com/vtex/faststore/compare/v2.0.8-alpha.0...v2.0.9-alpha.0) (2022-12-12)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Create `Price` component ([#1548](https://github.com/vtex/faststore/issues/1548)) ([2d7418a](https://github.com/vtex/faststore/commit/2d7418ad45f42cdb0174d45d7c4de5b6d6e27f60))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [2.0.7-alpha.0](https://github.com/vtex/faststore/compare/v2.0.6-alpha.0...v2.0.7-alpha.0) (2022-12-09)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* Adds `DiscountBadge` component ([#1546](https://github.com/vtex/faststore/issues/1546)) ([9b2e279](https://github.com/vtex/faststore/commit/9b2e27940ffa9b52c9a62541a07e1f593a0bcfb7)), closes [#313](https://github.com/vtex/faststore/issues/313)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## [2.0.6-alpha.0](https://github.com/vtex/faststore/compare/v2.0.5-alpha.0...v2.0.6-alpha.0) (2022-12-08)
|
|
7
25
|
|
|
8
26
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { AriaAttributes } from 'react';
|
|
3
|
-
import type { PriceProps } from '
|
|
3
|
+
import type { PriceProps } from '@faststore/components';
|
|
4
4
|
import type { SliderProps } from '../../atoms/Slider';
|
|
5
5
|
export declare type PriceRangeProps = SliderProps & {
|
|
6
6
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useRef, useImperativeHandle, forwardRef } from 'react';
|
|
2
|
-
import Price from '
|
|
2
|
+
import { Price } from '@faststore/components';
|
|
3
3
|
import Slider from '../../atoms/Slider';
|
|
4
4
|
const PriceRange = forwardRef(function PriceRange({ className, formatter, max, min, step, onChange, onEnd, testId = 'store-price-range', variant, 'aria-label': ariaLabel, }, ref) {
|
|
5
5
|
const sliderRef = useRef();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PriceRange.js","sourceRoot":"","sources":["../../../../src/components/molecules/PriceRange/PriceRange.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGtE,OAAO,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"PriceRange.js","sourceRoot":"","sources":["../../../../src/components/molecules/PriceRange/PriceRange.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGtE,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAG7C,OAAO,MAAM,MAAM,oBAAoB,CAAA;AA0BvC,MAAM,UAAU,GAAG,UAAU,CAC3B,SAAS,UAAU,CACjB,EACE,SAAS,EACT,SAAS,EACT,GAAG,EACH,GAAG,EACH,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,MAAM,GAAG,mBAAmB,EAC5B,OAAO,EACP,YAAY,EAAE,SAAS,GACxB,EACD,GAAG;IAEH,MAAM,SAAS,GAAG,MAAM,EAEpB,CAAA;IAEJ,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAC9B,mBAAmB,EAAE,CAAC,MAAoC,EAAE,EAAE;YAC5D,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAA;YAClB,SAAS,CAAC,OAAO,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;QAC5C,CAAC;KACF,CAAC,CAAC,CAAA;IAEH,OAAO,CACL,yEAAsC,MAAM,EAAE,SAAS,EAAE,SAAS;QAChE,oBAAC,MAAM,IACL,GAAG,EAAE,SAAS,EACd,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,gBACA,SAAS,EACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EACtC,sBAAsB,EAAE,CAAC,QAAQ,EAAE,EAAE;gBACnC,MAAM,UAAU,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAA;gBAElD,OAAO,CACL,oBAAC,KAAK,IACJ,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,kCACS,KAAK,EAClC,KAAK,EAAE;wBACL,QAAQ,EAAE,UAAU;wBACpB,IAAI,EAAE,QAAQ,UAAU,QAAQ,CAAC,GAAG,UAAU,GAAG,GAAG,MAAM;qBAC3D,GACD,CACH,CAAA;YACH,CAAC,EACD,sBAAsB,EAAE,CAAC,QAAQ,EAAE,EAAE;gBACnC,MAAM,UAAU,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAA;gBAElD,OAAO,CACL,oBAAC,KAAK,IACJ,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,QAAQ,kCACc,KAAK,EAClC,KAAK,EAAE;wBACL,QAAQ,EAAE,UAAU;wBACpB,IAAI,EAAE,QAAQ,UAAU,QAAQ,CAAC,GAAG,UAAU,GAAG,GAAG,MAAM;qBAC3D,GACD,CACH,CAAA;YACH,CAAC,GACD,CACE,CACP,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,UAAU,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ export { default as Link } from './components/atoms/Link';
|
|
|
3
3
|
export type { LinkProps } from './components/atoms/Link';
|
|
4
4
|
export { default as Popover } from './components/atoms/Popover';
|
|
5
5
|
export type { PopoverProps } from './components/atoms/Popover';
|
|
6
|
-
export { default as Price } from './components/atoms/Price';
|
|
7
|
-
export type { PriceProps } from './components/atoms/Price';
|
|
8
6
|
export { default as TextArea } from './components/atoms/TextArea';
|
|
9
7
|
export type { TextAreaProps } from './components/atoms/TextArea';
|
|
10
8
|
export { default as Select } from './components/atoms/Select';
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@ export * from '@faststore/components';
|
|
|
2
2
|
// Atoms
|
|
3
3
|
export { default as Link } from './components/atoms/Link';
|
|
4
4
|
export { default as Popover } from './components/atoms/Popover';
|
|
5
|
-
export { default as Price } from './components/atoms/Price';
|
|
6
5
|
export { default as TextArea } from './components/atoms/TextArea';
|
|
7
6
|
export { default as Select } from './components/atoms/Select';
|
|
8
7
|
export { default as Slider } from './components/atoms/Slider';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AAErC,QAAQ;AACR,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,yBAAyB,CAAA;AAGzD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAG/D,OAAO,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/ui",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9-alpha.0",
|
|
4
4
|
"description": "A lightweight, framework agnostic component library for React",
|
|
5
5
|
"author": "emersonlaurentino",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@babel/core": "^7.19.6",
|
|
52
52
|
"@faststore/shared": "^2.0.3-alpha.0",
|
|
53
|
-
"@faststore/styles": "^2.0.
|
|
53
|
+
"@faststore/styles": "^2.0.9-alpha.0",
|
|
54
54
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
55
55
|
"@storybook/addon-a11y": "^6.5.13",
|
|
56
56
|
"@storybook/addon-actions": "^6.5.13",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"node": "16.18.0",
|
|
79
79
|
"yarn": "1.19.1"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "df3ddd2d140bf19046a4753474bebee4298cd6ac"
|
|
82
82
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[data-fs-price] {
|
|
2
|
+
// --------------------------------------------------------
|
|
3
|
+
// Design Tokens for Price
|
|
4
|
+
// --------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
// Listing
|
|
7
|
+
--fs-price-listing-color : var(--fs-color-text-light);
|
|
8
|
+
--fs-price-listing-text-decoration : line-through;
|
|
9
|
+
|
|
10
|
+
// Spot
|
|
11
|
+
--fs-price-spot-margin-left : var(--fs-spacing-1);
|
|
12
|
+
--fs-price-spot-font-weight : var(--fs-text-weight-bold);
|
|
13
|
+
|
|
14
|
+
// --------------------------------------------------------
|
|
15
|
+
// Variants Styles
|
|
16
|
+
// --------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
&[data-fs-price-variant="listing"] {
|
|
19
|
+
color: var(--fs-price-listing-color);
|
|
20
|
+
text-decoration: var(--fs-price-listing-text-decoration);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&[data-fs-price-variant="spot"] {
|
|
24
|
+
margin-left: var(--fs-price-spot-margin-left);
|
|
25
|
+
font-weight: var(--fs-price-spot-font-weight);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'
|
|
2
|
+
|
|
3
|
+
import { DiscountBadge } from '@faststore/components'
|
|
4
|
+
|
|
5
|
+
<Meta title="Molecules/DiscountBadge" component={DiscountBadge} argTypes={{}} />
|
|
6
|
+
|
|
7
|
+
export const Template = (args) => (
|
|
8
|
+
<DiscountBadge id="discount-badge-id" listPrice={65} spotPrice={40} />
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
<header>
|
|
12
|
+
|
|
13
|
+
# DiscountBadge
|
|
14
|
+
|
|
15
|
+
A custom `Badge` that display product's discounts.
|
|
16
|
+
|
|
17
|
+
</header>
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
import { DiscountBadge } from '@faststore/ui'
|
|
23
|
+
// Styles
|
|
24
|
+
import '@faststore/ui/src/components/molecules/DiscountBadge/styles.scss'
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
<Canvas>
|
|
28
|
+
<Story
|
|
29
|
+
name="default"
|
|
30
|
+
args={{
|
|
31
|
+
id: 'discount-badge-default',
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
{Template.bind({})}
|
|
35
|
+
</Story>
|
|
36
|
+
</Canvas>
|
|
37
|
+
|
|
38
|
+
<ArgsTable story="default" />
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[data-fs-discount-badge] {
|
|
2
|
+
// --------------------------------------------------------
|
|
3
|
+
// Design Tokens for Discount Badge
|
|
4
|
+
// --------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
// Low
|
|
7
|
+
--fs-discount-badge-low-bkg-color : var(--fs-badge-success-bkg-color);
|
|
8
|
+
--fs-discount-badge-low-text-color : var(--fs-badge-success-text-color);
|
|
9
|
+
--fs-discount-badge-low-border-color : var(--fs-badge-success-border-color);
|
|
10
|
+
|
|
11
|
+
// Medium
|
|
12
|
+
--fs-discount-badge-medium-bkg-color : var(--fs-badge-warning-bkg-color);
|
|
13
|
+
--fs-discount-badge-medium-text-color : var(--fs-badge-warning-text-color);
|
|
14
|
+
--fs-discount-badge-medium-border-color : var(--fs-badge-warning-border-color);
|
|
15
|
+
|
|
16
|
+
// High
|
|
17
|
+
--fs-discount-badge-high-bkg-color : var(--fs-badge-danger-bkg-color);
|
|
18
|
+
--fs-discount-badge-high-text-color : var(--fs-badge-danger-text-color);
|
|
19
|
+
--fs-discount-badge-high-border-color : var(--fs-badge-danger-border-color);
|
|
20
|
+
|
|
21
|
+
// --------------------------------------------------------
|
|
22
|
+
// Variants Styles
|
|
23
|
+
// --------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
&[data-fs-discount-badge-variant="low"] {
|
|
26
|
+
color: var(--fs-discount-badge-low-text-color);
|
|
27
|
+
|
|
28
|
+
[data-fs-badge-wrapper] {
|
|
29
|
+
background-color: var(--fs-discount-badge-low-bkg-color);
|
|
30
|
+
border-color: var(--fs-discount-badge-low-border-color);
|
|
31
|
+
|
|
32
|
+
&::after {
|
|
33
|
+
background-color: var(--fs-discount-badge-low-bkg-color);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&[data-fs-discount-badge-variant="medium"] {
|
|
39
|
+
color: var(--fs-discount-badge-medium-text-color);
|
|
40
|
+
|
|
41
|
+
[data-fs-badge-wrapper] {
|
|
42
|
+
background-color: var(--fs-discount-badge-medium-bkg-color);
|
|
43
|
+
border-color: var(--fs-discount-badge-medium-border-color);
|
|
44
|
+
&::after { background-color: var(--fs-discount-badge-medium-bkg-color); }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&[data-fs-discount-badge-variant="high"] {
|
|
49
|
+
color: var(--fs-discount-badge-high-text-color);
|
|
50
|
+
|
|
51
|
+
[data-fs-badge-wrapper] {
|
|
52
|
+
background-color: var(--fs-discount-badge-high-bkg-color);
|
|
53
|
+
border-color: var(--fs-discount-badge-high-border-color);
|
|
54
|
+
&::after { background-color: var(--fs-discount-badge-high-bkg-color); }
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { Story, Meta } from '@storybook/react'
|
|
2
2
|
import React, { useMemo } from 'react'
|
|
3
3
|
|
|
4
|
-
import Badge from '@faststore/components'
|
|
5
|
-
import Price from '../../../atoms/Price/Price'
|
|
4
|
+
import { Badge, Price } from '@faststore/components'
|
|
6
5
|
// Gift components
|
|
7
6
|
import GiftComponent from '../Gift'
|
|
8
7
|
import GiftContent from '../GiftContent'
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React, { useRef, useImperativeHandle, forwardRef } from 'react'
|
|
2
2
|
import type { AriaAttributes } from 'react'
|
|
3
3
|
|
|
4
|
-
import Price from '
|
|
4
|
+
import { Price } from '@faststore/components'
|
|
5
|
+
import type { PriceProps } from '@faststore/components'
|
|
6
|
+
|
|
5
7
|
import Slider from '../../atoms/Slider'
|
|
6
|
-
import type { PriceProps } from '../../atoms/Price'
|
|
7
8
|
import type { SliderProps } from '../../atoms/Slider'
|
|
8
9
|
|
|
9
10
|
export type PriceRangeProps = SliderProps & {
|
|
@@ -2,8 +2,7 @@ import type { Story, Meta } from '@storybook/react'
|
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
4
|
// Atoms
|
|
5
|
-
import Price from '
|
|
6
|
-
import { Badge, Button } from '@faststore/components'
|
|
5
|
+
import { Badge, Button, Price } from '@faststore/components'
|
|
7
6
|
// Card components
|
|
8
7
|
import ProductCardComponent from '../ProductCard'
|
|
9
8
|
import ProductCardImage from '../ProductCardImage'
|
package/src/index.ts
CHANGED
|
@@ -7,9 +7,6 @@ export type { LinkProps } from './components/atoms/Link'
|
|
|
7
7
|
export { default as Popover } from './components/atoms/Popover'
|
|
8
8
|
export type { PopoverProps } from './components/atoms/Popover'
|
|
9
9
|
|
|
10
|
-
export { default as Price } from './components/atoms/Price'
|
|
11
|
-
export type { PriceProps } from './components/atoms/Price'
|
|
12
|
-
|
|
13
10
|
export { default as TextArea } from './components/atoms/TextArea'
|
|
14
11
|
export type { TextAreaProps } from './components/atoms/TextArea'
|
|
15
12
|
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
@import "../components/atoms/Checkbox/styles";
|
|
5
5
|
@import "../components/atoms/Input/styles";
|
|
6
6
|
@import "../components/atoms/Overlay/styles";
|
|
7
|
+
@import "../components/atoms/Price/styles";
|
|
7
8
|
@import "../components/atoms/Radio/styles";
|
|
8
9
|
|
|
9
10
|
// Molecules
|
|
10
11
|
@import "../components/molecules/CheckboxField/styles";
|
|
12
|
+
@import "../components/molecules/DiscountBadge/styles";
|
|
11
13
|
@import "../components/molecules/InputField/styles";
|
|
12
14
|
@import "../components/molecules/RadioField/styles";
|
|
13
15
|
@import "../components/molecules/Tag/styles";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { HTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
export declare type PriceVariant = 'selling' | 'listing' | 'spot' | 'savings' | 'installment';
|
|
4
|
-
export declare type PriceFormatter = (price: number, variant: PriceVariant) => ReactNode;
|
|
5
|
-
export interface PriceProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
|
|
6
|
-
/**
|
|
7
|
-
* Set the HTML element tag of this component.
|
|
8
|
-
*/
|
|
9
|
-
as?: ElementType;
|
|
10
|
-
/**
|
|
11
|
-
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
12
|
-
*/
|
|
13
|
-
testId?: string;
|
|
14
|
-
/**
|
|
15
|
-
* The raw price value.
|
|
16
|
-
*/
|
|
17
|
-
value: number;
|
|
18
|
-
/**
|
|
19
|
-
* Formatter function that transforms the raw price value and render the result.
|
|
20
|
-
*/
|
|
21
|
-
formatter?: PriceFormatter;
|
|
22
|
-
/**
|
|
23
|
-
* The current use case variant for prices.
|
|
24
|
-
*/
|
|
25
|
-
variant?: PriceVariant;
|
|
26
|
-
}
|
|
27
|
-
export declare const Price: React.ForwardRefExoticComponent<PriceProps & React.RefAttributes<Omit<HTMLSpanElement, "children">>>;
|
|
28
|
-
export default Price;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
export const Price = forwardRef(function Price({ as: Component = 'span', testId = 'store-price', value, formatter = (price) => price, variant = 'selling', ...otherProps }, ref) {
|
|
3
|
-
const formattedPrice = formatter(value, variant);
|
|
4
|
-
return (React.createElement(Component, Object.assign({ ref: ref, "data-fs-price": true, "data-testid": testId, "data-variant": variant }, otherProps), formattedPrice));
|
|
5
|
-
});
|
|
6
|
-
export default Price;
|
|
7
|
-
//# sourceMappingURL=Price.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Price.js","sourceRoot":"","sources":["../../../../src/components/atoms/Price/Price.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAmCzC,MAAM,CAAC,MAAM,KAAK,GAAG,UAAU,CAC7B,SAAS,KAAK,CACZ,EACE,EAAE,EAAE,SAAS,GAAG,MAAM,EACtB,MAAM,GAAG,aAAa,EACtB,KAAK,EACL,SAAS,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAC5B,OAAO,GAAG,SAAS,EACnB,GAAG,UAAU,EACd,EACD,GAAG;IAEH,MAAM,cAAc,GAAG,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAEhD,OAAO,CACL,oBAAC,SAAS,kBACR,GAAG,EAAE,GAAG,wCAEK,MAAM,kBACL,OAAO,IACjB,UAAU,GAEb,cAAc,CACL,CACb,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,KAAK,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/atoms/Price/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { HTMLAttributes, ElementType, ReactNode } from 'react'
|
|
2
|
-
import React, { forwardRef } from 'react'
|
|
3
|
-
|
|
4
|
-
export type PriceVariant =
|
|
5
|
-
| 'selling'
|
|
6
|
-
| 'listing'
|
|
7
|
-
| 'spot'
|
|
8
|
-
| 'savings'
|
|
9
|
-
| 'installment'
|
|
10
|
-
|
|
11
|
-
export type PriceFormatter = (price: number, variant: PriceVariant) => ReactNode
|
|
12
|
-
|
|
13
|
-
export interface PriceProps
|
|
14
|
-
extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
|
|
15
|
-
/**
|
|
16
|
-
* Set the HTML element tag of this component.
|
|
17
|
-
*/
|
|
18
|
-
as?: ElementType
|
|
19
|
-
/**
|
|
20
|
-
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
21
|
-
*/
|
|
22
|
-
testId?: string
|
|
23
|
-
/**
|
|
24
|
-
* The raw price value.
|
|
25
|
-
*/
|
|
26
|
-
value: number
|
|
27
|
-
/**
|
|
28
|
-
* Formatter function that transforms the raw price value and render the result.
|
|
29
|
-
*/
|
|
30
|
-
formatter?: PriceFormatter
|
|
31
|
-
/**
|
|
32
|
-
* The current use case variant for prices.
|
|
33
|
-
*/
|
|
34
|
-
variant?: PriceVariant
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const Price = forwardRef<Omit<HTMLSpanElement, 'children'>, PriceProps>(
|
|
38
|
-
function Price(
|
|
39
|
-
{
|
|
40
|
-
as: Component = 'span',
|
|
41
|
-
testId = 'store-price',
|
|
42
|
-
value,
|
|
43
|
-
formatter = (price) => price,
|
|
44
|
-
variant = 'selling',
|
|
45
|
-
...otherProps
|
|
46
|
-
},
|
|
47
|
-
ref
|
|
48
|
-
) {
|
|
49
|
-
const formattedPrice = formatter(value, variant)
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<Component
|
|
53
|
-
ref={ref}
|
|
54
|
-
data-fs-price
|
|
55
|
-
data-testid={testId}
|
|
56
|
-
data-variant={variant}
|
|
57
|
-
{...otherProps}
|
|
58
|
-
>
|
|
59
|
-
{formattedPrice}
|
|
60
|
-
</Component>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
export default Price
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs'
|
|
2
|
-
import Price from '../Price'
|
|
3
|
-
|
|
4
|
-
# Price
|
|
5
|
-
|
|
6
|
-
## Default
|
|
7
|
-
|
|
8
|
-
<Canvas>
|
|
9
|
-
<Story id="atoms-price--default" />
|
|
10
|
-
</Canvas>
|
|
11
|
-
|
|
12
|
-
## INTL Formatted
|
|
13
|
-
|
|
14
|
-
<Canvas>
|
|
15
|
-
<Story id="atoms-price--intl-formatted" />
|
|
16
|
-
</Canvas>
|
|
17
|
-
|
|
18
|
-
## INTL Formatted to parts
|
|
19
|
-
|
|
20
|
-
<Canvas>
|
|
21
|
-
<Story id="atoms-price--intl-formatted-to-parts" />
|
|
22
|
-
</Canvas>
|
|
23
|
-
|
|
24
|
-
## Custom
|
|
25
|
-
|
|
26
|
-
<Canvas>
|
|
27
|
-
<Story id="atoms-price--custom" />
|
|
28
|
-
</Canvas>
|
|
29
|
-
|
|
30
|
-
## Props
|
|
31
|
-
|
|
32
|
-
<ArgsTable of={Price} />
|
|
33
|
-
|
|
34
|
-
## CSS Selectors
|
|
35
|
-
|
|
36
|
-
```css
|
|
37
|
-
[data-fs-price] {}
|
|
38
|
-
|
|
39
|
-
[data-variant='('selling'|'listing'|'spot'|'savings'|'installment')'] {}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Formatter function example
|
|
43
|
-
|
|
44
|
-
```jsx
|
|
45
|
-
function customFormatter(price: number) {
|
|
46
|
-
const unformattedPrice = `${price}`
|
|
47
|
-
const formattedPrice = `${unformattedPrice.replace('.', ',')} reais`
|
|
48
|
-
|
|
49
|
-
return formattedPrice
|
|
50
|
-
},
|
|
51
|
-
```
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react'
|
|
2
|
-
import type { Story } from '@storybook/react'
|
|
3
|
-
|
|
4
|
-
import Component from '../Price'
|
|
5
|
-
import type { PriceProps } from '../Price'
|
|
6
|
-
import mdx from './Price.mdx'
|
|
7
|
-
import type { ComponentArgTypes } from '../../../../typings/utils'
|
|
8
|
-
|
|
9
|
-
const priceValue = 62.5
|
|
10
|
-
|
|
11
|
-
const PriceTemplate: Story<PriceProps> = ({ value, variant }) => (
|
|
12
|
-
<Component value={value} variant={variant} />
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
export const Default = PriceTemplate.bind({})
|
|
16
|
-
Default.args = {
|
|
17
|
-
value: priceValue,
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const INTLFormattedTemplate: Story<PriceProps> = ({ value, variant }) => {
|
|
21
|
-
function useIntlFormatter(price: number) {
|
|
22
|
-
return useMemo(() => {
|
|
23
|
-
const formattedPrice = new Intl.NumberFormat('en-GB', {
|
|
24
|
-
style: 'currency',
|
|
25
|
-
currency: 'EUR',
|
|
26
|
-
}).format(price)
|
|
27
|
-
|
|
28
|
-
return formattedPrice
|
|
29
|
-
}, [price])
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<Component formatter={useIntlFormatter} value={value} variant={variant} />
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const INTLFormatted = INTLFormattedTemplate.bind({})
|
|
38
|
-
INTLFormatted.args = {
|
|
39
|
-
value: priceValue,
|
|
40
|
-
variant: 'spot',
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const INTLFormattedToPartsTemplate: Story<PriceProps> = ({
|
|
44
|
-
value,
|
|
45
|
-
variant,
|
|
46
|
-
}) => {
|
|
47
|
-
function useIntlPartsFormatter(price: number) {
|
|
48
|
-
return useMemo(() => {
|
|
49
|
-
return new Intl.NumberFormat('en-US', {
|
|
50
|
-
style: 'currency',
|
|
51
|
-
currency: 'USD',
|
|
52
|
-
})
|
|
53
|
-
.formatToParts(price)
|
|
54
|
-
.map((part) => {
|
|
55
|
-
const props = {
|
|
56
|
-
[`data-fs-price-${part.type}`]: true,
|
|
57
|
-
} as Record<string, unknown>
|
|
58
|
-
|
|
59
|
-
if (part.type === 'integer') {
|
|
60
|
-
props.style = { fontWeight: 700 }
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<span key={part.type} {...props}>
|
|
65
|
-
{part.value}
|
|
66
|
-
</span>
|
|
67
|
-
)
|
|
68
|
-
})
|
|
69
|
-
}, [price])
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<Component
|
|
74
|
-
formatter={useIntlPartsFormatter}
|
|
75
|
-
value={value}
|
|
76
|
-
variant={variant}
|
|
77
|
-
/>
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const INTLFormattedToParts = INTLFormattedToPartsTemplate.bind({})
|
|
82
|
-
INTLFormattedToParts.args = {
|
|
83
|
-
value: priceValue,
|
|
84
|
-
variant: 'selling',
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export const Custom: Story<PriceProps> = ({ value, variant }) => {
|
|
88
|
-
function customFormatter(price: number) {
|
|
89
|
-
const unformattedPrice = `${price}`
|
|
90
|
-
const formattedPrice = `${unformattedPrice.replace('.', ',')} reais`
|
|
91
|
-
|
|
92
|
-
return formattedPrice
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<Component formatter={customFormatter} value={value} variant={variant} />
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
Custom.args = {
|
|
101
|
-
value: priceValue,
|
|
102
|
-
variant: 'savings',
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const argTypes: ComponentArgTypes<Omit<PriceProps, 'value'>> = {
|
|
106
|
-
variant: {
|
|
107
|
-
options: ['selling', 'listing', 'spot', 'savings', 'installment'],
|
|
108
|
-
control: { type: 'select' },
|
|
109
|
-
},
|
|
110
|
-
formatter: {
|
|
111
|
-
table: { disable: true },
|
|
112
|
-
},
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export default {
|
|
116
|
-
title: 'Atoms/Price',
|
|
117
|
-
argTypes,
|
|
118
|
-
parameters: {
|
|
119
|
-
docs: {
|
|
120
|
-
page: mdx,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
}
|