Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 97a8d33

Browse files
committed
fix(docs-api): tables overflow screen width on mobile
- fix docs-api layouts to work down to 360px width - fixes Observers, Accessibility, Drag and Drop, Platform, and Overlay layouts - fix DeprecatedconnectedTo to Deprecated connectedTo display issue - update footer copyright - fix exception trying to unsubscribe to undefined routeParamSubscription Fixes #550
1 parent 71de160 commit 97a8d33

File tree

10 files changed

+67
-34
lines changed

10 files changed

+67
-34
lines changed

src/app/pages/component-category-list/component-category-list.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export class ComponentCategoryList implements OnInit, OnDestroy {
3838
}
3939

4040
ngOnDestroy() {
41-
this.routeParamSubscription.unsubscribe();
41+
if (this.routeParamSubscription) {
42+
this.routeParamSubscription.unsubscribe();
43+
}
4244
}
4345
}
4446

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {Injectable} from '@angular/core';
2+
import {MatSidenav} from '@angular/material/sidenav';
3+
4+
@Injectable({providedIn : 'root'})
5+
export class ComponentSidenavProxy {
6+
sidenav: MatSidenav;
7+
}

src/app/pages/component-sidenav/component-sidenav.service.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/app/pages/component-sidenav/component-sidenav.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,17 @@ import {HttpClientModule} from '@angular/common/http';
3737
import {StackBlitzButtonModule} from '../../shared/stack-blitz';
3838
import {SvgViewerModule} from '../../shared/svg-viewer/svg-viewer';
3939
import {ExampleModule} from '@angular/components-examples';
40-
import {ComponentSidenavService} from './component-sidenav.service';
40+
import {ComponentSidenavProxy} from './component-sidenav-proxy';
4141
import {MatDrawerToggleResult} from '@angular/material/sidenav/drawer';
4242
import {MatListModule} from '@angular/material/list';
4343

44+
// These constants are used by the ComponentSidenav for orchestrating the MatSidenav in a responsive
45+
// way. This includes hiding the sidenav, defaulting it to open, changing the mode from over to
46+
// side, determining the size of the top gap, and whether the sidenav is fixed in the viewport.
47+
// The values were determined through the combination of Material Design breakpoints and careful
48+
// testing of the application across a range of common device widths (360px+).
49+
// These breakpoint values need to stay in sync with the related Sass variables in
50+
// src/styles/_constants.scss.
4451
const EXTRA_SMALL_WIDTH_BREAKPOINT = 720;
4552
const SMALL_WIDTH_BREAKPOINT = 959;
4653

