@faststore/ui 1.3.19 → 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.
@@ -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