Skip to content

Commit e37fa68

Browse files
authored
Merge pull request #112 from cskime/feature/#49
[#49] Animation 적용
2 parents e294319 + dcd215b commit e37fa68

File tree

20 files changed

+258
-66
lines changed

20 files changed

+258
-66
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { css } from "styled-components";
2+
3+
function mountAnimation({ isOpen, open, close }) {
4+
return css`
5+
animation: ${isOpen ? open : close} 300ms both;
6+
`;
7+
}
8+
9+
export { mountAnimation };

src/components/button/button.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const BaseButton = styled.button`
5050
line-height: ${({ $size }) => styles.lineHeight[$size]};
5151
border-radius: ${({ $size }) => styles.borderRadius[$size]};
5252
height: ${({ $size, $icon }) => styles.height($icon)[$size]};
53+
transition: background-color 0.3s;
5354
5455
span {
5556
display: block;

src/components/button/toggle-button.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ const ToggleItem = styled.button`
1818
padding: 0 16px;
1919
height: 40px;
2020
cursor: pointer;
21+
transition: background-color 0.3s;
22+
23+
&:hover {
24+
background-color: ${({ $selected }) =>
25+
$selected ? Colors.purple(100) : Colors.gray(200)};
26+
}
2127
2228
span {
2329
display: block;

src/components/modal/modal.jsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1-
import styled from "styled-components";
1+
import styled, { keyframes } from "styled-components";
2+
import { mountAnimation } from "../animated-mount/mount-animation";
23
import Portal from "../portal/portal";
34

5+
const openAnimation = keyframes`
6+
from { opacity: 0 }
7+
to { opacity: 1 }
8+
`;
9+
10+
const closeAnimation = keyframes`
11+
from { opacity: 1 }
12+
to { opacity: 0 }
13+
`;
14+
415
const Content = styled.div`
516
width: 100%;
617
display: flex;
@@ -29,14 +40,20 @@ const ModalContainer = styled.div`
2940
display: flex;
3041
justify-content: center;
3142
align-items: center;
43+
${({ $isOpen }) =>
44+
mountAnimation({
45+
isOpen: $isOpen,
46+
open: openAnimation,
47+
close: closeAnimation,
48+
})};
3249
`;
3350

34-
function Modal({ shows, children }) {
51+
function Modal({ shows, isOpen, onDismiss, children }) {
3552
return (
3653
<>
3754
{shows && (
3855
<Portal id="modal">
39-
<ModalContainer>
56+
<ModalContainer $isOpen={isOpen} onAnimationEnd={onDismiss}>
4057
<StyledModal>
4158
<Content>{children}</Content>
4259
</StyledModal>

src/components/text-field/dropdown-input/dropdown-input.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const StyledDropdownInput = styled.button`
5151
gap: 8px;
5252
cursor: pointer;
5353
position: relative;
54+
transition: box-shadow 0.3s;
5455
5556
&:hover {
5657
box-shadow: 0 0 0 1px

src/components/text-field/input-styles.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ const INPUT_STYLES = Object.freeze({
88
line-height: 26px;
99
`,
1010
borderColor: {
11-
normal: (error) => (error ? Colors.error : Colors.gray(300)),
12-
hover: (error) => (error ? Colors.error : Colors.gray(500)),
13-
active: (error) => (error ? Colors.error : Colors.gray(700)),
14-
focus: (error) => (error ? Colors.error : Colors.gray(500)),
11+
normal: (error) => (error ? Colors.red(400) : Colors.gray(300)),
12+
hover: (error) => (error ? Colors.red(500) : Colors.gray(500)),
13+
active: (error) => (error ? Colors.red(700) : Colors.gray(700)),
14+
focus: (error) => (error ? Colors.red(500) : Colors.gray(500)),
1515
disabled: Colors.gray(300),
1616
},
1717
textColor: {

src/components/text-field/text-input/text-input.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const StyledTextInput = styled.input`
1212
${INPUT_STYLES.font}
1313
color: ${INPUT_STYLES.textColor.normal};
1414
min-width: 320px;
15+
transition: box-shadow 0.3s;
1516
1617
&::placeholder {
1718
${INPUT_STYLES.font}

src/components/toast/toast.jsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1-
import styled from "styled-components";
1+
import styled, { keyframes } from "styled-components";
22
import checkImage from "../../assets/ic-check-circle-green.svg";
33
import closeImage from "../../assets/ic-xmark.svg";
4+
import { mountAnimation } from "../animated-mount/mount-animation";
5+
6+
const openAnimation = keyframes`
7+
from { opacity: 0 }
8+
to { opacity: 1 }
9+
`;
10+
11+
const closeAnimation = keyframes`
12+
from { opacity: 1 }
13+
to { opacity: 0 }
14+
`;
415

516
const StyledToast = styled.div`
617
background-color: rgba(0, 0, 0, 0.8);
@@ -20,6 +31,12 @@ const StyledToast = styled.div`
2031
left: 50%;
2132
bottom: 70px;
2233
transform: translateX(-50%);
34+
${({ $isOpen }) =>
35+
mountAnimation({
36+
isOpen: $isOpen,
37+
open: openAnimation,
38+
close: closeAnimation,
39+
})};
2340
2441
p {
2542
margin: 0;
@@ -56,14 +73,14 @@ const IconButton = styled(Icon)`
5673
cursor: pointer;
5774
`;
5875

59-
function Toast({ message, onDismiss }) {
76+
function Toast({ isOpen, message, onClose, onDismiss }) {
6077
return (
61-
<StyledToast>
78+
<StyledToast $isOpen={isOpen} onAnimationEnd={onDismiss}>
6279
<Icon>
6380
<img src={checkImage} alt="확인" />
6481
</Icon>
6582
<p>{message}</p>
66-
<IconButton as="button" onClick={onDismiss}>
83+
<IconButton as="button" onClick={onClose}>
6784
<img src={closeImage} alt="닫기" />
6885
</IconButton>
6986
</StyledToast>

src/features/message/components/message-card-add.jsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import styled from "styled-components";
22
import plusImage from "../../../assets/ic-plus.svg";
33
import Colors from "../../../components/color/colors";
44
import { media } from "../../../utils/media";
5+
import MessageCardBase from "./message-card-base";
56

67
const AddCircle = styled.div`
78
width: 56px;
@@ -14,13 +15,12 @@ const AddCircle = styled.div`
1415
`;
1516

1617
const StyledMessageCardAdd = styled.button`
18+
width: 100%;
19+
background: none;
1720
border: none;
1821
display: flex;
1922
justify-content: center;
2023
align-items: center;
21-
border-radius: 16px;
22-
background-color: white;
23-
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.08);
2424
min-height: 280px;
2525
cursor: pointer;
2626
@@ -35,11 +35,13 @@ const StyledMessageCardAdd = styled.button`
3535

3636
function MessageCardAdd({ onClick }) {
3737
return (
38-
<StyledMessageCardAdd onClick={onClick}>
39-
<AddCircle>
40-
<img src={plusImage} alt="Message 추가" />
41-
</AddCircle>
42-
</StyledMessageCardAdd>
38+
<MessageCardBase>
39+
<StyledMessageCardAdd onClick={onClick}>
40+
<AddCircle>
41+
<img src={plusImage} alt="Message 추가" />
42+
</AddCircle>
43+
</StyledMessageCardAdd>
44+
</MessageCardBase>
4345
);
4446
}
4547

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import styled, { keyframes } from "styled-components";
2+
3+
const mountAnimation = keyframes`
4+
from {
5+
transform: translateY(36px);
6+
}
7+
8+
to {
9+
transform: initial;
10+
}
11+
`;
12+
13+
function animationDelay({ $index = 0 }) {
14+
const delay = 150;
15+
return `${delay * $index}ms`;
16+
}
17+
18+
const StyledMessageCardBase = styled.div`
19+
background-color: white;
20+
border-radius: 16px;
21+
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.08);
22+
overflow: hidden;
23+
animation: ${mountAnimation} 900ms ${animationDelay} backwards;
24+
25+
${({ $useScaleTransform }) =>
26+
$useScaleTransform
27+
? `
28+
transition: transform 300ms;
29+
30+
&:hover {
31+
transform: scale(1.02);
32+
}
33+
`
34+
: ""};
35+
`;
36+
37+
function MessageCardBase({ useScaleTransform, index, children }) {
38+
return (
39+
<StyledMessageCardBase
40+
$index={index}
41+
$useScaleTransform={useScaleTransform}
42+
>
43+
{children}
44+
</StyledMessageCardBase>
45+
);
46+
}
47+
48+
export default MessageCardBase;

0 commit comments

Comments
 (0)