@faststore/ui 1.10.29 → 1.10.34

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 CHANGED
@@ -3,6 +3,33 @@
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.10.34 (2022-08-04)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add skuSelector-related properties to ProductGroup type ([#1407](https://github.com/vtex/faststore/issues/1407)) ([3f9f33f](https://github.com/vtex/faststore/commit/3f9f33f05b47d266465f349edb7645ad06ff7b27))
12
+
13
+
14
+
15
+ ## [1.10.31](https://github.com/vtex/faststore/compare/v1.10.30...v1.10.31) (2022-08-02)
16
+
17
+
18
+ ### Features
19
+
20
+ * Add fowardRef to `ProductTitle` ([#1427](https://github.com/vtex/faststore/issues/1427)) ([5f622f3](https://github.com/vtex/faststore/commit/5f622f3a28a32228aa457c0b1bd141969f541262))
21
+
22
+
23
+
24
+ ## 1.10.30 (2022-08-02)
25
+
26
+
27
+ ### Chores
28
+
29
+ * Updates documentation link ([#1424](https://github.com/vtex/faststore/issues/1424)) ([04e518a](https://github.com/vtex/faststore/commit/04e518a92038259bda212024b85c1a807ebf0e1a))
30
+
31
+
32
+
6
33
  ## [1.10.29](https://github.com/vtex/faststore/compare/v1.10.28...v1.10.29) (2022-07-29)
7
34
 
8
35
 
package/README.md CHANGED
@@ -49,4 +49,4 @@ function MyComponent {
49
49
 
50
50
  ## Docs
51
51
 
52
- For more information, please refer to our documentation: https://faststore.dev/reference/ui/overview
52
+ For more information, please refer to our documentation: https://faststore.dev/reference/ui/faststore-ui
package/dist/index.d.ts CHANGED
@@ -78,6 +78,8 @@ export { default as Dropdown, DropdownButton, DropdownItem, DropdownMenu, } from
78
78
  export type { DropdownProps, DropdownButtonProps, DropdownItemProps, DropdownMenuProps, } from './molecules/Dropdown';
79
79
  export { default as OutOfStock, OutOfStockTitle, OutOfStockMessage, } from './organisms/OutOfStock';
80
80
  export type { OutOfStockProps, OutOfStockMessageProps, OutOfStockTitleProps, } from './organisms/OutOfStock';
81
+ export { Tiles, Tile } from './organisms/Tiles';
82
+ export type { TilesProps, TileProps } from './organisms/Tiles';
81
83
  export { default as Hero, HeroHeading, HeroImage } from './organisms/Hero';
82
84
  export type { HeroProps, HeroHeadingProps, HeroImageProps, } from './organisms/Hero';
83
85
  export { default as useSlider } from './hooks/useSlider';
package/dist/index.js CHANGED
@@ -41,6 +41,7 @@ export { default as QuantitySelector } from './molecules/QuantitySelector';
41
41
  export { default as Dropdown, DropdownButton, DropdownItem, DropdownMenu, } from './molecules/Dropdown';
42
42
  // Organisms
43
43
  export { default as OutOfStock, OutOfStockTitle, OutOfStockMessage, } from './organisms/OutOfStock';
44
+ export { Tiles, Tile } from './organisms/Tiles';
44
45
  export { default as Hero, HeroHeading, HeroImage } from './organisms/Hero';
45
46
  // Hooks
46
47
  export { default as useSlider } from './hooks/useSlider';
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,MAAM,eAAe,CAAA;AAGhD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAGtD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAA;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AS,EACT,QAAQ,GACT,MAAM,mBAAmB,CAAA;AAU1B,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAGlD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAGpD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAG1E,OAAO,EACL,OAAO,IAAI,QAAQ,EACnB,cAAc,EACd,YAAY,EACZ,YAAY,GACb,MAAM,sBAAsB,CAAA;AAQ7B,YAAY;AACZ,OAAO,EACL,OAAO,IAAI,UAAU,EACrB,eAAe,EACf,iBAAiB,GAClB,MAAM,wBAAwB,CAAA;AAO/B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAG/C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAO1E,QAAQ;AACR,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAA"}
@@ -1,4 +1,4 @@
1
- import { HTMLAttributes } from 'react';
1
+ import React, { HTMLAttributes } from 'react';
2
2
  import type { ReactNode } from 'react';
3
3
  export declare type ProductTitleProps = Omit<HTMLAttributes<HTMLElement>, 'title'> & {
4
4
  /**
@@ -22,5 +22,26 @@ export declare type ProductTitleProps = Omit<HTMLAttributes<HTMLElement>, 'title
22
22
  */
23
23
  testId?: string;
24
24
  };
25
- declare function ProductTitle({ title, label, refTag, refNumber, testId, ...otherProps }: ProductTitleProps): JSX.Element;
25
+ declare const ProductTitle: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<HTMLElement>, "title"> & {
26
+ /**
27
+ * A react component to be used as the product title, e.g. a `h1`
28
+ */
29
+ title: ReactNode;
30
+ /**
31
+ * A react component to be used as the product label, e.g. a `DiscountBadge`
32
+ */
33
+ label?: ReactNode;
34
+ /**
35
+ * Label for reference.
36
+ */
37
+ refTag?: string | undefined;
38
+ /**
39
+ * A text to be used below the title and the label, such as the product's reference number.
40
+ */
41
+ refNumber?: string | undefined;
42
+ /**
43
+ * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
44
+ */
45
+ testId?: string | undefined;
46
+ } & React.RefAttributes<HTMLElement>>;
26
47
  export default ProductTitle;
@@ -1,12 +1,12 @@
1
- import React from 'react';
2
- function ProductTitle({ title, label, refTag = "Ref.: ", refNumber, testId = 'store-product-title', ...otherProps }) {
3
- return (React.createElement("header", Object.assign({ "data-fs-product-title": true, "data-testid": testId }, otherProps),
1
+ import React, { forwardRef } from 'react';
2
+ const ProductTitle = forwardRef(function ProductTitle({ title, label, refTag = "Ref.: ", refNumber, testId = 'store-product-title', ...otherProps }, ref) {
3
+ return (React.createElement("header", Object.assign({ ref: ref, "data-fs-product-title": true, "data-testid": testId }, otherProps),
4
4
  React.createElement("div", { "data-fs-product-title-header": true },
5
5
  title,
6
6
  !!label && label),
7
7
  refNumber && (React.createElement("p", { "data-fs-product-title-addendum": true },
8
8
  refTag,
9
9
  refNumber))));
10
- }
10
+ });
11
11
  export default ProductTitle;
12
12
  //# sourceMappingURL=ProductTitle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProductTitle.js","sourceRoot":"","sources":["../../../src/molecules/ProductTitle/ProductTitle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyB,MAAM,OAAO,CAAA;AA0B7C,SAAS,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAE,QAAQ,EAAC,SAAS,EAAE,MAAM,GAAE,qBAAqB,EAAE,GAAG,UAAU,EAAqB;IACjI,OAAO,CACL,4FAA2C,MAAM,IAAM,UAAU;QAC/D;YACG,KAAK;YACL,CAAC,CAAC,KAAK,IAAI,KAAK,CACb;QAEL,SAAS,IAAI,CACZ;YACG,MAAM;YAAE,SAAS,CAChB,CACL,CACM,CACV,CAAA;AACH,CAAC;AAED,eAAe,YAAY,CAAA"}
1
+ {"version":3,"file":"ProductTitle.js","sourceRoot":"","sources":["../../../src/molecules/ProductTitle/ProductTitle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAA;AA0BzD,MAAM,YAAY,GAAG,UAAU,CAC7B,SAAS,YAAY,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAE,QAAQ,EAAC,SAAS,EAAE,MAAM,GAAE,qBAAqB,EAAE,GAAG,UAAU,EAAE,EAAE,GAAG;IACnH,OAAO,CACL,8CAAQ,GAAG,EAAE,GAAG,gDAAqC,MAAM,IAAM,UAAU;QACzE;YACG,KAAK;YACL,CAAC,CAAC,KAAK,IAAI,KAAK,CACb;QAEL,SAAS,IAAI,CACZ;YACG,MAAM;YAAE,SAAS,CAChB,CACL,CACM,CACV,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,YAAY,CAAA"}
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { HTMLAttributes } from 'react';
3
+ export interface TileProps extends HTMLAttributes<HTMLLIElement> {
4
+ /**
5
+ * ID to find this component in testing tools (e.g.: Cypress,
6
+ * Testing Library, and Jest).
7
+ */
8
+ testId?: string;
9
+ }
10
+ declare const Tile: React.ForwardRefExoticComponent<TileProps & React.RefAttributes<HTMLLIElement>>;
11
+ export default Tile;
@@ -0,0 +1,6 @@
1
+ import React, { forwardRef } from 'react';
2
+ const Tile = forwardRef(function Tile({ testId = 'store-tile', children, ...otherProps }, ref) {
3
+ return (React.createElement("li", Object.assign({ ref: ref, "data-fs-tile": true, "data-testid": testId }, otherProps), children));
4
+ });
5
+ export default Tile;
6
+ //# sourceMappingURL=Tile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tile.js","sourceRoot":"","sources":["../../../src/organisms/Tiles/Tile.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAWzC,MAAM,IAAI,GAAG,UAAU,CAA2B,SAAS,IAAI,CAC7D,EAAE,MAAM,GAAG,YAAY,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,EAClD,GAAG;IAEH,OAAO,CACL,0CAAI,GAAG,EAAE,GAAG,uCAA4B,MAAM,IAAM,UAAU,GAC3D,QAAQ,CACN,CACN,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,eAAe,IAAI,CAAA"}
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { HTMLAttributes } from 'react';
3
+ export interface TilesProps extends HTMLAttributes<HTMLUListElement> {
4
+ /**
5
+ * ID to find this component in testing tools (e.g.: Cypress,
6
+ * Testing Library, and Jest).
7
+ */
8
+ testId?: string;
9
+ }
10
+ declare const Tiles: React.ForwardRefExoticComponent<TilesProps & React.RefAttributes<HTMLUListElement>>;
11
+ export default Tiles;
@@ -0,0 +1,30 @@
1
+ import React, { Children, forwardRef } from 'react';
2
+ import { Tile } from '.';
3
+ const MIN_CHILDREN = 2;
4
+ const MAX_CHILDREN = 4;
5
+ const NUMBER_ITEMS_TO_EXPAND_FIRST_TWO = 2;
6
+ const NUMBER_ITEMS_TO_EXPAND_FIRST = 3;
7
+ const Tiles = forwardRef(function Tiles({ testId = 'store-tiles', children, ...otherProps }, ref) {
8
+ const childrenCount = Children.count(children);
9
+ if (process.env.NODE_ENV === 'development') {
10
+ const isOutOfBounds = childrenCount < MIN_CHILDREN || childrenCount > MAX_CHILDREN;
11
+ if (isOutOfBounds) {
12
+ throw new Error(`Tiles cannot receive less than ${MIN_CHILDREN} or more than ${MAX_CHILDREN} children.`);
13
+ }
14
+ }
15
+ if (process.env.NODE_ENV === 'development') {
16
+ Children.forEach(children, (child) => {
17
+ if (child.type !== Tile) {
18
+ throw new Error('Only Tile components allowed as children.');
19
+ }
20
+ });
21
+ }
22
+ const expandedClass = childrenCount === NUMBER_ITEMS_TO_EXPAND_FIRST
23
+ ? 'expanded-first'
24
+ : childrenCount === NUMBER_ITEMS_TO_EXPAND_FIRST_TWO
25
+ ? 'expanded-first-two'
26
+ : '';
27
+ return (React.createElement("ul", Object.assign({ ref: ref, "data-fs-tiles": true, "data-fs-tiles-variant": expandedClass, "data-testid": testId }, otherProps), children));
28
+ });
29
+ export default Tiles;
30
+ //# sourceMappingURL=Tiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tiles.js","sourceRoot":"","sources":["../../../src/organisms/Tiles/Tiles.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGnD,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,CAAA;AAUxB,MAAM,YAAY,GAAG,CAAC,CAAA;AACtB,MAAM,YAAY,GAAG,CAAC,CAAA;AACtB,MAAM,gCAAgC,GAAG,CAAC,CAAA;AAC1C,MAAM,4BAA4B,GAAG,CAAC,CAAA;AAEtC,MAAM,KAAK,GAAG,UAAU,CAA+B,SAAS,KAAK,CACnE,EAAE,MAAM,GAAG,aAAa,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,EACnD,GAAG;IAEH,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAE9C,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;QAC1C,MAAM,aAAa,GACjB,aAAa,GAAG,YAAY,IAAI,aAAa,GAAG,YAAY,CAAA;QAE9D,IAAI,aAAa,EAAE;YACjB,MAAM,IAAI,KAAK,CACb,kCAAkC,YAAY,iBAAiB,YAAY,YAAY,CACxF,CAAA;SACF;KACF;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;QAC1C,QAAQ,CAAC,OAAO,CAAC,QAAwB,EAAE,CAAC,KAAK,EAAE,EAAE;YACnD,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,EAAE;gBACvB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAA;aAC7D;QACH,CAAC,CAAC,CAAA;KACH;IAED,MAAM,aAAa,GACjB,aAAa,KAAK,4BAA4B;QAC5C,CAAC,CAAC,gBAAgB;QAClB,CAAC,CAAC,aAAa,KAAK,gCAAgC;YACpD,CAAC,CAAC,oBAAoB;YACtB,CAAC,CAAC,EAAE,CAAA;IAER,OAAO,CACL,0CACE,GAAG,EAAE,GAAG,kDAEe,aAAa,iBACvB,MAAM,IACf,UAAU,GAEb,QAAQ,CACN,CACN,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,eAAe,KAAK,CAAA"}
@@ -0,0 +1,4 @@
1
+ export { default as Tiles } from './Tiles';
2
+ export type { TilesProps } from './Tiles';
3
+ export { default as Tile } from './Tile';
4
+ export type { TileProps } from './Tile';
@@ -0,0 +1,3 @@
1
+ export { default as Tiles } from './Tiles';
2
+ export { default as Tile } from './Tile';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/organisms/Tiles/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAA;AAG1C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/ui",
3
- "version": "1.10.29",
3
+ "version": "1.10.34",
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.10.29",
60
+ "@faststore/styles": "^1.10.34",
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",
@@ -79,11 +79,11 @@
79
79
  "react": "^17.0.2",
80
80
  "react-docgen-typescript-loader": "^3.7.2",
81
81
  "react-dom": "^17.0.2",
82
- "shared": "^1.10.18",
82
+ "shared": "^1.10.34",
83
83
  "size-limit": "^7.0.8",
84
84
  "storybook-addon-themes": "^6.1.0",
85
85
  "tsdx": "^0.14.1",
86
86
  "typescript": "^4.2.4"
87
87
  },
88
- "gitHead": "505d423909498d321c657b8ce05ab2a15f015fce"
88
+ "gitHead": "5d59e28c724e389b596e2bb13b1464314eab275f"
89
89
  }
package/src/index.ts CHANGED
@@ -193,6 +193,9 @@ export type {
193
193
  OutOfStockTitleProps,
194
194
  } from './organisms/OutOfStock'
195
195
 
196
+ export { Tiles, Tile } from './organisms/Tiles'
197
+ export type { TilesProps, TileProps } from './organisms/Tiles'
198
+
196
199
  export { default as Hero, HeroHeading, HeroImage } from './organisms/Hero'
197
200
  export type {
198
201
  HeroProps,
@@ -1,4 +1,4 @@
1
- import React, { HTMLAttributes } from 'react'
1
+ import React, { forwardRef, HTMLAttributes } from 'react'
2
2
  import type { ReactNode } from 'react'
3
3
 
4
4
  export type ProductTitleProps = Omit<HTMLAttributes<HTMLElement>, 'title'> & {
@@ -24,21 +24,23 @@ export type ProductTitleProps = Omit<HTMLAttributes<HTMLElement>, 'title'> & {
24
24
  testId?: string
25
25
  }
26
26
 
27
- function ProductTitle({ title, label, refTag= "Ref.: ",refNumber, testId= 'store-product-title', ...otherProps }: ProductTitleProps) {
28
- return (
29
- <header data-fs-product-title data-testid={testId} {...otherProps}>
30
- <div data-fs-product-title-header>
31
- {title}
32
- {!!label && label}
33
- </div>
27
+ const ProductTitle = forwardRef<HTMLElement, ProductTitleProps>(
28
+ function ProductTitle({ title, label, refTag= "Ref.: ",refNumber, testId= 'store-product-title', ...otherProps }, ref) {
29
+ return (
30
+ <header ref={ref} data-fs-product-title data-testid={testId} {...otherProps}>
31
+ <div data-fs-product-title-header>
32
+ {title}
33
+ {!!label && label}
34
+ </div>
34
35
 
35
- {refNumber && (
36
- <p data-fs-product-title-addendum>
37
- {refTag}{refNumber}
38
- </p>
39
- )}
40
- </header>
41
- )
42
- }
36
+ {refNumber && (
37
+ <p data-fs-product-title-addendum>
38
+ {refTag}{refNumber}
39
+ </p>
40
+ )}
41
+ </header>
42
+ )
43
+ }
44
+ )
43
45
 
44
46
  export default ProductTitle
@@ -0,0 +1,23 @@
1
+ import React, { forwardRef } from 'react'
2
+ import type { HTMLAttributes } from 'react'
3
+
4
+ export interface TileProps extends HTMLAttributes<HTMLLIElement> {
5
+ /**
6
+ * ID to find this component in testing tools (e.g.: Cypress,
7
+ * Testing Library, and Jest).
8
+ */
9
+ testId?: string
10
+ }
11
+
12
+ const Tile = forwardRef<HTMLLIElement, TileProps>(function Tile(
13
+ { testId = 'store-tile', children, ...otherProps },
14
+ ref
15
+ ) {
16
+ return (
17
+ <li ref={ref} data-fs-tile data-testid={testId} {...otherProps}>
18
+ {children}
19
+ </li>
20
+ )
21
+ })
22
+
23
+ export default Tile
@@ -0,0 +1,64 @@
1
+ import React, { Children, forwardRef } from 'react'
2
+ import type { HTMLAttributes, ReactElement } from 'react'
3
+
4
+ import { Tile } from '.'
5
+
6
+ export interface TilesProps extends HTMLAttributes<HTMLUListElement> {
7
+ /**
8
+ * ID to find this component in testing tools (e.g.: Cypress,
9
+ * Testing Library, and Jest).
10
+ */
11
+ testId?: string
12
+ }
13
+
14
+ const MIN_CHILDREN = 2
15
+ const MAX_CHILDREN = 4
16
+ const NUMBER_ITEMS_TO_EXPAND_FIRST_TWO = 2
17
+ const NUMBER_ITEMS_TO_EXPAND_FIRST = 3
18
+
19
+ const Tiles = forwardRef<HTMLUListElement, TilesProps>(function Tiles(
20
+ { testId = 'store-tiles', children, ...otherProps },
21
+ ref
22
+ ) {
23
+ const childrenCount = Children.count(children)
24
+
25
+ if (process.env.NODE_ENV === 'development') {
26
+ const isOutOfBounds =
27
+ childrenCount < MIN_CHILDREN || childrenCount > MAX_CHILDREN
28
+
29
+ if (isOutOfBounds) {
30
+ throw new Error(
31
+ `Tiles cannot receive less than ${MIN_CHILDREN} or more than ${MAX_CHILDREN} children.`
32
+ )
33
+ }
34
+ }
35
+
36
+ if (process.env.NODE_ENV === 'development') {
37
+ Children.forEach(children as ReactElement, (child) => {
38
+ if (child.type !== Tile) {
39
+ throw new Error('Only Tile components allowed as children.')
40
+ }
41
+ })
42
+ }
43
+
44
+ const expandedClass =
45
+ childrenCount === NUMBER_ITEMS_TO_EXPAND_FIRST
46
+ ? 'expanded-first'
47
+ : childrenCount === NUMBER_ITEMS_TO_EXPAND_FIRST_TWO
48
+ ? 'expanded-first-two'
49
+ : ''
50
+
51
+ return (
52
+ <ul
53
+ ref={ref}
54
+ data-fs-tiles
55
+ data-fs-tiles-variant={expandedClass}
56
+ data-testid={testId}
57
+ {...otherProps}
58
+ >
59
+ {children}
60
+ </ul>
61
+ )
62
+ })
63
+
64
+ export default Tiles
@@ -0,0 +1,5 @@
1
+ export { default as Tiles } from './Tiles'
2
+ export type { TilesProps } from './Tiles'
3
+
4
+ export { default as Tile } from './Tile'
5
+ export type { TileProps } from './Tile'
@@ -0,0 +1,39 @@
1
+ import { ArgsTable, Canvas, Story } from '@storybook/addon-docs'
2
+
3
+ import { Tile, Tiles } from '../'
4
+
5
+ # Tiles
6
+
7
+ <Canvas>
8
+ <Story id="organisms-tiles--tiles" />
9
+ </Canvas>
10
+
11
+ ## Components
12
+
13
+ - `Tiles`: the parent component that wraps one or many `Tile`s.
14
+ - `Tile`: the child component.
15
+
16
+ ## Props
17
+
18
+ Besides those attributes, the following props are also supported:
19
+
20
+ ### `Tiles`
21
+
22
+ <ArgsTable of={Tiles} />
23
+
24
+ ### `Tile`
25
+
26
+ <ArgsTable of={Tile} />
27
+
28
+ ## CSS Selectors
29
+
30
+ ```css
31
+ [data-fs-tiles] {
32
+ }
33
+
34
+ [data-fs-tiles-variant='expanded-first'|'expanded-first-two'] {
35
+ }
36
+
37
+ [data-fs-tile] {
38
+ }
39
+ ```
@@ -0,0 +1,38 @@
1
+ import React from 'react'
2
+
3
+ import { Tile, Tiles as UITiles } from '../'
4
+ import mdx from './Tiles.mdx'
5
+
6
+ import type { Story, Meta } from '@storybook/react'
7
+ import type { TilesProps } from '../'
8
+
9
+ const TilesTemplate: Story<TilesProps> = () => (
10
+ <>
11
+ <UITiles>
12
+ <Tile>Tile #1</Tile>
13
+ <Tile>Tile #2</Tile>
14
+ </UITiles>
15
+ <UITiles>
16
+ <Tile>Tile #1</Tile>
17
+ <Tile>Tile #2</Tile>
18
+ <Tile>Tile #3</Tile>
19
+ <Tile>Tile #4</Tile>
20
+ </UITiles>
21
+ <UITiles>
22
+ <Tile>Tile #1</Tile>
23
+ <Tile>Tile #2</Tile>
24
+ <Tile>Tile #3</Tile>
25
+ </UITiles>
26
+ </>
27
+ )
28
+
29
+ export const Tiles = TilesTemplate.bind({})
30
+
31
+ export default {
32
+ title: 'Organisms/Tiles',
33
+ parameters: {
34
+ docs: {
35
+ page: mdx,
36
+ },
37
+ },
38
+ } as Meta