-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
47 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { CSSProperties, ElementType, forwardRef, PropsWithRef, Ref } from 'react'; | ||
import { OverridableProps } from 'src/types/OverridableProps'; | ||
|
||
interface FlexBaseProps { | ||
direction?: CSSProperties['flexDirection']; | ||
align?: CSSProperties['alignItems']; | ||
justify?: CSSProperties['justifyContent']; | ||
} | ||
|
||
type Props<T extends ElementType = 'div'> = OverridableProps<T, FlexBaseProps>; | ||
const Flex = <T extends ElementType = 'div'>( | ||
{ direction = 'row', align = 'flex-start', justify = 'flex-start', children }: Props<T>, | ||
ref: Ref<any> | ||
) => { | ||
return ( | ||
<div | ||
ref={ref} | ||
css={{ | ||
display: 'flex', | ||
flexDirection: direction, | ||
alignItems: align, | ||
justifyContent: justify, | ||
}} | ||
> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default forwardRef(Flex) as PropsWithRef<typeof Flex>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import { ComponentPropsWithoutRef, ComponentType, ElementType, ReactElement } from 'react'; | ||
import { ComponentProps, ComponentType, ElementType, ReactElement } from 'react'; | ||
|
||
/** | ||
* @description T와 K에서 T의 프로퍼티를 제거한 타입을 병합합니다. | ||
*/ | ||
export type Combine<T, K> = T & Omit<K, keyof T>; | ||
|
||
export type CombineElementProps<E extends ElementType, P = unknown> = Combine< | ||
P, | ||
ComponentPropsWithoutRef<E> | ||
>; | ||
export type CombineElementProps<E extends ElementType, P = unknown> = Combine<P, ComponentProps<E>>; | ||
|
||
export type ComponentElementType<T> = ReactElement<ComponentType<T>>; |