Skip to content

Commit f8327ba

Browse files
committed
feat: add if component
1 parent 35b1d2d commit f8327ba

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { default as If } from './source/If';
2+
3+
export * from './type';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { IfProps } from '../type';
2+
3+
function If({ children, condition, fallback }: IfProps) {
4+
return condition ? children : fallback;
5+
}
6+
7+
export default If;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { ReactNode } from 'react';
2+
3+
export interface IfProps {
4+
/**
5+
* The children to render
6+
*/
7+
children?: ReactNode;
8+
/**
9+
* If true, the children will be rendered
10+
*/
11+
condition: boolean;
12+
/**
13+
* The fallback to render
14+
*/
15+
fallback?: ReactNode;
16+
}

0 commit comments

Comments
 (0)