Skip to content

Commit 4c921e3

Browse files
fix(www): Make Guide Pages Responsive (#4900)
Co-authored-by: Marko Stanimirović <[email protected]>
1 parent 7108d84 commit 4c921e3

File tree

2 files changed

+87
-12
lines changed

2 files changed

+87
-12
lines changed

projects/www/src/app/components/docs/markdown-article.component.ts

Lines changed: 79 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,40 @@ import {
88
signal,
99
viewChild,
1010
} from '@angular/core';
11+
import { MatIcon } from '@angular/material/icon';
1112
import { Router } from '@angular/router';
1213

1314
type Heading = { level: number; text: string; id: string; url: string };
1415

1516
@Component({
1617
selector: 'ngrx-markdown-article',
1718
standalone: true,
19+
imports: [MatIcon],
1820
template: `
1921
<article #article>
2022
<ng-content></ng-content>
2123
</article>
2224
<menu>
23-
@for (heading of headings(); track $index) {
24-
<a
25-
[href]="heading.url"
26-
[style]="{ paddingLeft: 24 + (heading.level - 2) * 8 + 'px' }"
27-
[class.active]="activeHeadingId() === heading.id"
28-
(click)="navigateToHeading($event, heading)"
29-
>
30-
{{ heading.text }}
31-
</a>
32-
}
25+
<div class="content-menu" (click)="isMenuOpen.set(!isMenuOpen())">
26+
<mat-icon>library_books</mat-icon>
27+
@if(isMenuOpen()){
28+
<mat-icon>keyboard_arrow_up</mat-icon>
29+
}@else{
30+
<mat-icon>keyboard_arrow_down</mat-icon>
31+
}
32+
</div>
33+
<div class="content-menu-holder" [class.open]="isMenuOpen()">
34+
@for (heading of headings(); track $index) {
35+
<a
36+
[href]="heading.url"
37+
[style]="{ paddingLeft: 24 + (heading.level - 2) * 8 + 'px' }"
38+
[class.active]="activeHeadingId() === heading.id"
39+
(click)="navigateToHeading($event, heading)"
40+
>
41+
{{ heading.text }}
42+
</a>
43+
}
44+
</div>
3345
</menu>
3446
`,
3547
styles: [
@@ -39,6 +51,12 @@ type Heading = { level: number; text: string; id: string; url: string };
3951
width: 100%;
4052
position: relative;
4153
padding-right: 240px;
54+
@media only screen and (max-width: 1280px) {
55+
padding-top: 40px;
56+
padding-right: 0px;
57+
display: flex;
58+
flex-direction: column-reverse;
59+
}
4260
}
4361
4462
menu {
@@ -52,6 +70,12 @@ type Heading = { level: number; text: string; id: string; url: string };
5270
margin: 0;
5371
padding: 0;
5472
border-left: 1px solid rgba(255, 255, 255, 0.12);
73+
@media only screen and (max-width: 1280px) {
74+
position: relative;
75+
width: 100%;
76+
padding: 24px;
77+
right: 0px;
78+
}
5579
}
5680
5781
menu a {
@@ -69,10 +93,49 @@ type Heading = { level: number; text: string; id: string; url: string };
6993
border-color: rgba(207, 143, 197, 0.96);
7094
}
7195
96+
.content-menu-holder {
97+
display: flex;
98+
flex-direction: column;
99+
gap: 6px;
100+
@media only screen and (max-width: 1280px) {
101+
display: none;
102+
&.open {
103+
display: flex;
104+
}
105+
}
106+
}
107+
108+
.content-menu {
109+
align-items: center;
110+
justify-content: space-between;
111+
padding: 5px 10px;
112+
background: #201a23;
113+
border-radius: 5px;
114+
display: flex;
115+
margin-bottom: 10px;
116+
cursor: pointer;
117+
display: none;
118+
@media only screen and (max-width: 1280px) {
119+
display: flex;
120+
}
121+
&:hover {
122+
background: #262029;
123+
}
124+
}
125+
72126
article {
73-
width: 960px;
127+
max-width: 960px;
128+
width: calc(100% - 120px);
74129
padding: 24px;
75130
margin: 0 auto;
131+
@media only screen and (max-width: 1500px) {
132+
margin: 0px;
133+
}
134+
@media only screen and (max-width: 1280px) {
135+
max-width: 100%;
136+
width: 100%;
137+
margin: 0px;
138+
}
76139
}
77140
78141
article ::ng-deep h1 {
@@ -94,6 +157,10 @@ type Heading = { level: number; text: string; id: string; url: string };
94157
border-left: 1px solid rgba(255, 255, 255, 0.12);
95158
border-right: 1px solid rgba(255, 255, 255, 0.12);
96159
margin: 14px 0;
160+
@media only screen and (max-width: 1280px) {
161+
display: block;
162+
overflow-x: scroll;
163+
}
97164
}
98165
99166
article ::ng-deep table thead {
@@ -126,6 +193,7 @@ export class MarkdownArticleComponent implements OnDestroy {
126193
articleRef: Signal<ElementRef<HTMLElement>> = viewChild.required('article');
127194
headings = signal<Heading[]>([]);
128195
activeHeadingId = signal<string | null>(null);
196+
isMenuOpen = signal(false);
129197
mutationObserver?: MutationObserver;
130198
intersectionObserver?: IntersectionObserver;
131199

projects/www/src/app/components/guide-footer.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,16 @@ import { FlattenedLink } from '../services/guide-menu.service';
4545
display: grid;
4646
grid-template-columns: 1fr 1fr;
4747
gap: 24px;
48-
max-width: 960px;
48+
width: 960px;
4949
padding-top: 24px;
5050
margin-top: 24px;
5151
border-top: 1px solid rgba(255, 255, 255, 0.12);
52+
@media only screen and (max-width: 1280px) {
53+
width: 100%;
54+
}
55+
@media only screen and (max-width: 480px) {
56+
grid-template-columns: 1fr;
57+
}
5258
}
5359
5460
.linkWrapper a {
@@ -60,6 +66,7 @@ import { FlattenedLink } from '../services/guide-menu.service';
6066
border: 1px solid rgba(255, 255, 255, 0.12);
6167
align-items: center;
6268
transition: border-color 200ms;
69+
height: 100%;
6370
}
6471
6572
.linkWrapper.previous a {

0 commit comments

Comments
 (0)