@@ -8,28 +8,40 @@ import {
8
8
signal ,
9
9
viewChild ,
10
10
} from '@angular/core' ;
11
+ import { MatIcon } from '@angular/material/icon' ;
11
12
import { Router } from '@angular/router' ;
12
13
13
14
type Heading = { level : number ; text : string ; id : string ; url : string } ;
14
15
15
16
@Component ( {
16
17
selector : 'ngrx-markdown-article' ,
17
18
standalone : true ,
19
+ imports : [ MatIcon ] ,
18
20
template : `
19
21
<article #article>
20
22
<ng-content></ng-content>
21
23
</article>
22
24
<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>
33
45
</menu>
34
46
` ,
35
47
styles : [
@@ -39,6 +51,12 @@ type Heading = { level: number; text: string; id: string; url: string };
39
51
width: 100%;
40
52
position: relative;
41
53
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
+ }
42
60
}
43
61
44
62
menu {
@@ -52,6 +70,12 @@ type Heading = { level: number; text: string; id: string; url: string };
52
70
margin: 0;
53
71
padding: 0;
54
72
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
+ }
55
79
}
56
80
57
81
menu a {
@@ -69,10 +93,49 @@ type Heading = { level: number; text: string; id: string; url: string };
69
93
border-color: rgba(207, 143, 197, 0.96);
70
94
}
71
95
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
+
72
126
article {
73
- width: 960px;
127
+ max-width: 960px;
128
+ width: calc(100% - 120px);
74
129
padding: 24px;
75
130
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
+ }
76
139
}
77
140
78
141
article ::ng-deep h1 {
@@ -94,6 +157,10 @@ type Heading = { level: number; text: string; id: string; url: string };
94
157
border-left: 1px solid rgba(255, 255, 255, 0.12);
95
158
border-right: 1px solid rgba(255, 255, 255, 0.12);
96
159
margin: 14px 0;
160
+ @media only screen and (max-width: 1280px) {
161
+ display: block;
162
+ overflow-x: scroll;
163
+ }
97
164
}
98
165
99
166
article ::ng-deep table thead {
@@ -126,6 +193,7 @@ export class MarkdownArticleComponent implements OnDestroy {
126
193
articleRef : Signal < ElementRef < HTMLElement > > = viewChild . required ( 'article' ) ;
127
194
headings = signal < Heading [ ] > ( [ ] ) ;
128
195
activeHeadingId = signal < string | null > ( null ) ;
196
+ isMenuOpen = signal ( false ) ;
129
197
mutationObserver ?: MutationObserver ;
130
198
intersectionObserver ?: IntersectionObserver ;
131
199
0 commit comments