From 67264e060b6068399dae9a67abae035a73b84af1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 26 Mar 2021 13:20:37 +0100 Subject: Redesign account page --- .../misc/simple-search-input.component.html | 13 +++--- .../misc/simple-search-input.component.scss | 36 +++++++-------- .../misc/simple-search-input.component.ts | 52 ++++++++++++++++++---- 3 files changed, 68 insertions(+), 33 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/shared-main/misc/simple-search-input.component.html b/client/src/app/shared/shared-main/misc/simple-search-input.component.html index fb0d97122..c20c02e23 100644 --- a/client/src/app/shared/shared-main/misc/simple-search-input.component.html +++ b/client/src/app/shared/shared-main/misc/simple-search-input.component.html @@ -1,14 +1,15 @@ - - - +
- + + + + +
diff --git a/client/src/app/shared/shared-main/misc/simple-search-input.component.scss b/client/src/app/shared/shared-main/misc/simple-search-input.component.scss index 591b04fb2..037937f80 100644 --- a/client/src/app/shared/shared-main/misc/simple-search-input.component.scss +++ b/client/src/app/shared/shared-main/misc/simple-search-input.component.scss @@ -1,29 +1,29 @@ @import '_variables'; @import '_mixins'; -span { - opacity: .6; - - &:focus-within { - opacity: 1; - } +.root { + display: flex; } my-global-icon { - height: 18px; - position: relative; - top: -2px; -} + height: 26px; + width: 26px; + margin-left: 10px; + cursor: pointer; -input { - @include peertube-input-text(150px); + &:hover { + color: pvar(--mainHoverColor); + } - height: 22px; // maximum height for the account/video-channels links - padding-left: 10px; - background-color: transparent; - border: none; + &[iconName=search] { + color: pvar(--mainColor); + } - &::placeholder { - font-size: 15px; + &[iconName=cross] { + color: pvar(--mainForegroundColor); } } + +input { + @include peertube-input-text(200px); +} diff --git a/client/src/app/shared/shared-main/misc/simple-search-input.component.ts b/client/src/app/shared/shared-main/misc/simple-search-input.component.ts index 86ae9ab42..224d71134 100644 --- a/client/src/app/shared/shared-main/misc/simple-search-input.component.ts +++ b/client/src/app/shared/shared-main/misc/simple-search-input.component.ts @@ -1,7 +1,7 @@ -import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' -import { ActivatedRoute, Router } from '@angular/router' import { Subject } from 'rxjs' import { debounceTime, distinctUntilChanged } from 'rxjs/operators' +import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' +import { ActivatedRoute, Router } from '@angular/router' @Component({ selector: 'simple-search-input', @@ -13,11 +13,14 @@ export class SimpleSearchInputComponent implements OnInit { @Input() name = 'search' @Input() placeholder = $localize`Search` + @Input() iconTitle = $localize`Search` + @Input() alwaysShow = true @Output() searchChanged = new EventEmitter() + @Output() inputDisplayChanged = new EventEmitter() value = '' - shown: boolean + inputShown: boolean private searchSubject = new Subject() @@ -35,20 +38,51 @@ export class SimpleSearchInputComponent implements OnInit { .subscribe(value => this.searchChanged.emit(value)) this.searchSubject.next(this.value) + + if (this.isInputShown()) this.showInput(false) } - showInput () { - this.shown = true - setTimeout(() => this.input.nativeElement.focus()) + isInputShown () { + if (this.alwaysShow) return true + + return this.inputShown + } + + onIconClick () { + if (!this.isInputShown()) { + this.showInput() + return + } + + this.searchChange() + } + + showInput (focus = true) { + this.inputShown = true + this.inputDisplayChanged.emit(this.inputShown) + + if (focus) { + setTimeout(() => this.input.nativeElement.focus()) + } + } + + hideInput () { + this.inputShown = false + + if (this.isInputShown() === false) { + this.inputDisplayChanged.emit(this.inputShown) + } } focusLost () { - if (this.value !== '') return - this.shown = false + if (this.value) return + + this.hideInput() } searchChange () { - this.router.navigate(['./search'], { relativeTo: this.route }) + this.router.navigate([ './search' ], { relativeTo: this.route }) + this.searchSubject.next(this.value) } } -- cgit v1.2.3