-
Notifications
You must be signed in to change notification settings - Fork 387
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
Add song preview to contest entry for submitted beatmap #11225
Open
Exotica0122
wants to merge
13
commits into
ppy:master
Choose a base branch
from
Exotica0122:contest-thumbnail-song-preview
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fe2af87
rewrite contest entry in typescript
Exotica0122 269cbe4
show track preview with cover image in contest entry
Exotica0122 abfec4f
refactor track preview cover url name
Exotica0122 6b0fe4f
Merge branch 'master' into contest-thumbnail-song-preview
Exotica0122 0a5a5ff
add licence to contest entry
Exotica0122 971ced6
ignore import error for coffeescript component
Exotica0122 c40a0ff
Merge branch 'master' into contest-thumbnail-song-preview
Exotica0122 b16b029
add voter type declaration
Exotica0122 195b247
Merge branch 'master' into contest-thumbnail-song-preview
Exotica0122 a26e036
add licence text to voter type declaration
Exotica0122 5f85fc7
Merge branch 'master' into contest-thumbnail-song-preview
Exotica0122 a60a8fd
Merge branch 'master' into contest-thumbnail-song-preview
Exotica0122 9ad92ba
Merge branch 'master' into contest-thumbnail-song-preview
Exotica0122 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 was deleted.
Oops, something went wrong.
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,208 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
import TrackPreview from 'components/track-preview'; | ||
import { route } from 'laroute'; | ||
import { includes, round } from 'lodash'; | ||
import * as React from 'react'; | ||
import { transChoice } from 'utils/lang'; | ||
import UserLink from '../components/user-link'; | ||
import ContestEntryJson from '../interfaces/contest-entry-json'; | ||
import { ContestJsonForEntries } from '../interfaces/contest-json'; | ||
import { Voter } from './voter'; | ||
|
||
interface Props { | ||
contest: ContestJsonForEntries; | ||
entry: ContestEntryJson; | ||
hideIfNotVoted: boolean; | ||
options: { | ||
showLink: boolean; | ||
showPreview: boolean; | ||
}; | ||
rank: number; | ||
selected: number[]; | ||
waitingForResponse: boolean; | ||
winnerVotes: number; | ||
} | ||
|
||
export const Entry = (props: Props) => { | ||
const selected = includes(props.selected, props.entry.id); | ||
|
||
if (props.hideIfNotVoted && !selected) { | ||
return; | ||
} | ||
|
||
const linkIcon = | ||
props.contest.type === 'external' ? 'fa-external-link-alt' : 'fa-download'; | ||
|
||
const relativeVotePercentage = props.entry.results | ||
? round((props.entry.results.votes / props.winnerVotes) * 100, 2) | ||
: 0; | ||
|
||
const usersVotedPercentage = props.entry.results | ||
? round( | ||
(props.entry.results.votes / props.contest.users_voted_count) * 100, | ||
2, | ||
) | ||
: 0; | ||
|
||
const renderUserLink = () => { | ||
if (!props.entry.user) { | ||
return <></>; | ||
} | ||
|
||
return ( | ||
<UserLink | ||
className="contest-voting-list__entrant" | ||
user={props.entry.user} | ||
/> | ||
); | ||
}; | ||
|
||
const renderTitle = () => { | ||
if (props.contest.type === 'external') { | ||
return ( | ||
<> | ||
<a className="contest-voting-list__title-link u-ellipsis-overflow u-relative"> | ||
{props.entry.title} | ||
</a> | ||
{renderUserLink()} | ||
</> | ||
); | ||
} | ||
|
||
if ( | ||
props.options.showLink && | ||
props.entry.preview !== null && | ||
props.contest.submitted_beatmaps | ||
) { | ||
return ( | ||
<> | ||
<a | ||
className="contest-voting-list__title-link u-ellipsis-overflow u-relative" | ||
href={route('beatmapsets.show', { | ||
beatmapset: props.entry.preview, | ||
})} | ||
> | ||
{props.entry.title} | ||
</a> | ||
{renderUserLink()} | ||
</> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<div className="u-relative u-ellipsis-overflow"> | ||
{props.entry.title} | ||
</div> | ||
{renderUserLink()} | ||
</> | ||
); | ||
}; | ||
|
||
return ( | ||
<div | ||
className={`contest-voting-list__row${ | ||
selected && !props.contest.show_votes | ||
? ' contest-voting-list__row--selected' | ||
: '' | ||
}`} | ||
> | ||
{props.contest.show_votes && ( | ||
<div className="contest-voting-list__rank"> | ||
{props.rank < 4 ? ( | ||
<span | ||
className={`contest-voting-list__trophy contest-voting-list__trophy--${props.rank}`} | ||
> | ||
<i className="fas fa-fw fa-trophy" /> | ||
</span> | ||
) : ( | ||
`#${props.rank}` | ||
)} | ||
</div> | ||
)} | ||
{props.entry.preview !== undefined ? ( | ||
props.contest.submitted_beatmaps ? ( | ||
<div className="contest-voting-list__preview"> | ||
{props.entry.preview !== undefined && ( | ||
<TrackPreview | ||
track={{ | ||
coverUrl: `https://b.ppy.sh/thumb/${props.entry.preview}.jpg`, | ||
preview: props.entry.preview, | ||
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. this is very wrong |
||
}} | ||
/> | ||
)} | ||
</div> | ||
) : ( | ||
<div className="contest-voting-list__icon contest-voting-list__icon--bg"> | ||
<a | ||
className="contest-voting-list__link" | ||
href={props.entry.preview} | ||
rel="nofollow noreferrer" | ||
target="_blank" | ||
> | ||
<i className={`fas fa-fw fa-lg ${linkIcon}`} /> | ||
</a> | ||
</div> | ||
) | ||
) : ( | ||
<></> | ||
)} | ||
{props.contest.show_votes ? ( | ||
<div className="contest-voting-list__title contest-voting-list__title--show-votes"> | ||
<div | ||
className="contest-voting-list__votes-bar" | ||
style={{ width: `${relativeVotePercentage}%` }} | ||
/> | ||
{renderTitle()} | ||
</div> | ||
) : ( | ||
<div className="contest-voting-list__title">{renderTitle()}</div> | ||
)} | ||
{!props.contest.judged && ( | ||
<div | ||
className={`contest__voting-star${ | ||
props.contest.show_votes ? ' contest__voting-star--dark-bg' : '' | ||
}`} | ||
> | ||
<Voter | ||
key={props.entry.id} | ||
contest={props.contest} | ||
entry={props.entry} | ||
selected={props.selected} | ||
waitingForResponse={props.waitingForResponse} | ||
/> | ||
</div> | ||
)} | ||
{props.contest.show_votes ? ( | ||
props.contest.best_of || props.contest.judged ? ( | ||
<div className="contest__vote-count contest__vote-count--no-percentages"> | ||
{props.entry.results && | ||
transChoice('contest.vote.points', props.entry.results.votes)} | ||
</div> | ||
) : ( | ||
<div className="contest__vote-count"> | ||
{props.entry.results && | ||
transChoice('contest.vote.count', props.entry.results.votes)} | ||
{Number.isFinite(usersVotedPercentage)} | ||
</div> | ||
) | ||
) : ( | ||
<></> | ||
)} | ||
{props.contest.judged && ( | ||
<div className="contest-voting-list__icon contest-voting-list__icon--bg"> | ||
<a | ||
className="contest-voting-list__link" | ||
href={route('contest-entries.judge-results', props.entry.id)} | ||
rel="noreferrer" | ||
target="_blank" | ||
> | ||
<i className="fas fa-fw fa-lg fa-external-link-alt" /> | ||
</a> | ||
</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,17 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
import ContestEntryJson from 'interfaces/contest-entry-json'; | ||
import { ContestJsonForEntries } from 'interfaces/contest-json'; | ||
import * as React from 'react'; | ||
|
||
interface Props { | ||
buttonId?: string; | ||
contest: ContestJsonForEntries; | ||
entry: ContestEntryJson; | ||
selected: number[]; | ||
theme?: string; | ||
waitingForResponse: boolean; | ||
} | ||
|
||
export class Voter extends React.Component<Props> {} |
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.
this function is too long and contains too many different things
(the original wasn't readable either and this conversion isn't helping at all if not making it a bit more verbose)