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] 마감기한 공통컴포넌트 - 지연 상태일때의 스타일 추가 #60

Merged
merged 1 commit into from
Jul 8, 2024
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
40 changes: 32 additions & 8 deletions src/components/common/BtnDate/BtnDate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ interface BtnDateProps {
date?: string;
time?: string;
size?: string;
isDelayed?: boolean;
}

function BtnDate(props: BtnDateProps) {
const { date = '마감 기한', time = '마감 시간', size = 'big' } = props;
const { date = '마감 기한', time = '마감 시간', size = 'big', isDelayed = false } = props;
const [isPressed, setIsPressed] = useState(false);
const [isClicked, setIsClicked] = useState(false);

Expand All @@ -34,14 +35,15 @@ function BtnDate(props: BtnDateProps) {
isPressed={isPressed}
isClicked={isClicked}
size={size}
isDelayed={isDelayed}
isDefaultDate={isDefaultDate}
isDefaultTime={isDefaultTime}
onMouseDown={handleMouseDown}
onMouseUp={handleMouseUp}
>
<BtnDateText icon={<CalanderIcon />} text={date} isDefault={isDefaultDate} size={size} />
<LineIcon size={size} />
<BtnDateText icon={<ClockIcon />} text={time} isDefault={isDefaultTime} size={size} />
<BtnDateText icon={<CalanderIcon isDelayed={isDelayed} />} text={date} isDefault={isDefaultDate} size={size} />
<LineIcon size={size} isDelayed={isDelayed} />
<BtnDateText icon={<ClockIcon isDelayed={isDelayed} />} text={time} isDefault={isDefaultTime} size={size} />
<XIcon isClicked={isClicked} />
</BtnDateLayout>
);
Expand All @@ -58,34 +60,47 @@ const XIcon = styled((props: React.SVGProps<SVGSVGElement> & { isClicked: boolea
height: 2rem;
`;

const CalanderIcon = styled(Icons.Icn_calander, { target: 'CalanderIcon' })`
const CalanderIcon = styled(Icons.Icn_calander, { target: 'CalanderIcon' })<{ isDelayed: boolean }>`
display: flex;
align-items: center;
justify-content: center;
width: 1.4rem;
height: 1.4rem;

path {
stroke: ${({ isDelayed, theme }) => (isDelayed ? theme.palette.Orange.Orange4 : 'currentColor')};
}
`;

const ClockIcon = styled(Icons.Icn_date_clock, { target: 'ClockIcon' })`
const ClockIcon = styled(Icons.Icn_date_clock, { target: 'ClockIcon' })<{ isDelayed: boolean }>`
display: flex;
align-items: center;
justify-content: center;
width: 1.4rem;
height: 1.4rem;

path {
stroke: ${({ isDelayed, theme }) => (isDelayed ? theme.palette.Orange.Orange4 : 'currentColor')};
}
`;

const LineIcon = styled(Icons.Icn_line, { target: 'LineIcon' })<{ size: string }>`
const LineIcon = styled(Icons.Icn_line, { target: 'LineIcon' })<{ size: string; isDelayed: boolean }>`
display: flex;
align-items: center;
justify-content: center;
width: 0.1rem;
height: ${({ size }) => (size === 'big' ? '2.2rem' : '1.2rem')};

line {
stroke: ${({ isDelayed, theme }) => (isDelayed ? theme.palette.Orange.Orange5 : 'currentColor')};
}
`;

const BtnDateLayout = styled.div<{
isPressed: boolean;
isClicked: boolean;
size: string;
isDelayed: boolean;
isDefaultDate: boolean;
isDefaultTime: boolean;
}>`
Expand All @@ -102,13 +117,22 @@ const BtnDateLayout = styled.div<{
border-color: ${({ isClicked, theme }) => (isClicked ? theme.palette.Primary : theme.palette.Grey.Grey3)};
border-radius: 8px;

${({ isDelayed, theme }) =>
isDelayed &&
css`
background: ${theme.palette.Orange.Orange1};
border-color: ${theme.palette.Orange.Orange5};

pointer-events: none;
Copy link
Member

Choose a reason for hiding this comment

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

우와 이런 속성이 있었군요!!! 너무 좋네요 저도 써먹어보겠습니다ㅎ.ㅎ

`}

${({ isClicked, size, theme }) =>
isClicked &&
css`
padding-right: ${size === 'big' ? '0.6rem' : '0.2rem'};

border-color: ${theme.palette.Primary};
border-width: 2px;
border-width: ${size === 'big' ? '2px' : '1px'};
`}

${({ isPressed, theme }) =>
Expand Down
1 change: 1 addition & 0 deletions src/pages/Today.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function Today() {
<TextInputTime time="total" />
<TextInputStaging />
<BtnDate date="2024.07.11" size="big" />
<BtnDate date="2024.07.11" size="small" isDelayed />
<BtnStagingDate />
<TargetArea />
</>
Expand Down
Loading