Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/Transformers/BeatmapsetCompactTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function transform(Beatmapset $beatmapset)
'title' => $beatmapset->title,
'title_unicode' => $beatmapset->title_unicode,
'track_id' => $beatmapset->track_id,
'is_exclusive_track' => $beatmapset->track?->exclusive ?? false,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this just can't be here as it'll cause one additional query for each beatmapset

'user_id' => $beatmapset->user_id,
'video' => $beatmapset->video,
];
Expand Down
6 changes: 6 additions & 0 deletions resources/css/bem/beatmapset-badge.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@
--colour-hover: hsl(var(--hsl-blue-1));
}

&--exclusive {
--colour: hsl(var(--hsl-pink-2));
--colour-hover: hsl(var(--hsl-pink-1));
}

&--nsfw {
--colour: hsl(var(--hsl-orange-2));
--colour-hover: hsl(var(--hsl-orange-1));
}

&--panel {
Expand Down
1 change: 1 addition & 0 deletions resources/js/beatmap-discussions/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export class Header extends React.Component<Props> {
<h2 className={`${bn}__title ${bn}__title--artist`}>
{getArtist(this.beatmapset)}
<BeatmapsetBadge beatmapset={this.beatmapset} type='featured_artist' />
<BeatmapsetBadge beatmapset={this.beatmapset} type='exclusive' />
</h2>
</div>
<div className={`${bn}__filters`}>
Expand Down
1 change: 1 addition & 0 deletions resources/js/beatmapset-panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ export default class BeatmapsetPanel extends React.Component<Props> {
</a>
<div className="beatmapset-panel__badge-container">
<BeatmapsetBadge beatmapset={this.props.beatmapset} type='featured_artist' />
<BeatmapsetBadge beatmapset={this.props.beatmapset} type='exclusive' />
</div>
</div>

Expand Down
4 changes: 4 additions & 0 deletions resources/js/beatmapsets-show/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ export default class Header extends React.Component<Props> {
beatmapset={this.controller.beatmapset}
type='featured_artist'
/>
<BeatmapsetBadge
beatmapset={this.controller.beatmapset}
type='exclusive'
/>
</span>

<BeatmapsetMapping beatmapset={this.controller.beatmapset} />
Expand Down
11 changes: 9 additions & 2 deletions resources/js/components/beatmapset-badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,27 @@ import { wikiUrl } from 'utils/url';
interface Props {
beatmapset: BeatmapsetJson;
modifiers?: Modifiers;
type: 'featured_artist' | 'nsfw' | 'spotlight';
type: 'exclusive' | 'featured_artist' | 'nsfw' | 'spotlight';
}

export default function BeatmapsetBadge(props: Props) {
let url: string | undefined;

switch (props.type) {
case 'exclusive':
if ((props.beatmapset.track_id == null) || !props.beatmapset.is_exclusive_track) return null;

url = route('tracks.show', { track: props.beatmapset.track_id });
break;
case 'featured_artist':
if (props.beatmapset.track_id == null) return null;
if ((props.beatmapset.track_id == null) || props.beatmapset.is_exclusive_track) return null;

url = route('tracks.show', { track: props.beatmapset.track_id });
break;
case 'nsfw':
if (!props.beatmapset.nsfw) return null;

url = wikiUrl('Rules/Explicit_content');
break;
case 'spotlight':
if (!props.beatmapset.spotlight) return null;
Expand Down
2 changes: 2 additions & 0 deletions resources/js/interfaces/beatmapset-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ interface BeatmapsetJsonDefaultAttributes {
favourite_count: number;
hype: HypeData | null;
id: number;
is_exclusive_track: boolean;
nsfw: boolean;
offset: number;
play_count: number;
Expand Down Expand Up @@ -146,6 +147,7 @@ export function deletedBeatmapset(): BeatmapsetJson {
favourite_count: 0,
hype: null,
id: 0,
is_exclusive_track: false,
nsfw: false,
offset: 0,
play_count: 0,
Expand Down
4 changes: 4 additions & 0 deletions resources/lang/en/beatmapsets.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
'label' => 'Featured Artist',
],

'exclusive_badge' => [
'label' => 'osu! original',
],

'index' => [
'title' => 'Beatmaps Listing',
'guest_title' => 'Beatmaps',
Expand Down
1 change: 1 addition & 0 deletions resources/views/docs/_structures/beatmapset.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ recent_favourites |
related_users | | |
user | | |
track_id | integer | |
is_exclusive_track | boolean | |

<div id="beatmapset-covers" data-unique="beatmapset-covers"></div>

Expand Down