-
Notifications
You must be signed in to change notification settings - Fork 7
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
Release #103
base: main
Are you sure you want to change the base?
Release #103
Changes from all commits
932d03a
f797f74
01ad03f
2fc1aac
b5b7060
827c250
c16f6d0
50f5d40
2c8b83e
a9ec66f
a8b2816
2829ca9
ef2714c
881affa
9c9c3ee
f9c8643
f1e6f9c
d9e13eb
375d6ac
a32604e
d264352
dea84be
babc74b
7650838
288bac9
4156aed
bba172f
57b405e
6a4ec6e
9c3a8db
992e8c3
f90e59c
f3f3326
cd9d045
e5cfb3c
2ab4131
97edb98
dfe5b7c
b4b0a6d
fc1da99
abd1d85
8479d19
e3a7b4e
edfcf36
15f875f
a8ef8e1
d4be2e5
002d1e2
94940a3
2992e96
c84b1a3
8abf78c
750c441
e59ad4a
14b506f
08d1b8a
2f5988c
7e76db8
b0612ec
fa1c804
150204c
c7d5cc9
8640d79
bca2252
dee3b19
8f32e2b
36d5fe6
6542ef7
d000d8e
fac196c
5845b4b
de54c8a
5c667f1
4dc2ba6
230873b
fb46d85
8d5608b
d79117b
8e9401c
b68ccf6
4037fdc
7017c74
9fc2bd4
93cb3c9
05c364f
d2566a8
1583163
1ea6883
65cd4ab
b8981b7
808f246
a06f3f4
c01658f
963d85d
f76f004
6339dd8
ed4cf41
dd26f44
08aee47
41b8faa
95729aa
34fd061
2cf75e3
d16bce2
cc387f1
8186f62
edd7e7a
9748472
309abef
8dd07e9
1eafc6b
5cedb58
8ae4c10
07d50be
bec08d6
7135633
42ffb9c
35c6b5c
3694ead
f1215aa
842bb98
ebb8962
cedde8f
2cc955d
93d45b0
fc470ab
db443f7
d9aace7
ef9700c
ead7a47
f646f98
06bfeec
c57a4c7
4e3599d
e72e831
77fd1c0
1aff129
79adfb0
660d472
e8a06d2
de46894
2a1e2c7
dee9af2
991570d
f78e325
6a27aec
b2e15d7
d7d96f1
c6c68bd
50e1cc2
49d8e46
ffe9bbc
0f565c2
4494656
09840ba
612a678
fed1600
0719e52
5ed8bb5
848b2ac
8d5bf72
2df10e6
ff68bb8
2be32b4
d047163
affbfae
dae8f91
c9c7c73
4d23e00
a819a4c
a5ca5ef
a96ba49
c6b101c
8cc9458
115e7ce
8fb922e
63b5f38
9e300c1
eeb7502
63b4bf5
3a1b1b3
9eec445
caf7de0
403dc15
eef7458
251c124
e782f02
62a91da
ee8c0e5
5a27c8e
5bc4a96
49940dd
a39f69d
81b091a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,10 @@ yarn-error.log* | |
next-env.d.ts | ||
|
||
# vscode | ||
.vscode | ||
.vscode | ||
|
||
# idea | ||
.idea | ||
|
||
# pnpm-lock | ||
pnpm-lock.yaml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { useState } from "react"; | ||
import { | ||
Tooltip, | ||
TooltipTrigger, | ||
TooltipContent, | ||
TooltipProvider, | ||
} from "@/components/ui/tooltip"; | ||
import { FaInfoCircle } from "react-icons/fa"; | ||
import Link from "next/link"; | ||
|
||
interface TooltipWithIconProps { | ||
title: string; | ||
linkText: string; | ||
linkHref: string; | ||
description: string; | ||
} | ||
|
||
const TooltipWithIcon: React.FC<TooltipWithIconProps> = ({ | ||
title, | ||
linkText, | ||
linkHref, | ||
description, | ||
}) => { | ||
return ( | ||
<TooltipProvider> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<span className="ml-2 relative"> | ||
{/* Information Icon */} | ||
<FaInfoCircle className="text-black cursor-pointer" size={18} /> | ||
</span> | ||
</TooltipTrigger> | ||
|
||
<TooltipContent | ||
side="right" | ||
align="center" | ||
className="bg-white text-black rounded-lg shadow-lg p-4 w-64" | ||
> | ||
<div className="font-bold mb-2">{title}</div> | ||
<div className="font-normal"> | ||
{description}{" "} | ||
<Link | ||
href={linkHref} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className="text-blue-500 hover:underline" | ||
> | ||
{linkText} | ||
</Link> | ||
. | ||
</div> | ||
</TooltipContent> | ||
</Tooltip> | ||
</TooltipProvider> | ||
); | ||
}; | ||
|
||
export default TooltipWithIcon; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from "react"; | ||
import { Avatar } from "@/components/ui/avatar"; | ||
|
||
interface Assertion { | ||
index: number; | ||
content: string; | ||
type: string; | ||
winner: number; // 候选人的 ID | ||
name: string; // 候选人名字 | ||
} | ||
|
||
interface AssertionTableProps { | ||
assertions: Assertion[]; | ||
} | ||
|
||
const AssertionTable: React.FC<AssertionTableProps> = ({ assertions }) => { | ||
return ( | ||
<div> | ||
<table className="min-w-full table-auto"> | ||
<thead> | ||
<tr> | ||
<th className="px-4 py-2 border-b">Index</th> | ||
<th className="px-4 py-2 border-b">Content</th> | ||
<th className="px-4 py-2 border-b">Type</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{assertions.map((assertion) => ( | ||
<tr key={assertion.index}> | ||
<td className="px-4 py-2 text-center border-b"> | ||
{assertion.index} | ||
</td> | ||
<td className="px-4 py-2 text-left border-b"> | ||
<div className="flex items-center justify-start"> | ||
<Avatar candidateId={assertion.winner} className="mr-2" /> | ||
<span>{assertion.content}</span> | ||
</div> | ||
</td> | ||
<td className="px-4 py-2 text-center border-b"> | ||
{assertion.type} | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AssertionTable; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { Avatar } from "@/components/ui/avatar"; | ||
import { FaInfoCircle } from "react-icons/fa"; | ||
import Link from "next/link"; | ||
import TooltipWithIcon from "@/app/dashboard/components/Information-icon-text"; | ||
|
||
// 更新 Assertion 接口,添加 candidateId 字段 | ||
interface Assertion { | ||
index: number; | ||
winner: number; | ||
content: string; | ||
type: string; | ||
difficulty: number; | ||
margin: number; | ||
} | ||
|
||
interface AssertionsDetailsModalProps { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
assertions: Assertion[]; | ||
maxDifficulty: number; | ||
minMargin: number; | ||
} | ||
|
||
const AssertionsDetailsModal: React.FC<AssertionsDetailsModalProps> = ({ | ||
isOpen, | ||
onClose, | ||
assertions, | ||
maxDifficulty, | ||
minMargin, | ||
}) => { | ||
const [isTooltipVisible, setTooltipVisible] = useState(false); | ||
useEffect(() => { | ||
if (isOpen) { | ||
document.body.style.overflow = "hidden"; | ||
} else { | ||
document.body.style.overflow = "auto"; | ||
} | ||
}, [isOpen]); | ||
|
||
if (!isOpen) return null; | ||
return ( | ||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-30"> | ||
<div className="bg-white rounded-lg max-w-3xl w-full mx-4 p-6 relative"> | ||
{/* 关闭按钮 */} | ||
<button | ||
onClick={onClose} | ||
className="absolute top-4 right-4 text-gray-600 hover:text-gray-800" | ||
aria-label="Close" | ||
> | ||
{/* SVG 图标 */} | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
className="h-6 w-6" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
stroke="currentColor" | ||
> | ||
<path | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth={2} | ||
d="M6 18L18 6M6 6l12 12" | ||
/> | ||
</svg> | ||
</button> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 关闭按钮应该lucide里面有,不需要自己找svg图标 |
||
<h2 className="text-2xl font-bold mb-4 flex items-center relative"> | ||
Assertions Details | ||
<TooltipWithIcon | ||
title="Need Help?" | ||
description="For detailed guidance on understanding the assertion attributes, please refer to our" | ||
linkText="Tutorial" | ||
linkHref="/tutorial" | ||
/> | ||
</h2> | ||
<div className="mb-4"> | ||
<p className="text-gray-700 font-bold"> | ||
<span className="font-semibold">Maximum Difficulty:</span>{" "} | ||
{maxDifficulty}{" "} | ||
<span className="font-semibold">Minimum Margin:</span> {minMargin} | ||
</p> | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不需要用这么多 {“ ”}, 应该有其他方案 |
||
|
||
<div className="overflow-x-auto"> | ||
<table className="min-w-full table-auto"> | ||
<thead> | ||
<tr> | ||
<th scope="col" className="px-4 py-2 border-b text-left"> | ||
Index | ||
</th> | ||
<th scope="col" className="px-4 py-2 border-b text-left"> | ||
Content | ||
</th> | ||
<th scope="col" className="px-4 py-2 border-b text-left"> | ||
Type | ||
</th> | ||
<th scope="col" className="px-4 py-2 border-b text-left"> | ||
Difficulty | ||
</th> | ||
<th scope="col" className="px-4 py-2 border-b text-left"> | ||
Margin | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{assertions.map((assertion) => ( | ||
<tr key={assertion.index}> | ||
<td className="px-4 py-2 border-b">{assertion.index}</td> | ||
<td className="px-4 py-2 text-left border-b"> | ||
<div className="flex items-center justify-start"> | ||
{/* 使用 Avatar 组件,传入 candidateId */} | ||
<Avatar candidateId={assertion.winner} className="mr-2" /> | ||
<span>{assertion.content}</span> | ||
</div> | ||
</td> | ||
<td className="px-4 py-2 border-b">{assertion.type}</td> | ||
<td className="px-4 py-2 border-b">{assertion.difficulty}</td> | ||
<td className="px-4 py-2 border-b">{assertion.margin}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 用shadcn自带的表格,不要用table |
||
|
||
export default AssertionsDetailsModal; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//avatar-assign-color.tsx | ||
import React, { useEffect, useMemo, useState } from "react"; | ||
import useMultiWinnerDataStore from "@/store/multi-winner-data"; | ||
import { AvatarColor } from "@/utils/avatar-color"; | ||
|
||
interface AvatarProps { | ||
onComplete: () => void; | ||
} | ||
|
||
const AvatarAssignColor: React.FC<AvatarProps> = ({ onComplete }) => { | ||
const { candidateList, setCandidateList } = useMultiWinnerDataStore(); | ||
const avatarColor = useMemo(() => new AvatarColor(), []); | ||
const [hasCompleted, setHasCompleted] = useState(false); | ||
|
||
useEffect(() => { | ||
if (hasCompleted) return; | ||
|
||
console.log("candidateList:", candidateList); | ||
|
||
if (candidateList.length === 0) { | ||
onComplete(); | ||
setHasCompleted(true); | ||
return; | ||
} | ||
|
||
let hasUpdated = false; | ||
|
||
const updatedCandidates = candidateList.map((candidate, index) => { | ||
if (!candidate.color) { | ||
hasUpdated = true; | ||
const color = avatarColor.getColor(index); | ||
return { ...candidate, color }; | ||
} | ||
return candidate; | ||
}); | ||
|
||
if (hasUpdated) { | ||
setCandidateList(updatedCandidates); | ||
} | ||
|
||
onComplete(); | ||
setHasCompleted(true); | ||
}, [candidateList, avatarColor, setCandidateList, onComplete, hasCompleted]); | ||
|
||
return ( | ||
<div> | ||
{candidateList.map((candidate) => ( | ||
<div key={candidate.id} style={{ backgroundColor: candidate.color }}> | ||
{candidate.name} | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default AvatarAssignColor; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from "react"; | ||
|
||
interface CardProps { | ||
title: string; | ||
value: string | number; | ||
icon?: React.ReactNode; | ||
} | ||
|
||
const Card: React.FC<CardProps> = ({ title, value, icon }) => { | ||
return ( | ||
<div className="border border-gray-300 rounded-lg p-6 flex items-center justify-between w-full max-w-sm"> | ||
<div> | ||
<h3 className="text-gray-600 text-lg font-medium">{title}</h3> | ||
<p className="text-3xl font-bold">{value}</p> | ||
</div> | ||
{icon && <div className="text-gray-400 text-3xl">{icon}</div>} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Card; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shadcn应该有合适的table了,不需要用table标签来写