Skip to content

Commit ebfcb67

Browse files
authored
Merge pull request #90 from cskime/feature/#83
[#83] DangerousButton component 개발
2 parents 017589c + b7ec94a commit ebfcb67

File tree

6 files changed

+70
-22
lines changed

6 files changed

+70
-22
lines changed

src/components/button/button.jsx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,37 @@ function OutlinedButton({ className, title, icon, size, ...props }) {
215215
);
216216
}
217217

218-
export { OutlinedButton, PrimaryButton, SecondaryButton };
218+
/* Dangerous Button */
219+
220+
const StyledDangerousButton = styled(BaseButton)`
221+
padding: 0 24px;
222+
background-color: ${Colors.red(600)};
223+
color: white;
224+
225+
&:hover {
226+
background-color: ${Colors.red(700)};
227+
}
228+
229+
&:active {
230+
background-color: ${Colors.red(800)};
231+
}
232+
233+
&:focus {
234+
background-color: ${Colors.red(800)};
235+
box-shadow: 0 0 0 1px ${Colors.red(900)} inset;
236+
}
237+
238+
&:disabled {
239+
background-color: ${Colors.gray(300)};
240+
}
241+
`;
242+
243+
function DangerousButton({ title, size, ...props }) {
244+
return (
245+
<StyledDangerousButton $size={size} {...props}>
246+
<span>{title}</span>
247+
</StyledDangerousButton>
248+
);
249+
}
250+
251+
export { DangerousButton, OutlinedButton, PrimaryButton, SecondaryButton };

src/components/color/colors.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const Colors = {
1818
gray: function (value) {
1919
return `var(--color-gray-${shade({ value })})`;
2020
},
21+
red: function (value) {
22+
return `var(--color-red-${shade({ value })})`;
23+
},
2124
error: "var(--color-error)",
2225
surface: "var(--color-surface)",
2326
};

src/pages/messages-page.jsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { useEffect, useMemo, useState } from "react";
22
import { useLocation, useNavigate, useParams } from "react-router";
33
import styled from "styled-components";
4-
import { OutlinedButton, PrimaryButton } from "../components/button/button";
4+
import {
5+
DangerousButton,
6+
OutlinedButton,
7+
PrimaryButton,
8+
} from "../components/button/button";
59
import BUTTON_SIZE from "../components/button/button-size";
610
import BACKGROUND_COLOR from "../components/color/background-color";
711
import {
@@ -74,14 +78,14 @@ function ViewerButtons({ onEdit }) {
7478
function EditingButtons({ onDelete, onCancel }) {
7579
return (
7680
<ButtonContainer>
77-
<PrimaryButton
81+
<DangerousButton
7882
size={BUTTON_SIZE.medium}
7983
title="삭제하기"
8084
onClick={onDelete}
8185
/>
8286
<OutlinedButton
8387
size={BUTTON_SIZE.medium}
84-
title="완료하기"
88+
title="완료"
8589
onClick={onCancel}
8690
/>
8791
</ButtonContainer>

src/styles/colors.css

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
:root {
2-
/* Semantics */
3-
4-
--color-error: #dc3a3a;
5-
--color-surface: #f6f8ff;
6-
72
/* Palette */
83

94
--color-purple-100: #f8f0ff;
@@ -43,4 +38,19 @@
4338
--color-gray-700: #3a3a3a;
4439
--color-gray-800: #2b2b2b;
4540
--color-gray-900: #181818;
41+
42+
--color-red-100: #fef2f2;
43+
--color-red-200: #fecaca;
44+
--color-red-300: #fca5a5;
45+
--color-red-400: #f87171;
46+
--color-red-500: #dc3a3a;
47+
--color-red-600: #dc2626;
48+
--color-red-700: #b91c1c;
49+
--color-red-800: #991b1b;
50+
--color-red-900: #7f1d1d;
51+
52+
/* Semantics */
53+
54+
--color-error: var(--color-red-500);
55+
--color-surface: #f6f8ff;
4656
}

src/tests/test-api-page.jsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useCallback, useEffect, useState } from "react";
22
import styled from "styled-components";
3-
import { PrimaryButton } from "../components/button/button";
3+
import { DangerousButton, PrimaryButton } from "../components/button/button";
44
import BUTTON_SIZE from "../components/button/button-size";
55
import Colors from "../components/color/colors";
66
import {
@@ -250,23 +250,13 @@ function TestApiPage() {
250250
/>
251251
</Row>
252252
<Row>
253-
<PrimaryButton
254-
style={
255-
recipients.length === 0
256-
? undefined
257-
: { backgroundColor: Colors.error }
258-
}
253+
<DangerousButton
259254
size={buttonSize}
260255
title="롤링페이퍼 삭제"
261256
onClick={handleDeleteRecipientsClick}
262257
disabled={recipients.length === 0}
263258
/>
264-
<PrimaryButton
265-
style={
266-
recipients.length === 0
267-
? undefined
268-
: { backgroundColor: Colors.error }
269-
}
259+
<DangerousButton
270260
size={buttonSize}
271261
title="메시지 삭제"
272262
onClick={handleDeleteMessagesClick}

src/tests/test-components-page.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import EmojiBadge from "../components/badge/emoji-badge";
99
import ArrowButton from "../components/button/arrow-button";
1010
import ARROW_BUTTON_DIRECTION from "../components/button/arrow-button-direction";
1111
import {
12+
DangerousButton,
1213
OutlinedButton,
1314
PrimaryButton,
1415
SecondaryButton,
@@ -79,6 +80,13 @@ function TestComponentsPage() {
7980
<OutlinedButton size={BUTTON_SIZE.extraSmall} title="Hello" />
8081
<OutlinedButton size={BUTTON_SIZE.extraSmall} title="Hello" disabled />
8182
</div>
83+
<div style={{ display: "flex", alignItems: "center", gap: 16 }}>
84+
<DangerousButton size={BUTTON_SIZE.large} title="Hello" />
85+
<DangerousButton size={BUTTON_SIZE.medium} title="Hello" />
86+
<DangerousButton size={BUTTON_SIZE.small} title="Hello" />
87+
<DangerousButton size={BUTTON_SIZE.extraSmall} title="Hello" />
88+
<DangerousButton size={BUTTON_SIZE.extraSmall} title="Hello" disabled />
89+
</div>
8290
<div style={{ display: "flex", alignItems: "center", gap: 16 }}>
8391
<OutlinedButton
8492
size={BUTTON_SIZE.medium}

0 commit comments

Comments
 (0)