mirror of https://github.com/Chocobozzz/PeerTube
Header blocks
parent
857507dd1d
commit
8636708004
|
@ -8,25 +8,8 @@
|
|||
class="peertube-container"
|
||||
[ngClass]="{ 'user-logged-in': isUserLoggedIn(), 'user-not-logged-in': !isUserLoggedIn(), 'hotkeys-modal-opened': hotkeysModalOpened }"
|
||||
>
|
||||
<header class="root-header">
|
||||
|
||||
<div class="top-left-block">
|
||||
<button
|
||||
class="border-0 p-0" [title]="getToggleTitle()" (click)="menu.toggleMenu()" (keyup.enter)="menu.toggleMenu()"
|
||||
[ariaExpanded]="menu.isMenuDisplayed" aria-controls="left-menu"
|
||||
>
|
||||
<span class="icon icon-menu"></span>
|
||||
</button>
|
||||
|
||||
<a class="peertube-title c-hand" [routerLink]="getDefaultRoute()" [queryParams]="getDefaultRouteQuery()">
|
||||
<span class="icon icon-logo"></span>
|
||||
<span class="instance-name">{{ instanceName }}</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="root-header-right">
|
||||
<my-header class="w-100 d-flex justify-content-end"></my-header>
|
||||
</div>
|
||||
<header class="root-header mb-2">
|
||||
<my-header class="w-100"></my-header>
|
||||
</header>
|
||||
|
||||
<div class="sub-header-container">
|
||||
|
|
|
@ -36,72 +36,6 @@
|
|||
position: fixed;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
background-color: pvar(--mainBackgroundColor);
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.16);
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.top-left-block {
|
||||
z-index: 1;
|
||||
height: $header-height;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
|
||||
.icon {
|
||||
@include icon(24px);
|
||||
}
|
||||
|
||||
.icon-menu {
|
||||
mask-image: url('../assets/images/misc/menu.svg');
|
||||
-webkit-mask-image: url('../assets/images/misc/menu.svg');
|
||||
|
||||
background-color: pvar(--mainForegroundColor);
|
||||
margin: 0 18px 0 20px;
|
||||
|
||||
@media screen and (max-width: $mobile-view) {
|
||||
margin: 0 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.root-header-right {
|
||||
height: $header-height;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
white-space: nowrap;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.peertube-title {
|
||||
font-size: 20px;
|
||||
font-weight: $font-bold;
|
||||
color: inherit !important;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
padding: 0 0 0 10px;
|
||||
|
||||
@include disable-default-a-behaviour;
|
||||
|
||||
.instance-name {
|
||||
width: 100%;
|
||||
|
||||
@include ellipsis;
|
||||
|
||||
@media screen and (max-width: $mobile-view) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.icon.icon-logo {
|
||||
display: inline-block;
|
||||
width: 23px;
|
||||
height: 24px;
|
||||
|
||||
@include margin-right(0.5rem);
|
||||
}
|
||||
}
|
||||
|
||||
.broadcast-message {
|
||||
|
|
|
@ -106,10 +106,6 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||
this.ngbConfig.animation = false
|
||||
}
|
||||
|
||||
get instanceName () {
|
||||
return this.serverConfig.instance.name
|
||||
}
|
||||
|
||||
ngOnInit () {
|
||||
document.getElementById('incompatible-browser').className += ' browser-ok'
|
||||
|
||||
|
@ -160,22 +156,6 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
getDefaultRoute () {
|
||||
return this.redirectService.getDefaultRoute().split('?')[0]
|
||||
}
|
||||
|
||||
getDefaultRouteQuery () {
|
||||
return this.router.parseUrl(this.redirectService.getDefaultRoute()).queryParams
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
getToggleTitle () {
|
||||
if (this.menu.isDisplayed()) return $localize`Close the left menu`
|
||||
|
||||
return $localize`Open the left menu`
|
||||
}
|
||||
|
||||
isUserLoggedIn () {
|
||||
return this.authService.isLoggedIn()
|
||||
}
|
||||
|
|
|
@ -1,6 +1,104 @@
|
|||
<my-search-typeahead class="w-100 d-flex justify-content-center"></my-search-typeahead>
|
||||
<div class="root py-4 px-4 w-100 d-flex justify-content-between">
|
||||
<a class="peertube-title me-3" [routerLink]="getDefaultRoute()" [queryParams]="getDefaultRouteQuery()">
|
||||
<span class="icon icon-logo"></span>
|
||||
<span class="instance-name">{{ instanceName }}</span>
|
||||
</a>
|
||||
|
||||
<a class="peertube-button-link orange-button publish-button" routerLink="/videos/upload">
|
||||
<my-global-icon iconName="upload" aria-hidden="true"></my-global-icon>
|
||||
<span i18n class="publish-button-label">Publish</span>
|
||||
</a>
|
||||
<div class="d-flex align-items-center">
|
||||
<my-search-typeahead class="w-100 me-5"></my-search-typeahead>
|
||||
|
||||
@if (!isLoggedIn) {
|
||||
<my-button icon="cog" (click)="openQuickSettings()"></my-button>
|
||||
|
||||
<a *ngIf="isRegistrationAllowed()" routerLink="/signup" class="create-account-button peertube-button-link text-truncate d-block">
|
||||
<my-signup-label [requiresApproval]="requiresApproval"></my-signup-label>
|
||||
</a>
|
||||
|
||||
<my-login-link className="peertube-button-link orange-button w-100 text-truncate"></my-login-link>
|
||||
} @else {
|
||||
@defer (when isLoggedIn) {
|
||||
<my-notification-dropdown class="me-3" (navigate)="onActiveLinkScrollToAnchor($event)"></my-notification-dropdown>
|
||||
}
|
||||
|
||||
<my-button class="me-3" icon="cog" ptRouterLink="/my-account"></my-button>
|
||||
|
||||
<div
|
||||
class="logged-in-more" ngbDropdown #dropdown="ngbDropdown" placement="bottom-left auto"
|
||||
container="body" (openChange)="onDropdownOpenChange($event)"
|
||||
>
|
||||
<button class="button-unstyle" ngbDropdownToggle>
|
||||
<my-actor-avatar [actor]="user.account" actorType="account" size="34" class="me-2"></my-actor-avatar>
|
||||
|
||||
<div class="logged-in-info text-start">
|
||||
<div class="display-name ellipsis">{{ user.account?.displayName }}</div>
|
||||
|
||||
<div class="username ellipsis fs-8">@{{ user.username }}</div>
|
||||
</div>
|
||||
|
||||
<div class="dropdown-toggle-indicator">
|
||||
<span class="chevron-down"></span>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<div ngbDropdownMenu>
|
||||
<a
|
||||
*ngIf="user.account" ngbDropdownItem ngbDropdownToggle class="dropdown-item" [routerLink]="[ '/a', user.account.nameWithHost ]"
|
||||
#profile (click)="onActiveLinkScrollToAnchor(profile)"
|
||||
>
|
||||
<my-global-icon iconName="go" aria-hidden="true"></my-global-icon> <ng-container i18n>Public profile</ng-container>
|
||||
</a>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
<button
|
||||
myPluginSelector pluginSelectorId="menu-user-dropdown-language-item"
|
||||
ngbDropdownItem class="dropdown-item" (click)="openLanguageChooser()"
|
||||
>
|
||||
<my-global-icon iconName="language" aria-hidden="true"></my-global-icon>
|
||||
<span i18n>Interface:</span>
|
||||
<span class="ms-auto muted">{{ currentInterfaceLanguage }}</span>
|
||||
</button>
|
||||
|
||||
<a ngbDropdownItem class="dropdown-item" routerLink="/my-account/settings" fragment="video-languages-subtitles"
|
||||
#settingsLanguagesSubtitles (click)="onActiveLinkScrollToAnchor(settingsLanguagesSubtitles)">
|
||||
<my-global-icon iconName="video-lang" aria-hidden="true"></my-global-icon>
|
||||
<span i18n>Videos:</span>
|
||||
<span class="ms-auto muted">{{ videoLanguages.join(', ') }}</span>
|
||||
</a>
|
||||
|
||||
<a ngbDropdownItem class="dropdown-item settings-sensitive" routerLink="/my-account/settings"
|
||||
fragment="video-sensitive-content-policy" #settingsSensitiveContentPolicy
|
||||
(click)="onActiveLinkScrollToAnchor(settingsSensitiveContentPolicy)"
|
||||
>
|
||||
<my-global-icon class="hover-display-toggle" [hidden]="user.nsfwPolicy === 'display'" iconName="eye-open" aria-hidden="true"></my-global-icon>
|
||||
<my-global-icon class="hover-display-toggle" [hidden]="user.nsfwPolicy !== 'display'" iconName="eye-close" aria-hidden="true"></my-global-icon>
|
||||
<span i18n>Sensitive:</span>
|
||||
<span class="ms-auto muted">{{ nsfwPolicy }}</span>
|
||||
</a>
|
||||
|
||||
<button class="dropdown-item" (mousedown)="$event.stopPropagation(); toggleUseP2P()" [ariaPressed]="user.p2pEnabled" ngbDropdownItem>
|
||||
<my-global-icon iconName="p2p" aria-hidden="true"></my-global-icon>
|
||||
<ng-container i18n>Help share videos</ng-container>
|
||||
|
||||
<my-input-switch inputName="p2p-enabled" class="ms-auto" [preventUpdate]="true" [checked]="user.p2pEnabled"></my-input-switch>
|
||||
</button>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
<button *ngIf="!isInMobileView" ngbDropdownItem class="dropdown-item" (click)="openHotkeysCheatSheet()">
|
||||
<my-global-icon iconName="command" aria-hidden="true"></my-global-icon>
|
||||
<ng-container i18n>Keyboard shortcuts</ng-container>
|
||||
</button>
|
||||
|
||||
<button ngbDropdownItem (click)="logout($event)" class="dropdown-item">
|
||||
<my-global-icon iconName="sign-out" aria-hidden="true"></my-global-icon>
|
||||
<ng-container i18n>Log out</ng-container>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<my-language-chooser #languageChooserModal></my-language-chooser>
|
||||
<my-quick-settings #quickSettingsModal></my-quick-settings>
|
||||
|
|
|
@ -1,22 +1,89 @@
|
|||
@use 'sass:math';
|
||||
@use '_variables' as *;
|
||||
@use '_mixins' as *;
|
||||
|
||||
.publish-button {
|
||||
@include button-with-icon(21px, 3px, -1px);
|
||||
@include margin-right(25px);
|
||||
.peertube-title {
|
||||
font-size: 24px;
|
||||
font-weight: $font-bold;
|
||||
color: inherit !important;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
|
||||
@media screen and (max-width: $mobile-view) {
|
||||
padding-right: 10px;
|
||||
padding-left: 10px;
|
||||
@include padding-left(18px);
|
||||
@include disable-default-a-behaviour;
|
||||
|
||||
@include margin-right(10px);
|
||||
.instance-name {
|
||||
width: 100%;
|
||||
|
||||
.icon.icon-upload {
|
||||
@include margin-right(0);
|
||||
}
|
||||
@include ellipsis;
|
||||
|
||||
.publish-button-label {
|
||||
@media screen and (max-width: $mobile-view) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.icon.icon-logo {
|
||||
display: inline-block;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
|
||||
@include margin-right(10px);
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown {
|
||||
z-index: #{z('menu') + 1} !important;
|
||||
}
|
||||
|
||||
.dropdown-item {
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@include dropdown-with-icon-item;
|
||||
|
||||
&:hover {
|
||||
.hover-display-toggle {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.hover-display-toggle[hidden] {
|
||||
display: inherit !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.logged-in-more {
|
||||
flex: 1;
|
||||
border-radius: 25px;
|
||||
transition: all .1s ease-in-out;
|
||||
cursor: pointer;
|
||||
max-width: 250px;
|
||||
|
||||
> .dropdown-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
&::after {
|
||||
// Disable bootstrap toggle
|
||||
border: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-toggle-indicator {
|
||||
position: relative;
|
||||
display: none;
|
||||
width: 17px;
|
||||
|
||||
span {
|
||||
position: absolute;
|
||||
top: -8px;
|
||||
color: #808080;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.display-name {
|
||||
font-weight: $font-semibold;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,32 @@
|
|||
import { Component } from '@angular/core'
|
||||
import { CommonModule, ViewportScroller } from '@angular/common'
|
||||
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'
|
||||
import { Router, RouterLink, RouterLinkActive } from '@angular/router'
|
||||
import {
|
||||
AuthService,
|
||||
AuthStatus,
|
||||
AuthUser,
|
||||
HooksService,
|
||||
HotkeysService,
|
||||
MenuService,
|
||||
RedirectService,
|
||||
ScreenService,
|
||||
ServerService,
|
||||
UserService
|
||||
} from '@app/core'
|
||||
import { scrollToTop } from '@app/helpers'
|
||||
import { LanguageChooserComponent } from '@app/menu/language-chooser.component'
|
||||
import { NotificationDropdownComponent } from '@app/menu/notification-dropdown.component'
|
||||
import { QuickSettingsModalComponent } from '@app/menu/quick-settings-modal.component'
|
||||
import { ActorAvatarComponent } from '@app/shared/shared-actor-image/actor-avatar.component'
|
||||
import { InputSwitchComponent } from '@app/shared/shared-forms/input-switch.component'
|
||||
import { PeertubeModalService } from '@app/shared/shared-main/peertube-modal/peertube-modal.service'
|
||||
import { LoginLinkComponent } from '@app/shared/shared-main/users/login-link.component'
|
||||
import { SignupLabelComponent } from '@app/shared/shared-main/users/signup-label.component'
|
||||
import { NgbDropdown, NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { ServerConfig, VideoConstant } from '@peertube/peertube-models'
|
||||
import { Subscription, first, forkJoin } from 'rxjs'
|
||||
import { GlobalIconComponent } from '../shared/shared-icons/global-icon.component'
|
||||
import { RouterLink } from '@angular/router'
|
||||
import { ButtonComponent } from '../shared/shared-main/buttons/button.component'
|
||||
import { SearchTypeaheadComponent } from './search-typeahead.component'
|
||||
|
||||
@Component({
|
||||
|
@ -8,7 +34,264 @@ import { SearchTypeaheadComponent } from './search-typeahead.component'
|
|||
templateUrl: './header.component.html',
|
||||
styleUrls: [ './header.component.scss' ],
|
||||
standalone: true,
|
||||
imports: [ SearchTypeaheadComponent, RouterLink, GlobalIconComponent ]
|
||||
imports: [
|
||||
CommonModule,
|
||||
NotificationDropdownComponent,
|
||||
ActorAvatarComponent,
|
||||
InputSwitchComponent,
|
||||
SignupLabelComponent,
|
||||
LoginLinkComponent,
|
||||
LanguageChooserComponent,
|
||||
QuickSettingsModalComponent,
|
||||
GlobalIconComponent,
|
||||
RouterLink,
|
||||
RouterLinkActive,
|
||||
NgbDropdownModule,
|
||||
SearchTypeaheadComponent,
|
||||
RouterLink,
|
||||
GlobalIconComponent,
|
||||
ButtonComponent
|
||||
]
|
||||
})
|
||||
|
||||
export class HeaderComponent {}
|
||||
export class HeaderComponent implements OnInit, OnDestroy {
|
||||
@ViewChild('languageChooserModal', { static: true }) languageChooserModal: LanguageChooserComponent
|
||||
@ViewChild('quickSettingsModal', { static: true }) quickSettingsModal: QuickSettingsModalComponent
|
||||
@ViewChild('dropdown') dropdown: NgbDropdown
|
||||
|
||||
user: AuthUser
|
||||
isLoggedIn: boolean
|
||||
|
||||
hotkeysHelpVisible = false
|
||||
|
||||
videoLanguages: string[] = []
|
||||
nsfwPolicy: string
|
||||
|
||||
currentInterfaceLanguage: string
|
||||
|
||||
private languages: VideoConstant<string>[] = []
|
||||
|
||||
private serverConfig: ServerConfig
|
||||
|
||||
private languagesSub: Subscription
|
||||
private quickSettingsModalSub: Subscription
|
||||
private hotkeysSub: Subscription
|
||||
private authSub: Subscription
|
||||
|
||||
constructor (
|
||||
private viewportScroller: ViewportScroller,
|
||||
private authService: AuthService,
|
||||
private userService: UserService,
|
||||
private serverService: ServerService,
|
||||
private redirectService: RedirectService,
|
||||
private hotkeysService: HotkeysService,
|
||||
private screenService: ScreenService,
|
||||
private menuService: MenuService,
|
||||
private modalService: PeertubeModalService,
|
||||
private router: Router,
|
||||
private hooks: HooksService
|
||||
) { }
|
||||
|
||||
get isInMobileView () {
|
||||
return this.screenService.isInMobileView()
|
||||
}
|
||||
|
||||
get language () {
|
||||
return this.languageChooserModal.getCurrentLanguage()
|
||||
}
|
||||
|
||||
get requiresApproval () {
|
||||
return this.serverConfig.signup.requiresApproval
|
||||
}
|
||||
|
||||
get instanceName () {
|
||||
return this.serverConfig.instance.name
|
||||
}
|
||||
|
||||
ngOnInit () {
|
||||
this.currentInterfaceLanguage = this.languageChooserModal.getCurrentLanguage()
|
||||
|
||||
this.isLoggedIn = this.authService.isLoggedIn()
|
||||
this.updateUserState()
|
||||
|
||||
this.authSub = this.authService.loginChangedSource.subscribe(status => {
|
||||
if (status === AuthStatus.LoggedIn) {
|
||||
this.isLoggedIn = true
|
||||
} else if (status === AuthStatus.LoggedOut) {
|
||||
this.isLoggedIn = false
|
||||
}
|
||||
|
||||
this.updateUserState()
|
||||
})
|
||||
|
||||
this.hotkeysSub = this.hotkeysService.cheatSheetToggle
|
||||
.subscribe(isOpen => this.hotkeysHelpVisible = isOpen)
|
||||
|
||||
this.languagesSub = forkJoin([
|
||||
this.serverService.getVideoLanguages(),
|
||||
this.authService.userInformationLoaded.pipe(first())
|
||||
]).subscribe(([ languages ]) => {
|
||||
this.languages = languages
|
||||
|
||||
this.buildUserLanguages()
|
||||
})
|
||||
|
||||
this.serverService.getConfig()
|
||||
.subscribe(config => this.serverConfig = config)
|
||||
|
||||
this.quickSettingsModalSub = this.modalService.openQuickSettingsSubject
|
||||
.subscribe(() => this.openQuickSettings())
|
||||
}
|
||||
|
||||
ngOnDestroy () {
|
||||
if (this.quickSettingsModalSub) this.quickSettingsModalSub.unsubscribe()
|
||||
if (this.languagesSub) this.languagesSub.unsubscribe()
|
||||
if (this.hotkeysSub) this.hotkeysSub.unsubscribe()
|
||||
if (this.authSub) this.authSub.unsubscribe()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
getDefaultRoute () {
|
||||
return this.redirectService.getDefaultRoute().split('?')[0]
|
||||
}
|
||||
|
||||
getDefaultRouteQuery () {
|
||||
return this.router.parseUrl(this.redirectService.getDefaultRoute()).queryParams
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
isRegistrationAllowed () {
|
||||
if (!this.serverConfig) return false
|
||||
|
||||
return this.serverConfig.signup.allowed &&
|
||||
this.serverConfig.signup.allowedForCurrentIP
|
||||
}
|
||||
|
||||
logout (event: Event) {
|
||||
event.preventDefault()
|
||||
|
||||
this.authService.logout()
|
||||
// Redirect to home page
|
||||
this.redirectService.redirectToHomepage()
|
||||
}
|
||||
|
||||
openLanguageChooser () {
|
||||
this.languageChooserModal.show()
|
||||
}
|
||||
|
||||
openQuickSettings () {
|
||||
this.quickSettingsModal.show()
|
||||
}
|
||||
|
||||
toggleUseP2P () {
|
||||
if (!this.user) return
|
||||
this.user.p2pEnabled = !this.user.p2pEnabled
|
||||
|
||||
this.userService.updateMyProfile({ p2pEnabled: this.user.p2pEnabled })
|
||||
.subscribe(() => this.authService.refreshUserInformation())
|
||||
}
|
||||
|
||||
// FIXME: needed?
|
||||
onDropdownOpenChange (opened: boolean) {
|
||||
if (this.screenService.isInMobileView()) return
|
||||
|
||||
// Close dropdown when window scroll to avoid dropdown quick jump for re-position
|
||||
const onWindowScroll = () => {
|
||||
this.dropdown?.close()
|
||||
window.removeEventListener('scroll', onWindowScroll)
|
||||
}
|
||||
|
||||
if (opened) {
|
||||
window.addEventListener('scroll', onWindowScroll)
|
||||
document.querySelector('nav').scrollTo(0, 0) // Reset menu scroll to easy lock
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
document.querySelector('nav').addEventListener('scroll', this.onMenuScrollEvent)
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method
|
||||
document.querySelector('nav').removeEventListener('scroll', this.onMenuScrollEvent)
|
||||
}
|
||||
}
|
||||
|
||||
// Lock menu scroll when menu scroll to avoid fleeing / detached dropdown
|
||||
// FIXME: needed?
|
||||
onMenuScrollEvent () {
|
||||
document.querySelector('nav').scrollTo(0, 0)
|
||||
}
|
||||
|
||||
// FIXME: needed?
|
||||
onActiveLinkScrollToAnchor (link: HTMLAnchorElement) {
|
||||
const linkURL = link.getAttribute('href')
|
||||
const linkHash = link.getAttribute('fragment')
|
||||
|
||||
// On same url without fragment restore top scroll position
|
||||
if (!linkHash && this.router.url.includes(linkURL)) {
|
||||
scrollToTop('smooth')
|
||||
}
|
||||
|
||||
// On same url with fragment restore anchor scroll position
|
||||
if (linkHash && this.router.url === linkURL) {
|
||||
this.viewportScroller.scrollToAnchor(linkHash)
|
||||
}
|
||||
|
||||
if (this.screenService.isInSmallView()) {
|
||||
this.menuService.toggleMenu()
|
||||
}
|
||||
}
|
||||
|
||||
openHotkeysCheatSheet () {
|
||||
this.hotkeysService.cheatSheetToggle.next(!this.hotkeysHelpVisible)
|
||||
}
|
||||
|
||||
private buildUserLanguages () {
|
||||
if (!this.user) {
|
||||
this.videoLanguages = []
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.user.videoLanguages) {
|
||||
this.videoLanguages = [ $localize`any language` ]
|
||||
return
|
||||
}
|
||||
|
||||
this.videoLanguages = this.user.videoLanguages
|
||||
.map(locale => this.langForLocale(locale))
|
||||
.map(value => value === undefined ? '?' : value)
|
||||
}
|
||||
|
||||
private langForLocale (localeId: string) {
|
||||
if (localeId === '_unknown') return $localize`Unknown`
|
||||
|
||||
return this.languages.find(lang => lang.id === localeId).label
|
||||
}
|
||||
|
||||
private computeNSFWPolicy () {
|
||||
if (!this.user) {
|
||||
this.nsfwPolicy = null
|
||||
return
|
||||
}
|
||||
|
||||
switch (this.user.nsfwPolicy) {
|
||||
case 'do_not_list':
|
||||
this.nsfwPolicy = $localize`hide`
|
||||
break
|
||||
|
||||
case 'blur':
|
||||
this.nsfwPolicy = $localize`blur`
|
||||
break
|
||||
|
||||
case 'display':
|
||||
this.nsfwPolicy = $localize`display`
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
private updateUserState () {
|
||||
this.user = this.isLoggedIn
|
||||
? this.authService.getUser()
|
||||
: undefined
|
||||
|
||||
this.computeNSFWPolicy()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="d-inline-flex position-relative" id="typeahead-container">
|
||||
<div class="position-relative" id="typeahead-container">
|
||||
<input
|
||||
type="search" id="search-video" name="search-video" #searchVideo
|
||||
i18n-ariaLabel aria-label="Search videos, playlists, channels…" i18n-placeholder placeholder="Search videos, playlists, channels…"
|
||||
|
@ -6,7 +6,7 @@
|
|||
autocomplete="off" aria-describedby="typeahead-input-help"
|
||||
>
|
||||
|
||||
<button class="border-0 search-button" title="Search" i18n-title (click)="doSearch()">
|
||||
<button class="button-unstyle search-button" title="Search" i18n-title (click)="doSearch()">
|
||||
<my-global-icon iconName="search"></my-global-icon>
|
||||
</button>
|
||||
|
||||
|
|
|
@ -3,33 +3,47 @@
|
|||
|
||||
#search-video {
|
||||
text-overflow: ellipsis;
|
||||
line-height: 42px;
|
||||
|
||||
@include peertube-input-text($search-input-width, 14px);
|
||||
@include padding-left(10px);
|
||||
@include padding-right(40px); // For the search icon
|
||||
@include peertube-input-text(270px, 14px);
|
||||
@include padding-left(42px); // For the search icon
|
||||
@include padding-right(20px);
|
||||
|
||||
& {
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
|
||||
&::placeholder {
|
||||
color: pvar(--inputPlaceholderColor);
|
||||
}
|
||||
|
||||
@media screen and (max-width: $small-view) {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
@media screen and (max-width: $mobile-view) {
|
||||
width: 150px;
|
||||
}
|
||||
}
|
||||
|
||||
.search-button {
|
||||
display: inline-flex;
|
||||
align-self: center;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
|
||||
@include right(5px);
|
||||
@include left(18px);
|
||||
|
||||
&:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
my-global-icon {
|
||||
@include icon(18px);
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
|
||||
& {
|
||||
display: inline-flex;
|
||||
}
|
||||
position: relative;
|
||||
top: -2px;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,30 +94,6 @@
|
|||
|
||||
#typeahead-container {
|
||||
font-size: 14px;
|
||||
margin: 0 10px;
|
||||
|
||||
input {
|
||||
border: 1px solid pvar(--mainBackgroundColor) !important;
|
||||
box-shadow: rgba(0, 0, 0, 0.1) 0 1px 20px 0;
|
||||
flex-grow: 1;
|
||||
transition: box-shadow .3s ease, width .2s ease;
|
||||
}
|
||||
|
||||
@media screen and (max-width: $small-view) {
|
||||
input {
|
||||
width: 200px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: $mobile-view) {
|
||||
input {
|
||||
width: 150px;
|
||||
}
|
||||
}
|
||||
|
||||
span {
|
||||
right: 10px;
|
||||
}
|
||||
|
||||
> div:last-child {
|
||||
// we have to switch the display and not the opacity,
|
||||
|
|
|
@ -1,141 +1,22 @@
|
|||
<div class="menu-wrapper">
|
||||
<nav [ngClass]="{ 'is-logged-in': isLoggedIn }">
|
||||
<div class="top-menu">
|
||||
<div *ngIf="isLoggedIn" class="logged-in-block">
|
||||
<div>
|
||||
<div
|
||||
class="logged-in-more" ngbDropdown #dropdown="ngbDropdown" placement="bottom-left auto"
|
||||
container="body" (openChange)="onDropdownOpenChange($event)"
|
||||
>
|
||||
<button class="border-0 text-start" ngbDropdownToggle>
|
||||
<my-actor-avatar [actor]="user.account" actorType="account" size="34"></my-actor-avatar>
|
||||
|
||||
<div class="logged-in-info">
|
||||
<div class="logged-in-display-name">{{ user.account?.displayName }}</div>
|
||||
<ng-container *ngFor="let menuSection of menuSections" >
|
||||
<ul [ngClass]="[ menuSection.key, 'menu-block' ]">
|
||||
<li i18n class="block-container">
|
||||
<span class="block-title">{{ menuSection.title }}</span>
|
||||
|
||||
<div class="logged-in-username">@{{ user.username }}</div>
|
||||
</div>
|
||||
|
||||
<div class="dropdown-toggle-indicator">
|
||||
<span class="chevron-down"></span>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<div ngbDropdownMenu>
|
||||
<a
|
||||
*ngIf="user.account" ngbDropdownItem ngbDropdownToggle class="dropdown-item" [routerLink]="[ '/a', user.account.nameWithHost ]"
|
||||
#profile (click)="onActiveLinkScrollToAnchor(profile)"
|
||||
>
|
||||
<my-global-icon iconName="go" aria-hidden="true"></my-global-icon> <ng-container i18n>Public profile</ng-container>
|
||||
<ul class="mt-3">
|
||||
<li *ngFor="let link of menuSection.links">
|
||||
<a class="menu-link ps-0" [routerLink]="link.path" routerLinkActive="active">
|
||||
<my-global-icon *ngIf="link.icon" [iconName]="link.icon" [ngClass]="link.iconClass" aria-hidden="true"></my-global-icon>
|
||||
<ng-container>{{ link.shortLabel }}</ng-container>
|
||||
</a>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
<button
|
||||
myPluginSelector pluginSelectorId="menu-user-dropdown-language-item"
|
||||
ngbDropdownItem class="dropdown-item" (click)="openLanguageChooser()"
|
||||
>
|
||||
<my-global-icon iconName="language" aria-hidden="true"></my-global-icon>
|
||||
<span i18n>Interface:</span>
|
||||
<span class="ms-auto muted">{{ currentInterfaceLanguage }}</span>
|
||||
</button>
|
||||
|
||||
<a ngbDropdownItem class="dropdown-item" routerLink="/my-account/settings" fragment="video-languages-subtitles"
|
||||
#settingsLanguagesSubtitles (click)="onActiveLinkScrollToAnchor(settingsLanguagesSubtitles)">
|
||||
<my-global-icon iconName="video-lang" aria-hidden="true"></my-global-icon>
|
||||
<span i18n>Videos:</span>
|
||||
<span class="ms-auto muted">{{ videoLanguages.join(', ') }}</span>
|
||||
</a>
|
||||
|
||||
<a ngbDropdownItem class="dropdown-item settings-sensitive" routerLink="/my-account/settings"
|
||||
fragment="video-sensitive-content-policy" #settingsSensitiveContentPolicy
|
||||
(click)="onActiveLinkScrollToAnchor(settingsSensitiveContentPolicy)"
|
||||
>
|
||||
<my-global-icon class="hover-display-toggle" [hidden]="user.nsfwPolicy === 'display'" iconName="eye-open" aria-hidden="true"></my-global-icon>
|
||||
<my-global-icon class="hover-display-toggle" [hidden]="user.nsfwPolicy !== 'display'" iconName="eye-close" aria-hidden="true"></my-global-icon>
|
||||
<span i18n>Sensitive:</span>
|
||||
<span class="ms-auto muted">{{ nsfwPolicy }}</span>
|
||||
</a>
|
||||
|
||||
<button class="dropdown-item" (mousedown)="$event.stopPropagation(); toggleUseP2P()" [ariaPressed]="user.p2pEnabled" ngbDropdownItem>
|
||||
<my-global-icon iconName="p2p" aria-hidden="true"></my-global-icon>
|
||||
<ng-container i18n>Help share videos</ng-container>
|
||||
|
||||
<my-input-switch inputName="p2p-enabled" class="ms-auto" [preventUpdate]="true" [checked]="user.p2pEnabled"></my-input-switch>
|
||||
</button>
|
||||
|
||||
<div class="dropdown-divider"></div>
|
||||
|
||||
<button *ngIf="!isInMobileView" ngbDropdownItem class="dropdown-item" (click)="openHotkeysCheatSheet()">
|
||||
<my-global-icon iconName="command" aria-hidden="true"></my-global-icon>
|
||||
<ng-container i18n>Keyboard shortcuts</ng-container>
|
||||
</button>
|
||||
|
||||
<button ngbDropdownItem (click)="logout($event)" class="dropdown-item">
|
||||
<my-global-icon iconName="sign-out" aria-hidden="true"></my-global-icon>
|
||||
<ng-container i18n>Log out</ng-container>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@defer (when isLoggedIn) {
|
||||
<my-notification-dropdown (navigate)="onActiveLinkScrollToAnchor($event)"></my-notification-dropdown>
|
||||
}
|
||||
</div>
|
||||
|
||||
<ul class="logged-in-menu">
|
||||
<li>
|
||||
<a class="menu-link" routerLink="/my-account" routerLinkActive="active" #settingsLink (click)="onActiveLinkScrollToAnchor(settingsLink)">
|
||||
<my-global-icon iconName="user" aria-hidden="true"></my-global-icon>
|
||||
<ng-container i18n>My account</ng-container>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a class="menu-link" routerLink="/my-library" routerLinkActive="active" #libraryLink (click)="onActiveLinkScrollToAnchor(libraryLink)">
|
||||
<my-global-icon class="channel-icon" iconName="channel" aria-hidden="true"></my-global-icon>
|
||||
<ng-container i18n>My library</ng-container>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a class="menu-link" *ngIf="userHasAdminAccess" [routerLink]="getFirstAdminRouteAvailable()" routerLinkActive="active">
|
||||
<my-global-icon iconName="cog" aria-hidden="true"></my-global-icon>
|
||||
<ng-container i18n>Administration</ng-container>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<ul *ngIf="!isLoggedIn" class="login-buttons-block">
|
||||
<li>
|
||||
<my-login-link className="peertube-button-link orange-button w-100 text-truncate"></my-login-link>
|
||||
</li>
|
||||
|
||||
<li *ngIf="isRegistrationAllowed()" class="mt-2">
|
||||
<a routerLink="/signup" class="create-account-button peertube-button-link text-truncate d-block">
|
||||
<my-signup-label [requiresApproval]="requiresApproval"></my-signup-label>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ng-container *ngFor="let menuSection of menuSections" >
|
||||
<ul [ngClass]="[ menuSection.key, 'menu-block' ]">
|
||||
<li i18n class="block-container">
|
||||
<span class="block-title">{{ menuSection.title }}</span>
|
||||
|
||||
<ul class="mt-3">
|
||||
<li *ngFor="let link of menuSection.links">
|
||||
<a class="menu-link ps-0" [routerLink]="link.path" routerLinkActive="active">
|
||||
<my-global-icon *ngIf="link.icon" [iconName]="link.icon" [ngClass]="link.iconClass" aria-hidden="true"></my-global-icon>
|
||||
<ng-container>{{ link.shortLabel }}</ng-container>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</ng-container>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
<div class="footer">
|
||||
<ul class="footer-block">
|
||||
|
|
|
@ -87,185 +87,6 @@ nav {
|
|||
@media not all and (hover: hover) and (pointer: fine) {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
&.is-logged-in {
|
||||
.panel-block {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.block-title {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.top-menu {
|
||||
flex-grow: 1;
|
||||
width: $menu-width;
|
||||
}
|
||||
|
||||
.logged-in-block {
|
||||
margin-bottom: 20px;
|
||||
background-color: rgba(255, 255, 255, 0.15);
|
||||
|
||||
> div:first-child {
|
||||
height: 80px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: left;
|
||||
}
|
||||
}
|
||||
|
||||
my-notification-dropdown {
|
||||
@include margin-left(auto);
|
||||
@include margin-right(15px);
|
||||
}
|
||||
|
||||
.logged-in-more {
|
||||
flex: 1;
|
||||
min-width: 1px;
|
||||
border-radius: 25px;
|
||||
transition: all .1s ease-in-out;
|
||||
cursor: pointer;
|
||||
line-height: 1;
|
||||
|
||||
@include margin-left(13px);
|
||||
|
||||
@mixin display-hints($is-mobile: false) {
|
||||
background-color: rgba(255, 255, 255, 0.15);
|
||||
|
||||
@if $is-mobile {
|
||||
.dropdown-toggle-indicator {
|
||||
display: inherit !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.show {
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
box-shadow: inset 0 3px 5px rgba(0, 0, 0, .325);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
@include display-hints;
|
||||
}
|
||||
|
||||
/* smartphones and touchscreens */
|
||||
@media (hover: none) and (pointer: coarse) {
|
||||
@include display-hints($is-mobile: true);
|
||||
}
|
||||
|
||||
> .dropdown-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
padding: 5px 7px;
|
||||
|
||||
&::after {
|
||||
// Disable bootstrap toggle
|
||||
border: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-toggle-indicator {
|
||||
position: relative;
|
||||
display: none;
|
||||
width: 17px;
|
||||
|
||||
span {
|
||||
position: absolute;
|
||||
top: -8px;
|
||||
color: #808080;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my-actor-avatar {
|
||||
@include margin-right(10px);
|
||||
}
|
||||
|
||||
.logged-in-info {
|
||||
flex-shrink: 1;
|
||||
min-width: 1px;
|
||||
}
|
||||
|
||||
.logged-in-display-name,
|
||||
.logged-in-username {
|
||||
@include ellipsis;
|
||||
}
|
||||
|
||||
.logged-in-display-name {
|
||||
font-weight: $font-semibold;
|
||||
color: pvar(--menuForegroundColor);
|
||||
|
||||
@include disable-default-a-behaviour;
|
||||
}
|
||||
|
||||
.logged-in-username {
|
||||
font-size: 13px;
|
||||
color: #C6C6C6;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.logged-in-menu {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
border-top: 1px solid var(--greyForegroundColor);
|
||||
line-height: $line-height-normal;
|
||||
|
||||
a {
|
||||
$icon-size: 13px;
|
||||
$additional-margin: math.div($menu-link-icon-size - $icon-size, 2);
|
||||
|
||||
font-size: 14px;
|
||||
width: 100%;
|
||||
min-height: 35px;
|
||||
|
||||
my-global-icon {
|
||||
width: $icon-size;
|
||||
height: $icon-size;
|
||||
|
||||
// Keep aligned with other icons
|
||||
@include margin-left($additional-margin);
|
||||
}
|
||||
|
||||
&.active,
|
||||
&:hover,
|
||||
&:focus-visible {
|
||||
my-global-icon {
|
||||
@include apply-svg-color(var(--menuForegroundColor));
|
||||
}
|
||||
}
|
||||
|
||||
&.active {
|
||||
$border-left-width: 4px;
|
||||
|
||||
font-weight: $font-semibold;
|
||||
border-left: $border-left-width solid var(--mainColor);
|
||||
|
||||
my-global-icon {
|
||||
@include margin-left($additional-margin - $border-left-width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
li {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.login-buttons-block {
|
||||
margin: 30px 25px 35px;
|
||||
}
|
||||
|
||||
.create-account-button {
|
||||
color: #fff;
|
||||
background-color: rgba(255, 255, 255, 0.25);
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(255, 255, 255, 0.28);
|
||||
}
|
||||
}
|
||||
|
||||
.menu-block,
|
||||
|
@ -329,43 +150,6 @@ my-actor-avatar {
|
|||
}
|
||||
}
|
||||
|
||||
.dropdown {
|
||||
z-index: #{z('menu') + 1} !important;
|
||||
}
|
||||
|
||||
.dropdown-menu {
|
||||
width: calc(100% + 40px);
|
||||
|
||||
// Prevent weird display issue on firefox when global style is not loaded yet
|
||||
&:not(.show) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-item {
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@include dropdown-with-icon-item;
|
||||
|
||||
&:hover {
|
||||
.hover-display-toggle {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.hover-display-toggle[hidden] {
|
||||
display: inherit !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.more-settings {
|
||||
text-transform: uppercase;
|
||||
font-size: 80%;
|
||||
color: #6c757d;
|
||||
}
|
||||
|
||||
@media screen and (max-width: $mobile-view) {
|
||||
.menu-wrapper {
|
||||
width: 100% !important;
|
||||
|
@ -375,28 +159,7 @@ my-actor-avatar {
|
|||
}
|
||||
}
|
||||
|
||||
.top-menu,
|
||||
.footer {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.dropdown-menu {
|
||||
width: calc(100vw - 30px);
|
||||
}
|
||||
}
|
||||
|
||||
my-global-icon {
|
||||
position: relative;
|
||||
top: -1px;
|
||||
|
||||
.playlist-icon {
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
|
||||
@include margin-right(16px);
|
||||
}
|
||||
|
||||
&.channel-icon {
|
||||
top: -2px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,9 +40,7 @@ $not-expanded-horizontal-margins: 30px;
|
|||
|
||||
$button-font-size: 15px;
|
||||
|
||||
$header-height: 50px;
|
||||
$header-border-color: #e9eff6;
|
||||
$search-input-width: 375px;
|
||||
$header-height: 106px;
|
||||
|
||||
$menu-background: #000;
|
||||
$menu-color: #fff;
|
||||
|
|
|
@ -24,7 +24,7 @@ $playlist-menu-width: 350px;
|
|||
}
|
||||
|
||||
.header {
|
||||
border-bottom: 1px solid $header-border-color;
|
||||
border-bottom: 1px solid #e9eff6;
|
||||
padding: 20px 10px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
|
Loading…
Reference in New Issue