Skip to content
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 header navigation links on team page #11837

Merged
merged 3 commits into from
Feb 12, 2025
Merged
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
28 changes: 28 additions & 0 deletions app/Http/Controllers/TeamsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@ public function __construct()
$this->middleware('auth', ['only' => ['part']]);
}

public static function pageLinks(string $current, Team $team): array
{
$ret = [
[
'active' => $current === 'show',
'title' => osu_trans('teams.header_links.show'),
'url' => route('teams.show', ['team' => $team->getKey()]),
],
];

if (priv_check('TeamUpdate', $team)->can()) {
$applicationCount = $team->applications()->count();
$ret[] = [
'active' => $current === 'edit',
'title' => osu_trans('teams.header_links.edit'),
'url' => route('teams.edit', ['team' => $team->getKey()]),
];
$ret[] = [
'active' => $current === 'members.index',
'count' => $applicationCount === 0 ? null : $applicationCount,
'title' => osu_trans('teams.header_links.members.index'),
'url' => route('teams.members.index', ['team' => $team->getKey()]),
];
}

return $ret;
}

public function destroy(string $id): Response
{
$team = Team::findOrFail($id);
Expand Down
16 changes: 0 additions & 16 deletions resources/css/bem/btn-circle.less
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,6 @@
position: relative;
}

&__count {
.center-content();

background-color: hsl(var(--hsl-red-2));
border-radius: 10000px;
font-size: @font-size--small;

height: 2em;
width: 2em;

position: absolute;
right: 0;
top: 0;
transform: translate(50%, -50%);
}

&__icon {
.full-size();
.center-content();
Expand Down
7 changes: 6 additions & 1 deletion resources/css/bem/fake-bold.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
// See the LICENCE file in the repository root for full licence text.

.fake-bold {
&::after {
&::after,
&::before {
content: attr(data-content);
font-weight: bold;
opacity: 0;
pointer-events: none;
display: block;
height: 0;
}
// some text may be longer at normal weight (ex: "manage members")
&::before {
font-weight: normal;
}
}
15 changes: 14 additions & 1 deletion resources/css/bem/header-nav-v4.less
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@
}

&__link {
position: relative;
align-items: baseline;
display: flex;
gap: 2px 5px;
padding: var(--header-nav-item-padding-y) 0;
position: relative;

&::before {
display: none;
Expand Down Expand Up @@ -96,6 +99,16 @@
}
}

&__link-count {
background: hsl(var(--hsl-red-2));
// keep the original 1em
padding: (1em * (1em - $font-size) / 2 / $font-size) 10px;
font-size: 0.7em;
border-radius: @border-radius-large;
color: hsl(var(--hsl-c1));
font-weight: normal;
}

&__text {
padding: var(--header-nav-item-padding-y) 0;
}
Expand Down
6 changes: 6 additions & 0 deletions resources/lang/en/page_title.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
],
'teams_controller' => [
'_' => 'teams',
'edit' => 'team settings',
'show' => 'team info',
],
'tournaments_controller' => [
Expand All @@ -134,6 +135,11 @@
'store' => [
'_' => 'store',
],
'teams' => [
'members_controller' => [
'index' => 'team members',
],
],
'users' => [
'modding_history_controller' => [
'_' => 'modder info',
Expand Down
9 changes: 9 additions & 0 deletions resources/lang/en/teams.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@
],
],

'header_links' => [
'edit' => 'settings',
'show' => 'info',

'members' => [
'index' => 'manage members',
],
],

'members' => [
'destroy' => [
'success' => 'Team member removed',
Expand Down
5 changes: 5 additions & 0 deletions resources/views/layout/_page_header_v4.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ class="
class="fake-bold"
data-content="{{ $link['title'] }}"
>{{ $link['title'] }}</span>
@if (isset($link['count']))
<span class="header-nav-v4__link-count">
{{ i18n_number_format($link['count']) }}
</span>
@endif
</a>
@else
<span class="header-nav-v4__text">{{ $link['title'] }}</span>
Expand Down
12 changes: 5 additions & 7 deletions resources/views/teams/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
@extends('master')

@section('content')
@include('layout._page_header_v4')
@include('layout._page_header_v4', ['params' => [
'backgroundImage' => $team->header()->url(),
'links' => App\Http\Controllers\TeamsController::pageLinks('edit', $team),
'theme' => 'team',
]])

<form
method="POST"
Expand Down Expand Up @@ -181,12 +185,6 @@ class="btn-osu-big btn-osu-big--danger btn-osu-big--rounded-thin"
</div>

<div class="team-settings__buttons">
<a
class="btn-osu-big btn-osu-big--rounded-thin"
href="{{ route('teams.show', ['team' => $team]) }}"
>
{{ osu_trans('common.buttons.cancel') }}
</a>
<button class="btn-osu-big btn-osu-big--rounded-thin">
{{ osu_trans('common.buttons.save') }}
</button>
Expand Down
20 changes: 2 additions & 18 deletions resources/views/teams/members/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

@section('content')
@include('layout._page_header_v4', ['params' => [
'theme' => 'team',
'backgroundImage' => $team->header()->url(),
'links' => App\Http\Controllers\TeamsController::pageLinks('members.index', $team),
'theme' => 'team',
]])

<div class="osu-page osu-page--generic-compact">
Expand Down Expand Up @@ -151,23 +152,6 @@ class="u-contents"
</ul>
@endif
</div>

<div class="page-extra">
<div class="team-settings">
<div class="team-settings__item team-settings__item--buttons">
<div>
<a
class="btn-osu-big btn-osu-big--rounded-thin"
href="{{ route('teams.show', ['team' => $team]) }}"
>
{{ osu_trans('common.buttons.back') }}
</a>
</div>

<div></div>
</div>
</div>
</div>
</div>
</div>
@endsection
35 changes: 3 additions & 32 deletions resources/views/teams/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,17 @@

@section('content')
@include('layout._page_header_v4', ['params' => [
'theme' => 'team',
'backgroundImage' => $headerUrl,
'links' => App\Http\Controllers\TeamsController::pageLinks('show', $team),
'theme' => 'team',
]])

<div class="osu-page osu-page--generic-compact">
<div class="profile-info profile-info--cover profile-info--team">
<div
class="profile-info__bg profile-info__bg--team"
{!! background_image($headerUrl) !!}
>
@if (priv_check('TeamUpdate', $team)->can())
<div class="profile-page-cover-editor-button">
<a
class="btn-circle btn-circle--page-toggle"
data-tooltip-position="left center"
href="{{ route('teams.members.index', $team) }}"
title="{{ osu_trans('teams.members.index.title') }}"
>
<span class="fa fa-users"></span>
@php
$applicationCount = $team->applications()->count();
@endphp
@if ($applicationCount > 0)
<span class="btn-circle__count">
{{ i18n_number_format($applicationCount) }}
</span>
@endif
</a>

<a
class="btn-circle btn-circle--page-toggle"
data-tooltip-position="left center"
href="{{ route('teams.edit', $team) }}"
title="{{ osu_trans('teams.edit.title') }}"
>
<span class="fa fa-wrench"></span>
</a>
</div>
@endif
</div>
></div>
<div class="profile-info__details">
<div class="profile-info__avatar">
@include('objects._flag_team', ['modifiers' => 'full', 'team' => $team])
Expand Down