-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
180 additions
and
85 deletions.
There are no files selected for viewing
36 changes: 29 additions & 7 deletions
36
src/components/common/Buttons/AdminSignupPreview/AdminSignupPreview.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,29 @@ | ||
.element { | ||
background-color: var(--color-primary); | ||
&:hover { | ||
background-color: var(--color-onPrimaryFixedVariant); | ||
} | ||
} | ||
|
||
@import url('src/theme/fonts/pretendard.css'); | ||
|
||
.tableContainer { | ||
padding: 20px; | ||
background-color: #fff; /* 배경색을 하얀색으로 설정 */ | ||
border-radius: 0; /* 모서리를 90도로 설정 */ | ||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); | ||
font-family: "Pretendard Variable", __Pretendard_Fallback_e223ab, sans-serif; | ||
} | ||
|
||
.table { | ||
width: 100%; | ||
border-collapse: collapse; | ||
} | ||
|
||
.table th, .table td { | ||
padding: 10px; /* 행 간 간격을 유지 */ | ||
padding-left: 20px; /* 열 간격을 늘리기 위해 좌우 패딩 조정 */ | ||
padding-right: 20px; /* 열 간격을 늘리기 위해 좌우 패딩 조정 */ | ||
text-align: left; | ||
} | ||
|
||
.table th { | ||
border-bottom: 2px solid #000; | ||
} | ||
|
||
.table td { | ||
border-bottom: none; /* 회색 구분선을 제거 */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,11 @@ type Story = StoryObj<typeof meta>; | |
|
||
export const Usage: Story = { | ||
args: { | ||
name: 'John Doe', | ||
email: '[email protected]', | ||
role: 'Administrator', | ||
signups: [ | ||
{ id: 1, applicant: '김교수', date: '2024/07/05', category: '교수', remark: '' }, | ||
{ id: 2, applicant: '나공기업', date: '2024/07/05', category: '공공기관', remark: '인공지능지원사업부' }, | ||
{ id: 3, applicant: '김교수', date: '2024/07/05', category: '교수', remark: '' }, | ||
{ id: 4, applicant: '나공기업', date: '2024/07/05', category: '공공기관', remark: '인공지능지원사업부' }, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,30 @@ import { AdminSignupPreview } from './AdminSignupPreview'; | |
import '@testing-library/jest-dom'; | ||
|
||
describe('AdminSignupPreview component', () => { | ||
it('renders correctly with the given props', () => { | ||
render(<AdminSignupPreview name="John Doe" email="[email protected]" role="Administrator" />); | ||
expect(screen.getByText('Admin Signup Preview')).toBeInTheDocument(); | ||
expect(screen.getByText('John Doe')).toBeInTheDocument(); | ||
expect(screen.getByText('[email protected]')).toBeInTheDocument(); | ||
expect(screen.getByText('Administrator')).toBeInTheDocument(); | ||
it('renders correctly with given props', () => { | ||
const signups = [ | ||
{ id: 1, applicant: '김교수', date: '2024/07/05', category: '교수', remark: '' }, | ||
{ id: 2, applicant: '나공기업', date: '2024/07/05', category: '공공기관', remark: '인공지능지원사업부' }, | ||
{ id: 3, applicant: '김교수', date: '2024/07/05', category: '교수', remark: '' }, | ||
{ id: 4, applicant: '나공기업', date: '2024/07/05', category: '공공기관', remark: '인공지능지원사업부' }, | ||
]; | ||
|
||
render(<AdminSignupPreview signups={signups} />); | ||
|
||
expect(screen.getByText('ID')).toBeInTheDocument(); | ||
expect(screen.getByText('신청자')).toBeInTheDocument(); | ||
expect(screen.getByText('신청일')).toBeInTheDocument(); | ||
expect(screen.getByText('분류')).toBeInTheDocument(); | ||
expect(screen.getByText('비고')).toBeInTheDocument(); | ||
|
||
signups.forEach((signup) => { | ||
expect(screen.getByText(signup.id)).toBeInTheDocument(); | ||
expect(screen.getByText(signup.applicant)).toBeInTheDocument(); | ||
expect(screen.getByText(signup.date)).toBeInTheDocument(); | ||
expect(screen.getByText(signup.category)).toBeInTheDocument(); | ||
if (signup.remark) { | ||
expect(screen.getByText(signup.remark)).toBeInTheDocument(); | ||
} | ||
}); | ||
}); | ||
}); |
42 changes: 33 additions & 9 deletions
42
src/components/common/Buttons/AdminSignupPreview/AdminSignupPreview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,43 @@ | ||
import React from 'react'; | ||
import classes from './AdminSignupPreview.module.css'; | ||
|
||
interface Signup { | ||
id: number; | ||
applicant: string; | ||
date: string; | ||
category: string; | ||
remark?: string; | ||
} | ||
|
||
interface AdminSignupPreviewProps { | ||
name: string; | ||
email: string; | ||
role: string; | ||
signups: Signup[]; | ||
} | ||
|
||
export const AdminSignupPreview: React.FC<AdminSignupPreviewProps> = ({ name, email, role }) => { | ||
export const AdminSignupPreview: React.FC<AdminSignupPreviewProps> = ({ signups }) => { | ||
return ( | ||
<div className={classes.element}> | ||
<h3>Admin Signup Preview</h3> | ||
<p><strong>Name:</strong> {name}</p> | ||
<p><strong>Email:</strong> {email}</p> | ||
<p><strong>Role:</strong> {role}</p> | ||
<div className={classes.tableContainer}> | ||
<table className={classes.table}> | ||
<thead> | ||
<tr> | ||
<th>ID</th> | ||
<th>신청자</th> | ||
<th>신청일</th> | ||
<th>분류</th> | ||
<th>비고</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{signups.map((signup) => ( | ||
<tr key={signup.id}> | ||
<td>{signup.id}</td> | ||
<td>{signup.applicant}</td> | ||
<td>{signup.date}</td> | ||
<td>{signup.category}</td> | ||
<td>{signup.remark}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 31 additions & 7 deletions
38
src/components/common/Buttons/RadioButton/RadioButton.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,31 @@ | ||
.element { | ||
background-color: var(--color-primary); | ||
&:hover { | ||
background-color: var(--color-onPrimaryFixedVariant); | ||
} | ||
} | ||
|
||
@import url('src/theme/fonts/pretendard.css'); | ||
|
||
.radioButton { | ||
appearance: none; | ||
width: 30px; /* 사이즈를 사진 크기에 맞게 조정 */ | ||
height: 30px; /* 사이즈를 사진 크기에 맞게 조정 */ | ||
border: 2px solid #3a5a8d; | ||
border-radius: 50%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
cursor: pointer; | ||
outline: none; | ||
background-color: white; | ||
} | ||
|
||
.radioButton::before { | ||
content: ''; | ||
width: 14px; /* 내부 원 크기 조정 */ | ||
height: 14px; /* 내부 원 크기 조정 */ | ||
border-radius: 50%; | ||
background-color: #3a5a8d; | ||
} | ||
|
||
.radioButton.checked::before { | ||
background-color: red; | ||
} | ||
|
||
.radioButton.checked { | ||
border-color: red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 23 additions & 17 deletions
40
src/components/common/Buttons/RadioButton/RadioButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
import React from 'react'; | ||
import React, { useState, useEffect } from 'react'; | ||
import classes from './RadioButton.module.css'; | ||
|
||
interface RadioButtonProps { | ||
label: string; | ||
name: string; | ||
value: string; | ||
checked: boolean; | ||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
checked?: boolean; | ||
onChange?: (checked: boolean) => void; | ||
} | ||
|
||
export const RadioButton: React.FC<RadioButtonProps> = ({ label, name, value, checked, onChange }) => { | ||
export const RadioButton: React.FC<RadioButtonProps> = ({ checked = false, onChange }) => { | ||
const [isChecked, setIsChecked] = useState(checked); | ||
|
||
useEffect(() => { | ||
setIsChecked(checked); | ||
}, [checked]); | ||
|
||
const handleClick = () => { | ||
const newChecked = !isChecked; | ||
setIsChecked(newChecked); | ||
if (onChange) { | ||
onChange(newChecked); | ||
} | ||
}; | ||
|
||
return ( | ||
<label className={classes.element}> | ||
<input | ||
type="radio" | ||
name={name} | ||
value={value} | ||
checked={checked} | ||
onChange={onChange} | ||
/> | ||
{label} | ||
</label> | ||
<button | ||
type="button" | ||
className={`${classes.radioButton} ${isChecked ? classes.checked : ''}`} | ||
onClick={handleClick} | ||
></button> | ||
); | ||
}; |