Skip to content

Commit a73c817

Browse files
authored
Merge pull request #134 from cskime/Next-김참솔-sprint10
[김참솔] Sprint 10
2 parents aa5e087 + b725211 commit a73c817

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+6298
-592
lines changed

my-app/components/button/button-type.js

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export enum ButtonType {
2+
add = "add",
3+
edit = "edit",
4+
delete = "delete",
5+
}

my-app/components/button/button.jsx

Lines changed: 0 additions & 27 deletions
This file was deleted.

my-app/components/button/button.module.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
font-size: 16px;
99
font-weight: 700;
1010
line-height: 100%;
11-
cursor: pointer;
1211
display: flex;
1312
align-items: center;
1413
gap: 4px;
@@ -22,17 +21,20 @@
2221
width: 100%;
2322
height: 100%;
2423
}
24+
.button:not(:disabled) {
25+
cursor: pointer;
26+
}
2527

26-
.button.add:active {
28+
.button.add:not(:disabled) {
2729
color: white;
2830
background-color: var(--color-violet-600);
2931
}
30-
.button.add:active img {
32+
.button.add:not(:disabled) img {
3133
filter: invert(100%) sepia(14%) saturate(1801%) hue-rotate(190deg)
3234
brightness(116%) contrast(101%);
3335
}
3436

35-
.button.edit:active {
37+
.button.edit:not(:disabled) {
3638
background-color: var(--color-lime-300);
3739
}
3840

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { ButtonHTMLAttributes, ReactNode } from "react";
2+
import { ButtonType } from "./button-type";
3+
import styles from "./button.module.css";
4+
5+
const className: {
6+
[key in keyof typeof ButtonType]: string;
7+
} = {
8+
[ButtonType.add]: `${styles.button} ${styles.add}`,
9+
[ButtonType.edit]: `${styles.button} ${styles.edit}`,
10+
[ButtonType.delete]: `${styles.button} ${styles.delete}`,
11+
};
12+
13+
const leadingIcon: {
14+
[key in keyof typeof ButtonType]: string;
15+
} = {
16+
[ButtonType.add]: "/icons/ic-plus.svg",
17+
[ButtonType.edit]: "/icons/ic-check.svg",
18+
[ButtonType.delete]: "/icons/ic-xmark-white.svg",
19+
};
20+
21+
interface Props extends ButtonHTMLAttributes<HTMLButtonElement> {
22+
children: ReactNode;
23+
buttonType: keyof typeof ButtonType;
24+
}
25+
26+
function Button({ children, buttonType = ButtonType.add, ...props }: Props) {
27+
return (
28+
<button className={className[buttonType]} {...props}>
29+
<div className={styles.trailingIcon}>
30+
<img src={leadingIcon[buttonType]} alt={buttonType} />
31+
</div>
32+
{children}
33+
</button>
34+
);
35+
}
36+
37+
export default Button;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export enum ColorName {
2+
state = "state",
3+
violet = "violet",
4+
rose = "rose",
5+
lime = "lime",
6+
amber = "amber",
7+
}

my-app/components/color/color.js renamed to my-app/components/color/color.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
function colorVariable(name, shade) {
1+
import { ColorName } from "./color-name";
2+
3+
function colorVariable(name: string, shade: number) {
24
return `var(--color-${name}-${Math.max(100, Math.min(900, shade))})`;
35
}
46

5-
const Colors = {
6-
state: {
7+
const Colors: {
8+
[key in keyof typeof ColorName]: { [key: number]: string };
9+
} = {
10+
[ColorName.state]: {
711
100: colorVariable("state", 100),
812
200: colorVariable("state", 200),
913
300: colorVariable("state", 300),
@@ -12,17 +16,17 @@ const Colors = {
1216
800: colorVariable("state", 800),
1317
900: colorVariable("state", 900),
1418
},
15-
violet: {
19+
[ColorName.violet]: {
1620
100: colorVariable("violet", 100),
1721
600: colorVariable("violet", 600),
1822
},
19-
rose: {
23+
[ColorName.rose]: {
2024
500: colorVariable("rose", 500),
2125
},
22-
lime: {
26+
[ColorName.lime]: {
2327
300: colorVariable("lime", 300),
2428
},
25-
amber: {
29+
[ColorName.amber]: {
2630
800: colorVariable("amber", 800),
2731
},
2832
};

my-app/components/input/search-input.jsx renamed to my-app/components/input/search-input.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { InputHTMLAttributes } from "react";
12
import styles from "./search-input.module.css";
23

3-
function SearchInput({ ...props }) {
4+
interface Props extends InputHTMLAttributes<HTMLInputElement> {}
5+
6+
function SearchInput({ ...props }: Props) {
47
return (
58
<div className={styles.searchInput}>
69
<input type="text" {...props} />

my-app/components/portal/portal.jsx renamed to my-app/components/portal/portal.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
import { useEffect, useState } from "react";
1+
import { ReactNode, useEffect, useState } from "react";
22
import { createPortal } from "react-dom";
33

4-
function Portal({ children }) {
5-
const [container, setContainer] = useState(null);
4+
interface Props {
5+
children: ReactNode;
6+
}
7+
8+
function Portal({ children }: Props) {
9+
const [container, setContainer] = useState<HTMLElement | null>(null);
610

711
useEffect(() => {
812
// setContainer(document.getElementById("portal"));

0 commit comments

Comments
 (0)