@@ -58,7 +65,7 @@ export class ComponentSidenav implements OnInit {
5865

5966
constructor(public docItems: DocumentationItems,
6067
private _route: ActivatedRoute,
61-
private componentSidenavService: ComponentSidenavService,
68+
private componentSidenavProxy: ComponentSidenavProxy,
6269
zone: NgZone,
6370
breakpoints: BreakpointObserver) {
6471
this.isExtraScreenSmall =
@@ -75,8 +82,8 @@ export class ComponentSidenav implements OnInit {
7582
}
7683

7784
toggleSidenav(sidenav: MatSidenav): Promise<MatDrawerToggleResult> {
78-
this.componentSidenavService.sidenav = sidenav;
79-
return this.componentSidenavService.sidenav.toggle();
85+
this.componentSidenavProxy.sidenav = sidenav;
86+
return this.componentSidenavProxy.sidenav.toggle();
8087
}
8188
}
8289

@@ -98,7 +105,7 @@ export class ComponentNav implements OnInit, OnDestroy {
98105
private _onDestroy = new Subject<void>();
99106

100107
constructor(public docItems: DocumentationItems, private _router: Router,
101-
private componentSidenavService: ComponentSidenavService) {}
108+
private componentSidenavProxy: ComponentSidenavProxy) {}
102109

103110
ngOnInit() {
104111
this._router.events.pipe(
@@ -154,8 +161,8 @@ export class ComponentNav implements OnInit, OnDestroy {
154161
* @param path component.id sub-path to use for navigation
155162
*/
156163
selectNavItem(path: string): void {
157-
if (this.componentSidenavService.sidenav) {
158-
this.componentSidenavService.sidenav.close().then(() => this.openNavItem(path));
164+
if (this.componentSidenavProxy.sidenav) {
165+
this.componentSidenavProxy.sidenav.close().then(() => this.openNavItem(path));
159166
} else {
160167
this.openNavItem(path);
161168
}

src/app/pages/component-viewer/component-api.html

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@
33
API for {{docItem?.id}}
44
</span>
55

6-
<span>
7-
<doc-viewer
8-
documentUrl="/docs-content/api-docs/{{docItem?.packageName}}-{{docItem?.id}}.html"
9-
class="docs-component-view-text-content docs-component-api"
10-
(contentRendered)="updateTableOfContents(docItem!.name, $event)">
11-
</doc-viewer>
6+
<doc-viewer
7+
documentUrl="/docs-content/api-docs/{{docItem?.packageName}}-{{docItem?.id}}.html"
8+
class="docs-component-view-text-content docs-component-api"
9+
(contentRendered)="updateTableOfContents(docItem!.name, $event)">
10+
</doc-viewer>
1211

13-
<doc-viewer *ngFor="let additionalApiDoc of docItem!.additionalApiDocs"
14-
documentUrl="/docs-content/api-docs/{{additionalApiDoc.path}}"
15-
class="docs-component-view-text-content docs-component-api"
16-
(contentRendered)="updateTableOfContents(additionalApiDoc.name, $event)">
17-
</doc-viewer>
18-
</span>
12+
<doc-viewer *ngFor="let additionalApiDoc of docItem!.additionalApiDocs"
13+
documentUrl="/docs-content/api-docs/{{additionalApiDoc.path}}"
14+
class="docs-component-view-text-content docs-component-api"
15+
(contentRendered)="updateTableOfContents(additionalApiDoc.name, $event)">
16+
</doc-viewer>
1917

2018
<table-of-contents #toc
2119
*ngIf="showToc | async"

src/app/pages/component-viewer/component-api.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
}
1212
}
1313

14+
.docs-api-type-alias-name,
15+
.docs-api-class-name {
16+
@media (max-width: 399px) {
17+
word-break: break-word;
18+
}
19+
}
20+
1421
.docs-api-h3 {
1522
font-weight: 300;
1623
font-size: 24px;

src/app/shared/footer/footer.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<div class="docs-footer-copyright">
2020
<div>
21-
<span>Powered by Google ©2010-2019.</span>
21+
<span>Powered by Google ©2010-2020.</span>
2222
<a href="https://github.com/angular/components/blob/master/LICENSE">Code licensed under an MIT-style License.</a>
2323
<span>Documentation licensed under CC BY 4.0.</span>
2424
</div>

src/styles/_api.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// Styles for API docs generated via dgeni from material2 source JsDocs.
22

3+
.docs-api {
4+
max-width: 100%;
5+
}
6+
37
// Top header, e.g., "API documentation for dialog".
48
.docs-api-h2 {
59
font-size: 30px;
@@ -62,6 +66,10 @@
6266
font-size: 12px;
6367
}
6468

69+
.docs-api-deprecated-marker {
70+
margin-right: 8px;
71+
}
72+
6573
.docs-api-module-import,
6674
.docs-api-class-selector-name,
6775
.docs-api-class-export-name {

src/styles/_constants.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
@import '../../node_modules/@angular/material/theming';
22

3+
// The values were determined through the combination of Material Design breakpoints and careful
4+
// testing of the application across a range of common device widths (360px+).
5+
// These breakpoint values need to stay in sync with the related constants in
6+
// src/app/pages/component-sidenav/component-sidenav.ts.
7+
// The extra small breakpoint is used for styling the guides and certain aspects of the tables.
38
$extra-small-breakpoint-width: 720px;
9+
// The small breakpoint is used for the component category and component list pages, the component
10+
// pages, the component sidenav, and certain aspects of the tables.
411
$small-breakpoint-width: 959px;
512

613
/* For desktop, the content should be aligned with the page title. */

src/styles/_tables.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
.docs-markdown-td {
2323
font-weight: 400;
2424
padding: 8px 16px;
25+
26+
@media (max-width: $extra-small-breakpoint-width) {
27+
&.docs-api-properties-name-cell,
28+
&.docs-api-method-parameter-cell,
29+
&.docs-api-method-returns-type-cell,
30+
&.docs-api-method-description-cell {
31+
min-width: 80px;
32+
word-break: break-word;
33+
}
34+
}
2535
}
2636

2737

0 commit comments

Comments
 (0)