Skip to content

Commit 45baa9b

Browse files
committed
fix(demo): responsive-layout
1 parent e1c3747 commit 45baa9b

File tree

7 files changed

+47
-7
lines changed

7 files changed

+47
-7
lines changed

projects/elements-demo/src/app/app.component.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Component, OnInit, ViewChild } from '@angular/core';
1+
import { Component, OnInit, ViewChild, HostBinding } from '@angular/core';
22
import { MatSidenav } from '@angular/material';
33
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
4-
import { map } from 'rxjs/operators';
4+
import { delay, map, tap } from 'rxjs/operators';
55

66
import { ResponsiveLayoutService } from './core/layout/responsive-layout.service';
77

@@ -11,6 +11,9 @@ import { ResponsiveLayoutService } from './core/layout/responsive-layout.service
1111
styleUrls: ['./app.component.scss']
1212
})
1313
export class AppComponent implements OnInit {
14+
@HostBinding('class')
15+
demoRootCssClass = '';
16+
1417
@ViewChild('sidenav', { static: false }) sidenav: MatSidenav;
1518

1619
navOpened: Observable<boolean>;
@@ -20,7 +23,10 @@ export class AppComponent implements OnInit {
2023
constructor(private responsiveLayoutService: ResponsiveLayoutService) {}
2124

2225
ngOnInit() {
23-
this.isResponsiveLayout = this.responsiveLayoutService.isResponsiveLayout;
26+
this.isResponsiveLayout = this.responsiveLayoutService.isResponsiveLayout.pipe(
27+
delay(1),
28+
tap(value => (this.demoRootCssClass = value ? 'responsive' : ''))
29+
);
2430

2531
this.navOpened = combineLatest([
2632
this.isResponsiveLayout,

projects/elements-demo/src/app/core/layout/responsive-layout.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export class ResponsiveLayoutService {
1818
columnCount: Observable<number>;
1919
isResponsiveLayout: Observable<boolean>;
2020

21+
// sync
22+
isResponsiveLayoutSync: boolean;
23+
2124
constructor(private breakpointObserver: BreakpointObserver) {
2225
this.isXSmallScreen = this.breakpointObserver
2326
.observe([Breakpoints.XSmall])

projects/elements-demo/src/app/core/layout/toolbar/toolbar.component.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
}}</mat-icon>
1111
</button>
1212

13+
<span class="spacer-responsive"></span>
14+
1315
<a mat-icon-button routerLink="home">
1416
<mat-icon
1517
inline
@@ -18,7 +20,11 @@
1820
aria-label="@angular-extensions/elements"
1921
></mat-icon>
2022
</a>
21-
<span class="project-name">@angular-extensions/elements</span>
23+
<span class="project-name"
24+
>{{
25+
(isResponsiveLayout | async) ? '' : '@angular-extensions/'
26+
}}elements</span
27+
>
2228

2329
<span class="spacer"></span>
2430
<ng-container *ngIf="(isResponsiveLayout | async) === false">

projects/elements-demo/src/app/core/layout/toolbar/toolbar.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ button {
1313
.menu {
1414
margin: 0 10px 0 0;
1515
}
16+
17+
:host-context(.responsive) {
18+
.spacer-responsive {
19+
flex: 1 0 auto;
20+
}
21+
}

projects/elements-demo/src/app/features/home/home/home.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ <h2>Features</h2>
5151
<mat-icon color="primary">{{ feature.icon }}</mat-icon>
5252
</div>
5353
<mat-card-title>{{ feature.title }}</mat-card-title>
54-
<mat-card-subtitle>{{ feature.subtitle }}</mat-card-subtitle>
54+
<mat-card-subtitle [innerHTML]="feature.subtitle"></mat-card-subtitle>
5555
</mat-card-header>
5656
</mat-card>
5757
</mat-grid-tile>

projects/elements-demo/src/app/features/home/home/home.component.scss

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,14 @@
6666
width: calc(100% - 50px);
6767
height: calc(100% - 50px);
6868

69+
mat-card-title {
70+
white-space: nowrap;
71+
overflow: hidden;
72+
text-overflow: ellipsis;
73+
}
74+
6975
mat-card-subtitle {
70-
height: 60px;
76+
height: 80px;
7177
width: 100%;
7278
overflow: hidden;
7379
text-overflow: ellipsis;
@@ -80,3 +86,16 @@
8086
}
8187
}
8288
}
89+
90+
:host-context(.responsive) {
91+
.cta {
92+
button {
93+
width: 100%;
94+
}
95+
}
96+
97+
code {
98+
white-space: normal;
99+
padding: 0 8px 1px 8px;
100+
}
101+
}

projects/elements-demo/src/app/features/home/home/home.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const FEATURES = [
1313
{
1414
title: 'Simple API',
1515
subtitle:
16-
'Just grab *axLazyElement directive set the element bundle url and you are ready to go!',
16+
'Just grab <code>*axLazyElement</code> directive set the element bundle url and you are ready to go!',
1717
icon: 'sentiment_satisfied_alt'
1818
},
1919
{

0 commit comments

Comments
 (0)