Skip to content

Commit

Permalink
✨ Feat: 월 선택 시 색상 변경 (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
alwn8918 committed Sep 17, 2024
1 parent dd6a4ff commit 8709298
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
9 changes: 8 additions & 1 deletion acoountbook/src/components/home/month/Month.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ import MonthItem from "./MonthItem";

export default function Month() {
const months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
const [selected, setSelected] = useState();

return (
<M.Container>
{months.map((month) => (
<MonthItem key={month} month={month.toString()} />
<MonthItem
key={month}
month={month.toString()}
isSelected={selected === month}
onClick={() => setSelected(month)}
/>
))}
</M.Container>
);
Expand Down
8 changes: 6 additions & 2 deletions acoountbook/src/components/home/month/MonthItem.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import * as M from "./MonthItem.style";

export default function MonthItem({ month }) {
return <M.Button>{month}</M.Button>;
export default function MonthItem({ month, isSelected, onClick }) {
return (
<M.Button isSelected={isSelected} onClick={onClick}>
{month}
</M.Button>
);
}
3 changes: 2 additions & 1 deletion acoountbook/src/components/home/month/MonthItem.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const Button = styled.button`
font-size: 18px;
font-weight: 600;
background-color: #f5f5f5;
background-color: ${(props) => (props.isSelected ? "#92b1d4" : "#f5f5f5")};
color: ${(props) => (props.isSelected ? "white" : "black")};
&:hover {
color: white;
Expand Down

0 comments on commit 8709298

Please sign in to comment.