@faststore/ui 1.3.16 → 1.3.20
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 +41 -0
- package/dist/index.d.ts +6 -0
- package/dist/molecules/Alert/Alert.d.ts +11 -0
- package/dist/molecules/Alert/index.d.ts +2 -0
- package/dist/molecules/Alert/stories/Alert.stories.d.ts +5 -0
- package/dist/molecules/Banner/Banner.d.ts +13 -0
- package/dist/molecules/Banner/BannerContent.d.ts +10 -0
- package/dist/molecules/Banner/BannerImage.d.ts +10 -0
- package/dist/molecules/Banner/BannerLink.d.ts +10 -0
- package/dist/molecules/Banner/index.d.ts +8 -0
- package/dist/molecules/Banner/stories/Banner.stories.d.ts +4 -0
- package/dist/molecules/PaymentMethods/PaymentMethods.d.ts +26 -0
- package/dist/molecules/PaymentMethods/index.d.ts +2 -0
- package/dist/molecules/PaymentMethods/stories/PaymentMethods.stories.d.ts +4 -0
- package/dist/molecules/PaymentMethods/stories/assets/Icons.d.ts +9 -0
- package/dist/ui.cjs.development.js +47 -0
- package/dist/ui.cjs.development.js.map +1 -1
- package/dist/ui.cjs.production.min.js +1 -1
- package/dist/ui.cjs.production.min.js.map +1 -1
- package/dist/ui.esm.js +45 -1
- package/dist/ui.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +9 -0
- package/src/molecules/Alert/Alert.test.tsx +23 -0
- package/src/molecules/Alert/Alert.tsx +30 -0
- package/src/molecules/Alert/index.ts +2 -0
- package/src/molecules/Alert/stories/Alert.mdx +26 -0
- package/src/molecules/Alert/stories/Alert.stories.tsx +36 -0
- package/src/molecules/Banner/Banner.test.tsx +63 -0
- package/src/molecules/Banner/Banner.tsx +26 -0
- package/src/molecules/Banner/BannerContent.tsx +31 -0
- package/src/molecules/Banner/BannerImage.tsx +29 -0
- package/src/molecules/Banner/BannerLink.tsx +29 -0
- package/src/molecules/Banner/index.ts +11 -0
- package/src/molecules/Banner/stories/Banner.mdx +63 -0
- package/src/molecules/Banner/stories/Banner.stories.tsx +66 -0
- package/src/molecules/PaymentMethods/PaymentMethods.test.tsx +37 -0
- package/src/molecules/PaymentMethods/PaymentMethods.tsx +58 -0
- package/src/molecules/PaymentMethods/index.tsx +2 -0
- package/src/molecules/PaymentMethods/stories/PaymentMethods.mdx +19 -0
- package/src/molecules/PaymentMethods/stories/PaymentMethods.stories.tsx +41 -0
- package/src/molecules/PaymentMethods/stories/assets/Icons.tsx +89 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Meta, Story } from '@storybook/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import type { AlertProps } from '../Alert'
|
|
5
|
+
import Component from '../Alert'
|
|
6
|
+
import ShoppingCartIcon from '../../../atoms/Icon/stories/assets/ShoppingCart'
|
|
7
|
+
import mdx from './Alert.mdx'
|
|
8
|
+
import { Icon } from '../../..'
|
|
9
|
+
|
|
10
|
+
const AlertTemplate: Story<AlertProps> = ({ children }) => (
|
|
11
|
+
<Component>{children}</Component>
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
export const Alert = AlertTemplate.bind({})
|
|
15
|
+
Alert.args = {
|
|
16
|
+
children: 'Alert',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const AlertWithIcon = AlertTemplate.bind({})
|
|
20
|
+
AlertWithIcon.args = {
|
|
21
|
+
children: (
|
|
22
|
+
<>
|
|
23
|
+
<Icon component={<ShoppingCartIcon />} />
|
|
24
|
+
<span>Alert</span>
|
|
25
|
+
</>
|
|
26
|
+
),
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
title: 'Molecules/Alert',
|
|
31
|
+
parameters: {
|
|
32
|
+
docs: {
|
|
33
|
+
page: mdx,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
} as Meta
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { render } from '@testing-library/react'
|
|
2
|
+
import { axe } from 'jest-axe'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
import Banner from './Banner'
|
|
6
|
+
import BannerImage from './BannerImage'
|
|
7
|
+
import BannerContent from './BannerContent'
|
|
8
|
+
import BannerLink from './BannerLink'
|
|
9
|
+
|
|
10
|
+
const BannerTest = () => {
|
|
11
|
+
return (
|
|
12
|
+
<Banner>
|
|
13
|
+
<BannerImage>
|
|
14
|
+
<img
|
|
15
|
+
alt="A person with hands on the pocket, carrying a round straw bag"
|
|
16
|
+
src="https://storecomponents.vtex.app/assets/fit-in/1280x613/center/middle/https%3A%2F%2Fstorecomponents.vtexassets.com%2Fassets%2Fvtex.file-manager-graphql%2Fimages%2Fedce348c-068c-4fb9-91f2-7d235d596e0f___b2822f893b14f87337d08f07f0e520ab.jpg"
|
|
17
|
+
/>
|
|
18
|
+
</BannerImage>
|
|
19
|
+
<BannerContent>
|
|
20
|
+
<div>
|
|
21
|
+
<h3>Get yo know our next release</h3>
|
|
22
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
|
23
|
+
</div>
|
|
24
|
+
<BannerLink>Shop now</BannerLink>
|
|
25
|
+
</BannerContent>
|
|
26
|
+
</Banner>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
describe('Banner', () => {
|
|
31
|
+
describe('Data attributes', () => {
|
|
32
|
+
const { getByTestId } = render(<BannerTest />)
|
|
33
|
+
|
|
34
|
+
const banner = getByTestId('store-banner')
|
|
35
|
+
const bannerImage = getByTestId('store-banner-image')
|
|
36
|
+
const bannerContent = getByTestId('store-banner-content')
|
|
37
|
+
const bannerLink = getByTestId('store-banner-link')
|
|
38
|
+
|
|
39
|
+
it('`Banner` component should have `data-store-banner` attribute', () => {
|
|
40
|
+
expect(banner).toHaveAttribute('data-store-banner')
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('`BannerImage` component should have `data-store-banner-image` attribute', () => {
|
|
44
|
+
expect(bannerImage).toHaveAttribute('data-store-banner-image')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it('`BannerContent` component should have `data-store-banner-content` attribute', () => {
|
|
48
|
+
expect(bannerContent).toHaveAttribute('data-store-banner-content')
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('`BannerLink` component should have `data-store-banner-link` attribute', () => {
|
|
52
|
+
expect(bannerLink).toHaveAttribute('data-store-banner-link')
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
describe('Accessibility', () => {
|
|
57
|
+
it('should have no violations', async () => {
|
|
58
|
+
const { getByTestId } = render(<BannerTest />)
|
|
59
|
+
|
|
60
|
+
expect(await axe(getByTestId('store-banner'))).toHaveNoViolations()
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
type BannerDirectionVariant = 'vertical' | 'horizontal'
|
|
4
|
+
export interface BannerProps {
|
|
5
|
+
/**
|
|
6
|
+
* ID to find this component in testing tools (e.g.: cypress,
|
|
7
|
+
* testing-library, and jest).
|
|
8
|
+
*/
|
|
9
|
+
testId?: string
|
|
10
|
+
children: React.ReactNode
|
|
11
|
+
variant?: BannerDirectionVariant
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Banner = ({
|
|
15
|
+
testId = 'store-banner',
|
|
16
|
+
children,
|
|
17
|
+
variant = 'vertical',
|
|
18
|
+
}: BannerProps) => {
|
|
19
|
+
return (
|
|
20
|
+
<article data-store-banner={variant} data-testid={testId}>
|
|
21
|
+
{children}
|
|
22
|
+
</article>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default Banner
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface BannerContentProps
|
|
5
|
+
extends Omit<HTMLAttributes<HTMLDivElement>, 'role'> {
|
|
6
|
+
/**
|
|
7
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
8
|
+
*/
|
|
9
|
+
testId?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const BannerContent = forwardRef<HTMLDivElement, BannerContentProps>(
|
|
13
|
+
function BannerContent(
|
|
14
|
+
{ testId = 'store-banner-content', children, ...otherProps },
|
|
15
|
+
ref
|
|
16
|
+
) {
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
ref={ref}
|
|
20
|
+
role="region"
|
|
21
|
+
data-store-banner-content
|
|
22
|
+
data-testid={testId}
|
|
23
|
+
{...otherProps}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</div>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
export default BannerContent
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface BannerImageProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
7
|
+
*/
|
|
8
|
+
testId?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const BannerImage = forwardRef<HTMLDivElement, BannerImageProps>(
|
|
12
|
+
function BannerImage(
|
|
13
|
+
{ testId = 'store-banner-image', children, ...otherProps },
|
|
14
|
+
ref
|
|
15
|
+
) {
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
ref={ref}
|
|
19
|
+
data-store-banner-image
|
|
20
|
+
data-testid={testId}
|
|
21
|
+
{...otherProps}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
export default BannerImage
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface BannerLinkProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
7
|
+
*/
|
|
8
|
+
testId?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const BannerLink = forwardRef<HTMLDivElement, BannerLinkProps>(
|
|
12
|
+
function BannerLink(
|
|
13
|
+
{ testId = 'store-banner-link', children, ...otherProps },
|
|
14
|
+
ref
|
|
15
|
+
) {
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
ref={ref}
|
|
19
|
+
data-store-banner-link
|
|
20
|
+
data-testid={testId}
|
|
21
|
+
{...otherProps}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
export default BannerLink
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { default } from './Banner'
|
|
2
|
+
export type { BannerProps } from './Banner'
|
|
3
|
+
|
|
4
|
+
export { default as BannerImage } from './BannerImage'
|
|
5
|
+
export type { BannerImageProps } from './BannerImage'
|
|
6
|
+
|
|
7
|
+
export { default as BannerContent } from './BannerContent'
|
|
8
|
+
export type { BannerContentProps } from './BannerContent'
|
|
9
|
+
|
|
10
|
+
export { default as BannerLink } from './BannerLink'
|
|
11
|
+
export type { BannerLinkProps } from './BannerLink'
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Canvas, Props, Story, ArgsTable } from '@storybook/addon-docs'
|
|
2
|
+
|
|
3
|
+
import Banner from '../Banner'
|
|
4
|
+
import BannerImage from '../BannerImage'
|
|
5
|
+
import BannerContent from '../BannerContent'
|
|
6
|
+
import BannerLink from '../BannerLink'
|
|
7
|
+
|
|
8
|
+
# Banner
|
|
9
|
+
|
|
10
|
+
<Canvas>
|
|
11
|
+
<Story id="molecules-banner--banner" />
|
|
12
|
+
</Canvas>
|
|
13
|
+
|
|
14
|
+
## Components
|
|
15
|
+
|
|
16
|
+
The `Banner` uses the [Compound Component](https://kentcdodds.com/blog/compound-components-with-react-hooks) pattern, its components are:
|
|
17
|
+
|
|
18
|
+
- `Banner`: the wrapper component, it can receive a `variant` prop to set its direction, supports `"vertical"` and `"horizontal"` values.
|
|
19
|
+
- `BannerImage`: the component that wraps the image displayed in the component.
|
|
20
|
+
- `BannerContent`: the component that can receive a title, description, and a `BannerLink`.
|
|
21
|
+
- `BannerLink`: the banner's call-to-action link.
|
|
22
|
+
|
|
23
|
+
## Props
|
|
24
|
+
|
|
25
|
+
All banner-related components support all attributes also supported by the `<div>` tag.
|
|
26
|
+
|
|
27
|
+
Besides those attributes, the following props are also supported:
|
|
28
|
+
|
|
29
|
+
### `Banner`
|
|
30
|
+
|
|
31
|
+
<ArgsTable of={Banner} />
|
|
32
|
+
|
|
33
|
+
### `BannerImage`
|
|
34
|
+
|
|
35
|
+
<ArgsTable of={BannerImage} />
|
|
36
|
+
|
|
37
|
+
### `BannerContent`
|
|
38
|
+
|
|
39
|
+
<ArgsTable of={BannerContent} />
|
|
40
|
+
|
|
41
|
+
### `BannerLink`
|
|
42
|
+
|
|
43
|
+
<ArgsTable of={BannerLink} />
|
|
44
|
+
|
|
45
|
+
## Guidelines
|
|
46
|
+
|
|
47
|
+
- Don’t hide important information in an image. If there is some important information, add it as text instead. For more information, see [Images Concepts • Images • WAI Web Accessibility Tutorials](https://www.w3.org/WAI/tutorials/images/)
|
|
48
|
+
- Use understandable links (avoid generic meaning, i.e., click here). For more information, see [Link Purpose](https://www.w3.org/WAI/WCAG21/Understanding/link-purpose-in-context.html)
|
|
49
|
+
|
|
50
|
+
## CSS Selectors
|
|
51
|
+
|
|
52
|
+
```css
|
|
53
|
+
[data-store-banner] {
|
|
54
|
+
}
|
|
55
|
+
[data-store-banner=('vertical'|'horizontal')] {
|
|
56
|
+
}
|
|
57
|
+
[data-store-banner-image] {
|
|
58
|
+
}
|
|
59
|
+
[data-store-banner-content] {
|
|
60
|
+
}
|
|
61
|
+
[data-store-banner-link] {
|
|
62
|
+
}
|
|
63
|
+
```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Story, Meta } from '@storybook/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import BannerComponent from '../Banner'
|
|
5
|
+
import BannerImage from '../BannerImage'
|
|
6
|
+
import BannerContent from '../BannerContent'
|
|
7
|
+
import BannerLink from '../BannerLink'
|
|
8
|
+
import type { BannerProps } from '../Banner'
|
|
9
|
+
import { Icon } from '../../..'
|
|
10
|
+
import mdx from './Banner.mdx'
|
|
11
|
+
|
|
12
|
+
const RightArrow = () => (
|
|
13
|
+
<svg
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
width="18"
|
|
16
|
+
height="18"
|
|
17
|
+
viewBox="0 0 18 18"
|
|
18
|
+
>
|
|
19
|
+
<path
|
|
20
|
+
d="M10.6553 3.40717C10.3624 3.11428 9.88756 3.11428 9.59467 3.40717C9.30178 3.70006 9.30178 4.17494 9.59467 4.46783L13.3768 8.25H2.8125C2.39829 8.25 2.0625 8.58579 2.0625 9C2.0625 9.41421 2.39829 9.75 2.8125 9.75H13.3768L9.59467 13.5322C9.30178 13.8251 9.30178 14.2999 9.59467 14.5928C9.88756 14.8857 10.3624 14.8857 10.6553 14.5928L15.7178 9.53033C15.8643 9.38388 15.9375 9.19194 15.9375 9C15.9375 8.89831 15.9173 8.80134 15.8806 8.71291C15.844 8.62445 15.7897 8.54158 15.7178 8.46967L10.6553 3.40717Z"
|
|
21
|
+
fill="currentColor"
|
|
22
|
+
/>
|
|
23
|
+
</svg>
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
const BannerTemplate: Story<BannerProps> = ({ testId, variant }) => (
|
|
27
|
+
<BannerComponent testId={testId} variant={variant}>
|
|
28
|
+
<BannerImage>
|
|
29
|
+
<img
|
|
30
|
+
alt="A person with hands on the pocket, carrying a round straw bag"
|
|
31
|
+
src="https://storecomponents.vtex.app/assets/fit-in/1280x613/center/middle/https%3A%2F%2Fstorecomponents.vtexassets.com%2Fassets%2Fvtex.file-manager-graphql%2Fimages%2Fedce348c-068c-4fb9-91f2-7d235d596e0f___b2822f893b14f87337d08f07f0e520ab.jpg"
|
|
32
|
+
/>
|
|
33
|
+
</BannerImage>
|
|
34
|
+
<BannerContent>
|
|
35
|
+
<div>
|
|
36
|
+
<h3>Get to know our new release</h3>
|
|
37
|
+
<p>Your one-stop shop for making this summer season the best of all.</p>
|
|
38
|
+
</div>
|
|
39
|
+
<BannerLink>
|
|
40
|
+
<a href="/">
|
|
41
|
+
Shop now <Icon component={<RightArrow />} />
|
|
42
|
+
</a>
|
|
43
|
+
</BannerLink>
|
|
44
|
+
</BannerContent>
|
|
45
|
+
</BannerComponent>
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
export const Banner = BannerTemplate.bind({})
|
|
49
|
+
Banner.storyName = 'Banner'
|
|
50
|
+
|
|
51
|
+
const argTypes = {
|
|
52
|
+
variant: {
|
|
53
|
+
options: ['vertical', 'horizontal'],
|
|
54
|
+
control: { type: 'select' },
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default {
|
|
59
|
+
title: 'Molecules/Banner',
|
|
60
|
+
argTypes,
|
|
61
|
+
parameters: {
|
|
62
|
+
docs: {
|
|
63
|
+
page: mdx,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
} as Meta
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { render } from '@testing-library/react'
|
|
2
|
+
import { axe } from 'jest-axe'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
import PaymentMethods from './PaymentMethods'
|
|
6
|
+
|
|
7
|
+
describe('Payment methods', () => {
|
|
8
|
+
let paymentMethodsData: HTMLElement
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
const { getByTestId } = render(
|
|
12
|
+
<PaymentMethods title="I am a title">
|
|
13
|
+
<h3>I am a flag</h3>
|
|
14
|
+
</PaymentMethods>
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
paymentMethodsData = getByTestId('store-payment-methods')
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('should have `data-store-payment-methods` attribute', () => {
|
|
21
|
+
expect(paymentMethodsData).toHaveAttribute('data-store-payment-methods')
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('Should render PaymentMethods Children', () => {
|
|
25
|
+
expect(paymentMethodsData).toHaveTextContent('I am a flag')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it('Should render PaymentMethods title', () => {
|
|
29
|
+
expect(paymentMethodsData).toHaveTextContent('I am a title')
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
describe('Accessibility', () => {
|
|
33
|
+
it('should have no violations', async () => {
|
|
34
|
+
expect(await axe(paymentMethodsData)).toHaveNoViolations()
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ReactNode, AriaAttributes } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface PaymentMethodsProps {
|
|
5
|
+
/**
|
|
6
|
+
* ID to find this component in testing tools (e.g.: cypress,
|
|
7
|
+
* testing-library, and jest).
|
|
8
|
+
*/
|
|
9
|
+
testId?: string
|
|
10
|
+
/**
|
|
11
|
+
* Title of the payment methods section (e.g.: "Payment methods",
|
|
12
|
+
* "Accepted Cards").
|
|
13
|
+
*/
|
|
14
|
+
title?: ReactNode
|
|
15
|
+
/**
|
|
16
|
+
* Defines a string value that labels the current element when
|
|
17
|
+
* title is not used.
|
|
18
|
+
*/
|
|
19
|
+
'aria-label'?: AriaAttributes['aria-label']
|
|
20
|
+
/**
|
|
21
|
+
* Children will receive the flags to be displayed in the payment
|
|
22
|
+
* methods section (e.g.:, visa, mastercard, etc).
|
|
23
|
+
*/
|
|
24
|
+
children: ReactNode
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const PaymentMethods = forwardRef<HTMLDivElement, PaymentMethodsProps>(
|
|
28
|
+
function PaymentMethods(
|
|
29
|
+
{
|
|
30
|
+
testId = 'store-payment-methods',
|
|
31
|
+
title,
|
|
32
|
+
'aria-label': ariaLabel = 'Payment Methods',
|
|
33
|
+
children,
|
|
34
|
+
...otherProps
|
|
35
|
+
},
|
|
36
|
+
ref
|
|
37
|
+
) {
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
ref={ref}
|
|
41
|
+
data-store-payment-methods
|
|
42
|
+
data-testid={testId}
|
|
43
|
+
{...otherProps}
|
|
44
|
+
>
|
|
45
|
+
{!!title && <div id="payment-methods">{title}</div>}
|
|
46
|
+
<div
|
|
47
|
+
data-payment-methods-flags
|
|
48
|
+
aria-labelledby={title ? 'payment-methods' : undefined}
|
|
49
|
+
aria-label={title ? undefined : ariaLabel}
|
|
50
|
+
>
|
|
51
|
+
{children}
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
export default PaymentMethods
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs'
|
|
2
|
+
import PaymentMethods from '../PaymentMethods'
|
|
3
|
+
|
|
4
|
+
# PaymentMethods
|
|
5
|
+
|
|
6
|
+
<Canvas>
|
|
7
|
+
<Story id="molecules-paymentmethods--payment-methods" />
|
|
8
|
+
</Canvas>
|
|
9
|
+
|
|
10
|
+
## Props
|
|
11
|
+
|
|
12
|
+
<ArgsTable of={PaymentMethods} />
|
|
13
|
+
|
|
14
|
+
## CSS Selectors
|
|
15
|
+
|
|
16
|
+
```css
|
|
17
|
+
[data-store-payment-methods] {}
|
|
18
|
+
[data-payment-methods-flags] {}
|
|
19
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Story, Meta } from '@storybook/react'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import type { PaymentMethodsProps } from '../PaymentMethods'
|
|
5
|
+
import Component from '../PaymentMethods'
|
|
6
|
+
import mdx from './PaymentMethods.mdx'
|
|
7
|
+
import {
|
|
8
|
+
VisaCard,
|
|
9
|
+
MasterCard,
|
|
10
|
+
MaestroCard,
|
|
11
|
+
AmericanExpressCard,
|
|
12
|
+
HiperCard,
|
|
13
|
+
EloCard,
|
|
14
|
+
DinersClub,
|
|
15
|
+
PayPal,
|
|
16
|
+
} from './assets/Icons'
|
|
17
|
+
|
|
18
|
+
const PaymentMethodsTemplate: Story<PaymentMethodsProps> = ({ testId }) => (
|
|
19
|
+
<Component testId={testId} title="Payment Methods">
|
|
20
|
+
<VisaCard key="visa" />
|
|
21
|
+
<MasterCard key="mastercard" />
|
|
22
|
+
<MaestroCard key="maestro" />
|
|
23
|
+
<AmericanExpressCard key="american express" />
|
|
24
|
+
<HiperCard key="hipercard" />
|
|
25
|
+
<EloCard key="elo" />
|
|
26
|
+
<DinersClub key="diners club" />
|
|
27
|
+
<PayPal key="paypal" />
|
|
28
|
+
</Component>
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
export const PaymentMethods = PaymentMethodsTemplate.bind({})
|
|
32
|
+
PaymentMethods.storyName = 'PaymentMethods'
|
|
33
|
+
|
|
34
|
+
export default {
|
|
35
|
+
title: 'Molecules/PaymentMethods',
|
|
36
|
+
parameters: {
|
|
37
|
+
docs: {
|
|
38
|
+
page: mdx,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
} as Meta
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
export function VisaCard() {
|
|
4
|
+
return (
|
|
5
|
+
<img
|
|
6
|
+
alt="Visa logo"
|
|
7
|
+
width={50}
|
|
8
|
+
height={50}
|
|
9
|
+
src="https://seeklogo.com/images/V/visa-logo-BDDD51C62D-seeklogo.com.png"
|
|
10
|
+
/>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function MasterCard() {
|
|
15
|
+
return (
|
|
16
|
+
<img
|
|
17
|
+
alt="Mastercard logo"
|
|
18
|
+
width={50}
|
|
19
|
+
height={50}
|
|
20
|
+
src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/Mastercard-logo.svg/1544px-Mastercard-logo.svg.png"
|
|
21
|
+
/>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function AmericanExpressCard() {
|
|
26
|
+
return (
|
|
27
|
+
<img
|
|
28
|
+
alt="American express logo"
|
|
29
|
+
width={50}
|
|
30
|
+
height={50}
|
|
31
|
+
src="https://seeklogo.com/images/A/american-express-logo-EDF87C04A0-seeklogo.com.png"
|
|
32
|
+
/>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function MaestroCard() {
|
|
37
|
+
return (
|
|
38
|
+
<img
|
|
39
|
+
alt="American express logo"
|
|
40
|
+
width={50}
|
|
41
|
+
height={50}
|
|
42
|
+
src="https://seeklogo.com/images/M/Maestro-logo-BF4E5E7686-seeklogo.com.png"
|
|
43
|
+
/>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function EloCard() {
|
|
48
|
+
return (
|
|
49
|
+
<img
|
|
50
|
+
alt="Elo logo"
|
|
51
|
+
width={50}
|
|
52
|
+
height={50}
|
|
53
|
+
src="https://seeklogo.com/images/E/elo-logo-9F0CF48D54-seeklogo.com.png"
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function HiperCard() {
|
|
59
|
+
return (
|
|
60
|
+
<img
|
|
61
|
+
alt="Hipercard logo"
|
|
62
|
+
width={50}
|
|
63
|
+
height={50}
|
|
64
|
+
src="https://seeklogo.com/images/H/Hipercard-logo-139D91D263-seeklogo.com.png"
|
|
65
|
+
/>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function PayPal() {
|
|
70
|
+
return (
|
|
71
|
+
<img
|
|
72
|
+
alt="PayPal brand"
|
|
73
|
+
width={50}
|
|
74
|
+
height={50}
|
|
75
|
+
src="https://seeklogo.com/images/P/paypal-logo-484B6FE744-seeklogo.com.png"
|
|
76
|
+
/>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function DinersClub() {
|
|
81
|
+
return (
|
|
82
|
+
<img
|
|
83
|
+
alt="Diners club logo"
|
|
84
|
+
width={50}
|
|
85
|
+
height={50}
|
|
86
|
+
src="https://seeklogo.com/images/D/Diners_Club_International-logo-EF50D35BE8-seeklogo.com.png"
|
|
87
|
+
/>
|
|
88
|
+
)
|
|
89
|
+
}
|