Projekt

Obecné

Profil

« Předchozí | Další » 

Revize bedb9995

Přidáno uživatelem Ondřej Váně před asi 4 roky(ů)

Re #7817: Responzivní navigační lišta

- přidána responzivního chování pro navigační lištu
- přidán boční navigační panel

Zobrazit rozdíly:

fe/fulltextsearch/src/app/app.component.html
1 1
<div>
2
  <app-header></app-header>
2
  <app-main-nav></app-main-nav>
3 3
  <router-outlet></router-outlet>
4 4
</div>
fe/fulltextsearch/src/app/app.module.ts
6 6
import { AppComponent } from './app.component';
7 7
import { FormsModule } from '@angular/forms';
8 8
import { HomeComponent } from './components/pages/home/home.component';
9
import { HeaderComponent } from './components/layout/header/header.component';
10 9
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
11 10
import { MatToolbarModule } from '@angular/material/toolbar';
12 11
import { MatButtonModule } from '@angular/material/button';
......
22 21
import { MatTableModule } from '@angular/material/table';
23 22
import { MatPaginatorModule } from '@angular/material/paginator';
24 23
import { MatSortModule } from '@angular/material/sort';
25
import {MatDialogModule} from '@angular/material/dialog';
24
import { MatDialogModule } from '@angular/material/dialog';
26 25
import { AboutDialogComponent } from './components/shared-components/about-dialog/about-dialog.component';
27 26
import { SearchPaginatorComponent } from './components/pages/search/search-paginator/search-paginator.component';
27
import { MainNavComponent } from './components/layout/main-nav/main-nav.component';
28
import { LayoutModule } from '@angular/cdk/layout';
29
import { MatSidenavModule } from '@angular/material/sidenav';
30
import { MatListModule } from '@angular/material/list';
28 31

  
29 32
@NgModule({
30 33
  declarations: [
31 34
    AppComponent,
32 35
    HomeComponent,
33
    HeaderComponent,
34 36
    SearchComponent,
35 37
    BrowseComponent,
36 38
    UploadComponent,
......
38 40
    SearchBoxComponent,
39 41
    TableComponent,
40 42
    AboutDialogComponent,
41
    SearchPaginatorComponent
43
    SearchPaginatorComponent,
44
    MainNavComponent,
42 45
  ],
43 46
  imports: [
44 47
    BrowserModule,
......
54 57
    MatTableModule,
55 58
    MatPaginatorModule,
56 59
    MatSortModule,
57
    MatDialogModule
60
    MatDialogModule,
61
    LayoutModule,
62
    MatSidenavModule,
63
    MatListModule
58 64
  ],
59 65
  providers: [],
60 66
  bootstrap: [AppComponent]
fe/fulltextsearch/src/app/components/layout/header/header.component.css
1
.space {
2
  flex: 1 1 auto;
3
}
4

  
5
a:hover {
6
  color: var(--navbar-text-color);
7
  background-color: var(--primary-color-dark);
8
}
9

  
10
a {
11
  font-weight: bold;
12
  font-size: large;
13
  color: var(--navbar-text-color);
14
}
15

  
16
.app-header {
17
  position: sticky;
18
  position: -webkit-sticky;
19
  top: 0;
20
  z-index: 1000;
21
  background-color: var(--primary-color);
22
}
23

  
24
.app-logo {
25
  color: var(--navbar-text-color);
26
  margin-right: 10pt;
27
  padding: 5pt 8pt 5pt 5pt;
28
}
29

  
30
.app-logo:hover {
31
  cursor: pointer;
32
  background-color: var(--primary-color-dark);
33
}
34

  
35
.app-logo div {
36
  margin-left: 15pt;
37
  margin-top: 5pt;
38
  text-align: center;
39
  font-size: medium;
40
  font-weight: bold;
41
  line-height: normal;
42
}
43

  
44
mat-icon {
45
  font-size: 40pt;
46
}
fe/fulltextsearch/src/app/components/layout/header/header.component.html
1
<mat-toolbar class="mat-elevation-z8 app-header">
2
  <!-- app logo -->
3
  <div class="app-logo" routerLink="" style="outline: none">
4
    <span style="display: flex;">
5
      <mat-icon>search</mat-icon>
6
      <div>FULL TEXT SEARCH<br> APPLICATION</div>
7
      </span>
8
  </div>
9
  <!-- left navigation items -->
10
  <a mat-button class="noHover active" routerLink="search">Search</a>
11
  <a mat-button routerLink="browse">Browse</a>
12
  <a mat-button routerLink="upload">Upload</a>
13
  <!-- navigation items space -->
14
  <div class="space"></div>
15
  <!-- right navigation items -->
16
  <a mat-button (click)="openAboutDialog()">About</a>
17
  <a mat-button routerLink="help">Help</a>
18
  <a mat-button>EN</a>
19
</mat-toolbar>
fe/fulltextsearch/src/app/components/layout/header/header.component.spec.ts
1
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2

  
3
import { HeaderComponent } from './header.component';
4

  
5
describe('HeaderComponent', () => {
6
  let component: HeaderComponent;
7
  let fixture: ComponentFixture<HeaderComponent>;
8

  
9
  beforeEach(async(() => {
10
    TestBed.configureTestingModule({
11
      declarations: [ HeaderComponent ]
12
    })
13
    .compileComponents();
14
  }));
15

  
16
  beforeEach(() => {
17
    fixture = TestBed.createComponent(HeaderComponent);
18
    component = fixture.componentInstance;
19
    fixture.detectChanges();
20
  });
21

  
22
  it('should create', () => {
23
    expect(component).toBeTruthy();
24
  });
25
});
fe/fulltextsearch/src/app/components/layout/header/header.component.ts
1
import { Component, OnInit } from '@angular/core';
2
import { MatDialog } from '@angular/material/dialog';
3
import { AboutDialogComponent } from '../../shared-components/about-dialog/about-dialog.component';
4

  
5
@Component({
6
  selector: 'app-header',
7
  templateUrl: './header.component.html',
8
  styleUrls: ['./header.component.css']
9
})
10
export class HeaderComponent implements OnInit {
11

  
12
  constructor( public dialog: MatDialog ) { }
13

  
14
  ngOnInit() {
15
  }
16

  
17
  openAboutDialog() {
18
    this.dialog.open(AboutDialogComponent, { panelClass: 'custom-dialog-container' });
19
  }
20

  
21
}
fe/fulltextsearch/src/app/components/layout/main-nav/main-nav.component.css
1
.sidenav-container {
2
  height: 100%;
3
}
4

  
5
.sidenav {
6
  width: 200px;
7
}
8

  
9
.sidenav .mat-toolbar {
10
  background: var(--primary-color);
11
  color: var(--navbar-text-color);
12

  
13
}
14

  
15
.mat-toolbar.mat-primary {
16
  position: sticky;
17
  top: 0;
18
  z-index: 10;
19
}
20

  
21
.hidden {
22
  display: none;
23
}
24

  
25
.space {
26
  flex: 1 1 auto;
27
}
28

  
29
a:hover {
30
  color: var(--navbar-text-color);
31
  background-color: var(--primary-color-dark);
32
}
33

  
34
a {
35
  font-weight: bold;
36
  font-size: large;
37
  color: var(--navbar-text-color);
38
}
39

  
40
.app-header {
41
  position: sticky;
42
  position: -webkit-sticky;
43
  top: 0;
44
}
45

  
46
.app-logo {
47
  color: var(--navbar-text-color);
48
  margin-right: 10pt;
49
  padding: 5pt 8pt 5pt 5pt;
50
}
51

  
52
.app-logo:hover {
53
  cursor: pointer;
54
  background-color: var(--primary-color-dark);
55
}
56

  
57
.app-logo div {
58
  margin-left: 15pt;
59
  margin-top: 5pt;
60
  text-align: center;
61
  font-size: medium;
62
  font-weight: bold;
63
  line-height: normal;
64
}
65

  
66
.app-logo mat-icon {
67
  font-size: 40pt;
68
}
69

  
70
mat-nav-list mat-icon {
71
  margin-right: 10px;
72
}
73

  
74
mat-nav-list a:hover {
75
  color: #932523;
76
}
77

  
78
.position-fixed {
79
  position: fixed
80
}
81

  
82
mat-sidenav-content {
83
  margin-top: 64px;
84
}
85

  
86

  
87
mat-toolbar.mat-primary {
88
  background-color: var(--primary-color);
89
}
90

  
91
.mat-drawer-backdrop {
92
  height: 100%;
93
}
94

  
95
mat-sidenav-content {
96
  margin-top: 56px;
97
}
fe/fulltextsearch/src/app/components/layout/main-nav/main-nav.component.html
1
<mat-sidenav-container class="sidenav-container">
2
  <mat-sidenav #drawer class="sidenav position-fixed" fixedInViewport
3
               [attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
4
               [mode]="(isHandset$ | async) ? 'over' : 'side'"
5
               [opened]="(isHandset$ | async) === false"
6
               [ngClass]="{hidden: !(isHandset$ | async)}">
7
    <mat-toolbar>Menu</mat-toolbar>
8
    <mat-nav-list (click)="drawer.close()">
9
      <a mat-list-item routerLink="">
10
        <mat-icon>home</mat-icon>
11
        Home</a>
12
      <a mat-list-item routerLink="search">
13
        <mat-icon>search</mat-icon>
14
        Search</a>
15
      <a mat-list-item routerLink="browse">
16
        <mat-icon>list</mat-icon>
17
        Browse</a>
18
      <a mat-list-item routerLink="upload">
19
        <mat-icon>backup</mat-icon>
20
        Upload</a>
21
      <a mat-list-item (click)="openAboutDialog()">
22
        <mat-icon>info</mat-icon>
23
        About</a>
24
      <a mat-list-item routerLink="help">
25
        <mat-icon>help</mat-icon>
26
        Help</a>
27
      <a mat-list-item>
28
        <mat-icon>translate</mat-icon>
29
        EN</a>
30
    </mat-nav-list>
31
  </mat-sidenav>
32
  <mat-sidenav-content>
33
    <mat-toolbar color="primary" class="position-fixed">
34
      <button
35
        type="button"
36
        aria-label="Toggle sidenav"
37
        mat-icon-button
38
        (click)="drawer.toggle()"
39
        *ngIf="isHandset$ | async">
40
        <mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
41
      </button>
42
      <!-- app logo -->
43
      <div class="app-logo" routerLink="" style="outline: none">
44
        <span style="display: flex;">
45
        <mat-icon>search</mat-icon>
46
        <div>FULL TEXT SEARCH<br> APPLICATION</div>
47
      </span>
48
      </div>
49
      <!-- left navigation items -->
50
      <a mat-button class="noHover active" routerLink="search" *ngIf="!(isHandset$ | async)">Search</a>
51
      <a mat-button routerLink="browse" *ngIf="!(isHandset$ | async)">Browse</a>
52
      <a mat-button routerLink="upload" *ngIf="!(isHandset$ | async)">Upload</a>
53
      <!-- navigation items space -->
54
      <div class="space" *ngIf="!(isHandset$ | async)"></div>
55
      <!-- right navigation items -->
56
      <a mat-button (click)="openAboutDialog()" *ngIf="!(isHandset$ | async)">About</a>
57
      <a mat-button routerLink="help" *ngIf="!(isHandset$ | async)">Help</a>
58
      <a mat-button *ngIf="!(isHandset$ | async)">EN</a>
59
    </mat-toolbar>
60
    <ng-content></ng-content>
61
  </mat-sidenav-content>
62
</mat-sidenav-container>
fe/fulltextsearch/src/app/components/layout/main-nav/main-nav.component.spec.ts
1
import { LayoutModule } from '@angular/cdk/layout';
2
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
4
import { MatButtonModule } from '@angular/material/button';
5
import { MatIconModule } from '@angular/material/icon';
6
import { MatListModule } from '@angular/material/list';
7
import { MatSidenavModule } from '@angular/material/sidenav';
8
import { MatToolbarModule } from '@angular/material/toolbar';
9

  
10
import { MainNavComponent } from './main-nav.component';
11

  
12
describe('MainNavComponent', () => {
13
  let component: MainNavComponent;
14
  let fixture: ComponentFixture<MainNavComponent>;
15

  
16
  beforeEach(async(() => {
17
    TestBed.configureTestingModule({
18
      declarations: [MainNavComponent],
19
      imports: [
20
        NoopAnimationsModule,
21
        LayoutModule,
22
        MatButtonModule,
23
        MatIconModule,
24
        MatListModule,
25
        MatSidenavModule,
26
        MatToolbarModule,
27
      ]
28
    }).compileComponents();
29
  }));
30

  
31
  beforeEach(() => {
32
    fixture = TestBed.createComponent(MainNavComponent);
33
    component = fixture.componentInstance;
34
    fixture.detectChanges();
35
  });
36

  
37
  it('should compile', () => {
38
    expect(component).toBeTruthy();
39
  });
40
});
fe/fulltextsearch/src/app/components/layout/main-nav/main-nav.component.ts
1
import { Component } from '@angular/core';
2
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
3
import { Observable } from 'rxjs';
4
import { map, shareReplay } from 'rxjs/operators';
5
import { AboutDialogComponent } from '../../shared-components/about-dialog/about-dialog.component';
6
import {MatDialog} from '@angular/material/dialog';
7

  
8
@Component({
9
  selector: 'app-main-nav',
10
  templateUrl: './main-nav.component.html',
11
  styleUrls: ['./main-nav.component.css']
12
})
13
export class MainNavComponent {
14

  
15
  isHandset$: Observable<boolean> = this.breakpointObserver.observe(Breakpoints.Handset)
16
    .pipe(
17
      map(result => result.matches),
18
      shareReplay()
19
    );
20

  
21
  constructor(private breakpointObserver: BreakpointObserver, public dialog: MatDialog) {}
22

  
23
  openAboutDialog() {
24
    this.dialog.open(AboutDialogComponent, { panelClass: 'custom-dialog-container' });
25
  }
26

  
27
}
fe/fulltextsearch/src/styles.css
1

  
2
body {
3
  height: 100% !important;
4
}
5

  
6
.mat-drawer-backdrop {
7
  position: fixed !important;
8
}
9

  
1 10
/* styles for our custom dialog */
2 11
.custom-dialog-container .mat-dialog-container {
3 12
  padding: 0;

Také k dispozici: Unified diff