@faststore/ui 1.3.15 → 1.3.19

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.
@@ -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,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,2 @@
1
+ export { default } from './PaymentMethods'
2
+ export type { PaymentMethodsProps } from './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
+ }