Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Flex): flex 컴포넌트를 원하는 컴포넌트로 렌더할 수 있도록 수정 #139

Merged
merged 4 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/create-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ jobs:
- name: Checkout
uses: actions/checkout@master
- name: Fire Notification
uses: Lubycon/github-reviewer-noti-action@v2.0.1
uses: Lubycon/github-reviewer-noti-action@v3.2.0
with:
github-token: ${{ secrets.LUBYCON_GITHUB_TOKEN }}
mattermost-webhook: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
slack-channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
slack-bot-signing-secret: ${{ secrets.SLACK_SIGNING_SECRET }}
17 changes: 14 additions & 3 deletions src/components/Flex/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,24 @@ export interface FlexBaseProps {
justify?: CSSProperties['justifyContent'];
}

export const DEFAULT_ELEMENT = 'div' as const;

type Props<T extends ElementType = 'div'> = OverridableProps<T, FlexBaseProps>;
const Flex = <T extends ElementType = 'div'>(
{ direction = 'row', align = 'flex-start', justify = 'flex-start', children, ...rest }: Props<T>,
{
direction = 'row',
align = 'flex-start',
justify = 'flex-start',
children,
as,
...rest
}: Props<T>,
ref: Ref<any>
) => {
const Component = as ?? DEFAULT_ELEMENT;

return (
<div
<Component
ref={ref}
css={{
display: 'flex',
Expand All @@ -24,7 +35,7 @@ const Flex = <T extends ElementType = 'div'>(
{...rest}
>
{children}
</div>
</Component>
);
};

Expand Down
3 changes: 1 addition & 2 deletions src/components/Grid/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ const Column = <T extends React.ElementType = typeof DEFAULT_ELEMENT>(
[]
);

const target = as ?? DEFAULT_ELEMENT;
const Component = target;
const Component = as ?? DEFAULT_ELEMENT;

return (
<Component
Expand Down
3 changes: 1 addition & 2 deletions src/components/Text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ const Text = <T extends ElementType = typeof DEFAULT_ELEMENT>(
{ display, lineHeight, weight, size, color, align, as, children, ...props }: TextProps<T>,
ref: Ref<any>
) => {
const target = as ?? DEFAULT_ELEMENT;
const Component = target;
const Component = as ?? DEFAULT_ELEMENT;

return (
<Component
Expand Down