-
Notifications
You must be signed in to change notification settings - Fork 0
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
5 changed files
with
164 additions
and
80 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,46 @@ | ||
import React, { ReactElement } from 'react'; | ||
import { IChildren } from '@/utils/types/components/children'; | ||
|
||
interface ConditionalProps<T> { | ||
data: T; | ||
isLoading: boolean; | ||
emptyFunction: (data: T) => boolean; | ||
renderComponent: ReactElement; | ||
loadingComponent: ReactElement; | ||
emptyComponent: ReactElement; | ||
} | ||
|
||
export const Conditional = () => { | ||
const Wrapper = <T,>({ | ||
data, | ||
isLoading, | ||
emptyFunction, | ||
renderComponent, | ||
loadingComponent, | ||
emptyComponent, | ||
}: ConditionalProps<T>) => { | ||
if (isLoading) { | ||
return loadingComponent; | ||
} | ||
|
||
if (emptyFunction(data)) { | ||
return emptyComponent; | ||
} | ||
|
||
return renderComponent; | ||
}; | ||
|
||
const Render: React.FC<IChildren> = ({ children }) => { | ||
return <>{children}</>; | ||
}; | ||
|
||
const Loading: React.FC<IChildren> = ({ children }) => { | ||
return <>{children}</>; | ||
}; | ||
|
||
const Empty: React.FC<IChildren> = ({ children }) => { | ||
return <>{children}</>; | ||
}; | ||
|
||
return { Wrapper, Render, Loading, Empty }; | ||
}; |
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,16 @@ | ||
import { IChildren } from '@/utils/types/components/children'; | ||
import styled from '@emotion/styled'; | ||
|
||
interface IProps extends IChildren { | ||
height?: number; | ||
} | ||
|
||
export const LimitBox = ({ children, height }: IProps) => { | ||
return <Wrapper height={height}>{children}</Wrapper>; | ||
}; | ||
|
||
const Wrapper = styled.div<Pick<IProps, 'height'>>` | ||
width: 100%; | ||
max-width: 1120px; | ||
${(props) => props.height && `height: ${props.height}px`}; | ||
`; |
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,22 @@ | ||
import { IChildren } from '@/utils/types/components/children'; | ||
import styled from '@emotion/styled'; | ||
|
||
interface IProps extends IChildren { | ||
widthFit?: boolean; | ||
gap?: number; | ||
} | ||
|
||
export const VStack = ({ children, widthFit = true, gap = 0 }: IProps) => ( | ||
<Wrapper widthFit={widthFit} gap={gap}> | ||
{children} | ||
</Wrapper> | ||
); | ||
|
||
const Wrapper = styled.div<Pick<IProps, 'widthFit' | 'gap'>>` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: flex-start; | ||
gap: ${({ gap }) => `${gap}px`}; | ||
width: ${({ widthFit }) => (widthFit ? '100%' : 'auto')}; | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface IChildren { | ||
children: React.ReactNode; | ||
} |