Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[User] Fix: preset button component #27

Merged
merged 5 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ui/components/admin/Uploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const Uploader: React.FC<UploaderProps> = ({ fileList, setFileList }) => {
return (
<div className="w-full">
<Dragger className="w-full" maxCount={1} {...props}>
<p className="text-6xl text-blue-600">
<p className="6xl·text-blue-600">
<InboxOutlined />
</p>
<p className="text-xl">파일을 드래그해주세요</p>
Expand Down
19 changes: 5 additions & 14 deletions src/ui/components/atom/preset/preset-button.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
import React, { useState } from 'react';
import React from 'react';
import { cn } from '../../../../utils/style';

interface PresetButtonProps {
onClick?: React.MouseEventHandler<HTMLButtonElement>;
isSelected?: boolean;
disabled?: boolean;
children: string;
}

const PresetButton = ({ onClick, disabled, children }: PresetButtonProps) => {
const [isClicked, setIsClicked] = useState(false);

const handleClick: React.MouseEventHandler<HTMLButtonElement> = (e) => {
if (onClick) {
onClick(e);
}
setIsClicked(true);
setTimeout(() => setIsClicked(false), 300); // 클릭 후 200ms 후에 초기화
};

const PresetButton = ({ onClick, isSelected, disabled, children }: PresetButtonProps) => {
const buttonClasses = cn(
'cursor-pointer rounded-full border border-gray text-black bg-white px-4 py-2 ',
isClicked ? 'bg-primary-blue text-white border-primary-blue' : 'bg-white text-black',
isSelected ? 'bg-primary-blue text-white border-primary-blue' : 'bg-white text-black',
disabled ? 'bg-border-gray cursor-not-allowed text-border-gray bg-text-white' : '',
);

return (
<button className={buttonClasses} onClick={handleClick} disabled={disabled}>
<button className={buttonClasses} onClick={onClick} disabled={disabled}>
{children}
</button>
);
Expand Down
20 changes: 16 additions & 4 deletions src/ui/pages/maru-egg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ import useTypeStore from '../../store/type-store';
import ChatCard from '../components/atom/chat-card/chat-card';
import ChatForm from '../components/molecule/user/chat-form/chat-form';
import useChatStore from '../../store/chat-store';
import PresetButton from '../components/atom/preset/preset-button';

const MaruEgg: React.FC = () => {
const { setSelectedType, type } = useTypeStore();
const { messages } = useChatStore();
const [selectedButton, setSelectedButton] = React.useState<'SUSI' | 'PYEONIP' | 'JEONGSI' | null>(null);

const handleButtonClick = (selectedType: 'SUSI' | 'PYEONIP' | 'JEONGSI') => {
setSelectedType(selectedType);
setSelectedButton(selectedType);
};

return (
<div className="h-full min-w-[360px] bg-background-default">
<div className="h-screen min-w-[360px] bg-background-default">
<Header type={type} />

<div className="w-full px-4 pb-24 pt-16">
Expand All @@ -23,9 +27,17 @@ const MaruEgg: React.FC = () => {
알아보고 싶은 전형을 선택해주세요!`}
role="system"
/>
<button onClick={() => handleButtonClick('SUSI')}>Select SUSI</button>
<button onClick={() => handleButtonClick('PYEONIP')}>Select PYEONIP</button>
<button onClick={() => handleButtonClick('JEONGSI')}>Select JEONGSI</button>
<div className="flex space-x-2">
<PresetButton onClick={() => handleButtonClick('SUSI')} isSelected={selectedButton === 'SUSI'}>
수시
</PresetButton>
<PresetButton onClick={() => handleButtonClick('PYEONIP')} isSelected={selectedButton === 'PYEONIP'}>
편입
</PresetButton>
<PresetButton onClick={() => handleButtonClick('JEONGSI')} isSelected={selectedButton === 'JEONGSI'}>
정시
</PresetButton>
</div>
{type !== null && (
<ChatCard role="user" content={type === 'SUSI' ? '수시' : type === 'JEONGSI' ? '정시' : '편입'} />
)}
Expand Down
Loading