Skip to content

Commit

Permalink
#53 feat: onClick 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeongbowoon committed Jul 9, 2024
1 parent 4c2378a commit 361e484
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const buttonStyle = (isClicked: boolean) =>

...theme.text.body04,
color: `${isClicked ? theme.colors.blue_900 : theme.colors.gray_800}`,
fontWeight: isClicked ? 600 : 500,
fontWeight: 500,

cursor: 'pointer',
});
16 changes: 12 additions & 4 deletions src/page/showcase/component/CategoryChip/CategoryChip.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { buttonStyle } from '@/page/showcase/component/CategoryChip/CategoryChip.style';

import { ButtonHTMLAttributes } from 'react';
import { ButtonHTMLAttributes, useState } from 'react';

interface CategoryChipProps extends ButtonHTMLAttributes<HTMLButtonElement> {
onClick?: () => void;
isClicked?: boolean;
}

const CategoryChip = ({ children, isClicked = false, ...props }: CategoryChipProps) => {
const CategoryChip = ({ children, onClick, ...props }: CategoryChipProps) => {
const [isClicked, setIsClicked] = useState(false);

const handleClick = () => {
if (onClick) {
onClick();
}
setIsClicked((prev) => !prev);
};

return (
<button css={buttonStyle(isClicked)} {...props}>
<button css={buttonStyle(isClicked)} onClick={handleClick} {...props}>
{children}
</button>
);
Expand Down

0 comments on commit 361e484

Please sign in to comment.