-
Notifications
You must be signed in to change notification settings - Fork 393
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
Convert game header component to typescript #12050
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
import BeatmapsetCover from 'components/beatmapset-cover'; | ||
import Mod from 'components/mod'; | ||
import StringWithComponent from 'components/string-with-component'; | ||
import TimeWithTooltip from 'components/time-with-tooltip'; | ||
import BeatmapJson from 'interfaces/beatmap-json'; | ||
import BeatmapsetJson from 'interfaces/beatmapset-json'; | ||
import LegacyMatchGameJson from 'interfaces/legacy-match-game-json'; | ||
import { route } from 'laroute'; | ||
import * as React from 'react'; | ||
import { getArtist, getTitle } from 'utils/beatmapset-helper'; | ||
import { classWithModifiers } from 'utils/css'; | ||
import { trans } from 'utils/lang'; | ||
|
||
interface Props { | ||
beatmap: BeatmapJson; | ||
beatmapset: BeatmapsetJson; | ||
game: LegacyMatchGameJson; | ||
} | ||
|
||
export default function GameHeader(props: Props) { | ||
const timeFormat = 'LTS'; | ||
|
||
let title = getTitle(props.beatmapset); | ||
const version = props.beatmap.version; | ||
if (version != null) { | ||
title += ` [${version}]`; | ||
} | ||
|
||
const startTime = (<TimeWithTooltip dateTime={props.game.start_time} format={timeFormat} />); | ||
const endTime = props.game.end_time != null | ||
? (<TimeWithTooltip dateTime={props.game.end_time} format={timeFormat} />) | ||
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. the |
||
: null; | ||
|
||
return ( | ||
<a | ||
className='mp-history-game__header' | ||
href={props.beatmap.id != null ? route('beatmaps.show', { beatmap: props.beatmap.id }) : ''}> | ||
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.
|
||
<BeatmapsetCover | ||
beatmapset={props.beatmapset} | ||
modifiers='full' | ||
size='cover' /> | ||
<div className='mp-history-game__header-overlay' /> | ||
<div className='mp-history-game__stats-box'> | ||
<span className='mp-history-game__stat'> | ||
{endTime != null | ||
? <StringWithComponent | ||
mappings={{ | ||
endTime, | ||
startTime, | ||
}} | ||
pattern=':startTime - :endTime' /> | ||
: <StringWithComponent | ||
mappings={{ | ||
inProgress: trans('matches.match.in-progress'), | ||
startTime, | ||
}} | ||
pattern=':startTime :inProgress' />} | ||
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. Oh, I forgot to mention - I'm kinda inventing with this one because I don't think anything else does ad-hoc patterns like this (at least I can't grep any) but maybe this is better than the previous code which was kinda hard to parse? 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. a plain |
||
</span> | ||
<span className='mp-history-game__stat'>{trans(`beatmaps.mode.${props.game.mode}`)}</span> | ||
<span className='mp-history-game__stat'>{trans(`matches.game.scoring-type.${props.game.scoring_type}`)}</span> | ||
</div> | ||
<div className='mp-history-game__metadata-box'> | ||
<h1 className={classWithModifiers('mp-history-game__metadata', ['title'])}>{title}</h1> | ||
<h2 className={classWithModifiers('mp-history-game__metadata', ['artist'])}>{getArtist(props.beatmapset)}</h2> | ||
</div> | ||
<div className='mp-history-game__mods'> | ||
{props.game.mods.map((mod) => (<Mod key={mod} mod={{ acronym: mod }} />))} | ||
</div> | ||
<div | ||
className='mp-history-game__team-type' | ||
style={{ | ||
backgroundImage: `url(/images/badges/team-types/${props.game.team_type}.svg`, | ||
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. missing closing |
||
}} | ||
title={trans(`matches.match.team-types.${props.game.team_type}`)} /> | ||
</a> | ||
); | ||
} |
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.
can be outside of the function