Skip to content

Commit 3d72cf8

Browse files
committed
Re-use types from AutoFill to InfiniteAutoFill
1 parent c5af9cd commit 3d72cf8

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

src/components/AutoFill/AutoFill.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Fills components vertically.
4848
function DemoComponent() {
4949
return (
5050
<div style={{ height: 1000, outline: '1px solid black' }}>
51-
<AutoFill>
51+
<AutoFill axis="y">
5252
<div style={{ padding: 15 }}>
5353
<div style={{ width: 50, outline: '1px solid red' }}>Child</div>
5454
</div>

src/components/AutoFill/AutoFill.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type AutoFillChildrenProps = {
1818
ref: RefCallback<unknown>;
1919
};
2020

21-
type AutoFillProps = {
21+
export type AutoFillProps = {
2222
children:
2323
| ReactElement<AutoFillChildrenProps>
2424
| ReadonlyArray<ReactElement<AutoFillChildrenProps>>;

src/components/InfiniteAutoFill/InfiniteAutoFill.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import * as stories from './InfiniteAutoFill.stories';
66
# InfiniteAutoFill
77

88
Uses the AutoFill to repeat children to fill the parent element in given axis. In addition to that
9-
it adds the children one more time to the end of the list. This can be useful for example marquee's.
9+
it adds the children one more time to the end of the list. This can be useful for example marquees
10+
or infinite carousels.
1011

1112
## Reference
1213

@@ -49,7 +50,7 @@ Fills components vertically + one extra.
4950
function DemoComponent() {
5051
return (
5152
<div style={{ height: 1000, outline: '1px solid black' }}>
52-
<InfiniteAutoFill>
53+
<InfiniteAutoFill axis="y">
5354
<div style={{ padding: 15 }}>
5455
<div style={{ width: 50, outline: '1px solid red' }}>Child</div>
5556
</div>

src/components/InfiniteAutoFill/InfiniteAutoFill.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
import { type ReactElement, type RefCallback } from 'react';
1+
import { type ComponentProps, type ReactElement } from 'react';
22
import { AutoFill } from '../../index.js';
33

4-
type InfiniteAutoFillChildrenProps = {
5-
ref: RefCallback<unknown>;
6-
};
7-
8-
type InfiniteAutoFillProps = {
9-
children:
10-
| ReactElement<InfiniteAutoFillChildrenProps>
11-
| ReadonlyArray<ReactElement<InfiniteAutoFillChildrenProps>>;
12-
axis?: 'x' | 'y';
13-
};
4+
type InfiniteAutoFillProps = ComponentProps<typeof AutoFill>;
145

156
/**
167
* Repeats children to fill the parent element in given axis.
178
*/
18-
export function InfiniteAutoFill({ children, axis = 'x' }: InfiniteAutoFillProps): ReactElement {
9+
export function InfiniteAutoFill({ children, axis }: InfiniteAutoFillProps): ReactElement {
1910
return (
2011
<>
2112
<AutoFill axis={axis}>{children}</AutoFill>

0 commit comments

Comments
 (0)