Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 resources/css/bem-index.less
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@
@import "bem/user-search-card";
@import "bem/user-session-list";
@import "bem/user-session-list-session";
@import "bem/user-tag";
@import "bem/user-verification";
@import "bem/user-verification-popup";
@import "bem/username-change";
Expand Down
8 changes: 7 additions & 1 deletion resources/css/bem/beatmapset-info.less
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

@media @desktop {
padding: 15px @gutter-beatmapset-desktop 0;
grid-template-columns: 1fr 175px @beatmapset-float-box-width;
grid-template-columns: 1fr minmax(175px, min-content) @beatmapset-float-box-width;
}

&__box {
Expand Down Expand Up @@ -104,4 +104,10 @@
pointer-events: none;
}
}

&__tags {
display: flex;
flex-wrap: wrap;
gap: 5px;
}
}
26 changes: 26 additions & 0 deletions resources/css/bem/user-tag.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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.

.user-tag {
.default-border-radius();
.link-plain();
display: flex;
overflow: hidden;
color: hsl(var(--hsl-c1));

&__item {
padding: 3px 6px;

&--category {
background: hsl(var(--hsl-b3));
}

&--count {
background: hsl(var(--hsl-b5));
}

&--name {
background: hsl(var(--hsl-b2));
}
}
}
4 changes: 1 addition & 3 deletions resources/js/beatmapsets-show/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// See the LICENCE file in the repository root for full licence text.

import { BeatmapsetJsonForShow } from 'interfaces/beatmapset-extended-json';
import TagJson from 'interfaces/tag-json';
import TagJson, { TagJsonWithCount } from 'interfaces/tag-json';
import UserJson from 'interfaces/user-json';
import { keyBy } from 'lodash';
import { action, computed, makeObservable, observable, runInAction } from 'mobx';
Expand All @@ -25,8 +25,6 @@ interface State {
showingNsfwWarning: boolean;
}

type TagJsonWithCount = TagJson & { count: number };

export default class Controller {
@observable hoveredBeatmap: null | BeatmapJsonForBeatmapsetShow = null;
@observable state: State;
Expand Down
13 changes: 3 additions & 10 deletions resources/js/beatmapsets-show/info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { trans } from 'utils/lang';
import { present } from 'utils/string';
import Controller from './controller';
import MetadataEditor from './metadata-editor';
import UserTag from './user-tag';

interface Props {
controller: Controller;
Expand Down Expand Up @@ -192,17 +193,9 @@ export default class Info extends React.Component<Props> {
<h3 className='beatmapset-info__header beatmapset-info__header--sticky'>
{trans('beatmapsets.show.info.user_tags')}
</h3>
<div>
<div className='beatmapset-info__tags'>
{this.controller.tags.userTags.map((tag) => (
<React.Fragment key={tag.name}>
<a
className='beatmapset-info__link'
href={route('beatmapsets.index', { q: makeSearchQueryOption('tag', tag.name) })}
>
{tag.name}
</a>
{' '}
</React.Fragment>
<UserTag key={tag.name} tag={tag} />
))}
</div>
</div>
Expand Down
44 changes: 44 additions & 0 deletions resources/js/beatmapsets-show/user-tag.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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 { TagJsonWithCount } from 'interfaces/tag-json';
import { route } from 'laroute';
import * as React from 'react';
import { makeSearchQueryOption } from 'utils/beatmapset-helper';

interface Props {
tag: TagJsonWithCount;
}

export default class UserTag extends React.PureComponent<Props> {
private readonly category;
private readonly name;

private get url() {
return route('beatmapsets.index', { q: makeSearchQueryOption('tag', this.props.tag.name) });
}

constructor(props: Props) {
super(props);

const split = props.tag.name.split('/');
this.category = split[0];
this.name = split[1];
}

render() {
return (
<a
className='user-tag'
href={this.url}
title={this.props.tag.description}
>
<span className='user-tag__item user-tag__item--category'>{this.category}</span>
<span className='user-tag__item user-tag__item--name'>{this.name}</span>
<span className='user-tag__item user-tag__item--count'>{this.props.tag.count}</span>
</a>
);
}
}


2 changes: 2 additions & 0 deletions resources/js/interfaces/tag-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ export default interface TagJson {
id: number;
name: string;
}

export type TagJsonWithCount = TagJson & { count: number };