-
Notifications
You must be signed in to change notification settings - Fork 32
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
Enhance Quiz Rankings and UI Optimization & Fix Challenge Dialog Flickering Issue #87
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6198855
fix: hide the title without quiz related course
Coooder-Crypto 506d696
fix: resolve flickering issue when closing challenge modal on the quiz
Coooder-Crypto ffb0d96
feat: whole rank list modal for quiz
Coooder-Crypto 5ac2f34
feat: quiz description markdown support
Coooder-Crypto 2dc79e3
fix: improve code according to feedback
Coooder-Crypto 5dbc901
merge
Coooder-Crypto b3aa1c0
Merge remote-tracking branch 'upstream/test' into test
Coooder-Crypto 5cfb4cf
fix: fix the bug according to feedback
Coooder-Crypto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* Copyright 2024 OpenBuild | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use client'; | ||
|
||
import Image from 'next/image'; | ||
import Rank1Icon from 'public/images/svg/rank-1.svg'; | ||
import Rank2Icon from 'public/images/svg/rank-2.svg'; | ||
import Rank3Icon from 'public/images/svg/rank-3.svg'; | ||
import { useMediaUrl } from '#/state/application/hooks'; | ||
|
||
export default function RankList({ rank, list }) { | ||
const mediaUrl = useMediaUrl(); | ||
|
||
return ( | ||
<div className="flex flex-col h-full"> | ||
<div className="border border-gray-600 rounded flex flex-col h-full overflow-hidden"> | ||
<h6 className="h-12 bg-gray-1000 text-center leading-[48px] relative flex-shrink-0"> | ||
Quiz Scoreboard | ||
{rank > 0 && ( | ||
<p className="absolute right-6 top-[14px] text-sm font-normal"> | ||
<span className="opacity-60">My ranking: </span> | ||
{rank} | ||
</p> | ||
)} | ||
</h6> | ||
<ul className="p-4 overflow-y-auto flex-grow"> | ||
{list?.map((i, k) => ( | ||
<li key={`QuizScoreboard-${k}`} className="flex items-center justify-between mb-4 last:mb-0"> | ||
<div className="flex items-center"> | ||
{k === 0 && <Image alt="" src={Rank1Icon} className="mr-2 w-5" />} | ||
{k === 1 && <Image alt="" src={Rank2Icon} className="mr-2 w-5" />} | ||
{k === 2 && <Image alt="" src={Rank3Icon} className="mr-2 w-5" />} | ||
{k > 2 && <span className="inline-block w-5 text-center mr-2 text-xs opacity-40">{k + 1}</span>} | ||
{mediaUrl && i?.user?.user_avatar ? ( | ||
<Image | ||
className="h-6 w-6 rounded object-cover mr-2" | ||
height={24} | ||
width={24} | ||
alt={'user_avatar'} | ||
src={`${mediaUrl}${i.user.user_avatar}`} | ||
/> | ||
) : ( | ||
<span className="h-6 w-6 rounded-full bg-gray-200 mr-2 flex items-center justify-center text-xs"> | ||
{i?.user?.user_nick_name?.[0]?.toUpperCase() || 'U'} | ||
</span> | ||
)} | ||
<p className="text-[12px] max-md:leading-[20px] md:text-sm"> | ||
<a href={`/u/${i?.user?.user_handle}`}>{i?.user?.user_nick_name}</a> | ||
</p> | ||
</div> | ||
<p className="max-md:text-[12px] max-md:leading-[24px]">{i?.score}</p> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright 2024 OpenBuild | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { Modal } from '@/components/Modal'; | ||
import RankList from './RankList'; | ||
import { useState } from 'react'; | ||
import { fetchRankList } from '#/domain/quiz/repository'; | ||
import Loader from '@/components/Loader'; | ||
import { ModalCloseIcon } from '@/components/Icons'; | ||
import useMounted from '@/hooks/useMounted'; | ||
|
||
export function RankListModal({ quizId, shown, onClose, rank }) { | ||
const [data, setData] = useState(null); | ||
const [loading, setLoading] = useState(true); | ||
|
||
useMounted(() => { | ||
setLoading(true); | ||
fetchRankList({ quizId }) | ||
.then(res => { | ||
setData(res?.data?.list?.rank); | ||
}) | ||
.finally(() => { | ||
setLoading(false); | ||
}); | ||
}); | ||
|
||
return ( | ||
<Modal isOpen={shown} closeModal={onClose} container mode="640"> | ||
<ModalCloseIcon | ||
onClick={onClose} | ||
className="absolute top-[-48px] md:top-[-32px] right-0 md:right-[-32px] cursor-pointer" | ||
/> | ||
<div className="md:h-[600px] h-[400px] flex flex-col overflow-y-auto rounded-inherit overflow-hidden"> | ||
{loading && <Loader classname="mr-2" />} | ||
<RankList rank={rank} list={data} /> | ||
</div> | ||
</Modal> | ||
); | ||
} |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
这层
div
多余的吧?