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

Jy/XButton, Input, Search Filter 구현 #97

Merged
merged 10 commits into from
Nov 5, 2020
17 changes: 17 additions & 0 deletions client/src/components/molecules/XButton/XButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { text } from '@storybook/addon-knobs';
import { Reset } from '@components/atoms/Icons';
import XButton from './XButton';

export default {
component: XButton,
title: 'XButton',
};
export const Default = () => {
const value = text('value', 'Clear current search query, filters, and sorts');
const Icon = Reset;
const onClick = (e: React.ChangeEvent<HTMLInputElement>) => {
// 필터 초기화
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나중을 위해서 onclick에 어떤 메소드가 들어갈지 적어준 부분 너무 좋아요~!

return <XButton Icon={Icon} value={value} onClick={onClick} />;
};
53 changes: 53 additions & 0 deletions client/src/components/molecules/XButton/XButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React, { FunctionComponent } from 'react';
import styled from '@themes/styled';

interface Props {
Icon: FunctionComponent;
value: string;
onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onclick에서는 event 객체를 활용할 일이 없을 것으로 생각됩니다!
event 객체를 넣어주면 이 컴포넌트를 사용할 때 항상 저 event 객체를 넣어주어야 해서 타입 오류가 잦게 날 수 있을 것 같습니다.

}

const StyledButton = styled.button`
font-size: 1rem;
font-weight: 600;
text-align: center;
color: ${({ theme }) => theme.palette.SECONDARY};
text-decoration: none;
border: none;
opacity: 1;

cursor: pointer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

속성끼리는 붙이고 & > 같은 다른 스타일 적용할 때만 띄워주면 좋을 것 같아요

& > svg {
width: 18px;
height: 18px;
padding: 1px;
margin-right: 3px;
fill: ${({ theme }) => theme.palette.LIGHT};
background-color: ${({ theme }) => theme.palette.SECONDARY};
border-radius: 6px;
border: none;
}

&:hover {
color: ${({ theme }) => theme.palette.LINK_BLUE};
}

&:hover svg {
background-color: ${({ theme }) => theme.palette.LINK_BLUE};
}

&:focus {
outline: none;
}
`;

const XButton: FunctionComponent<Props> = ({ Icon, value, onClick }) => {
return (
<StyledButton onClick={onClick}>
<Icon />
{value}
</StyledButton>
);
};

export default XButton;
1 change: 1 addition & 0 deletions client/src/components/molecules/XButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './XButton';