Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit 9be8a5e

Browse files
committed
docs: app supports v1 and v2 docs
1 parent a415f52 commit 9be8a5e

File tree

6 files changed

+95
-26
lines changed

6 files changed

+95
-26
lines changed

demo/src/app/app.component.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,14 @@ ul.side-nav.fixed ul.collapsible-accordion .collapsible-body li a {
7474
#logo-container {
7575
display: block;
7676
}
77+
78+
79+
.dt-version-button {
80+
text-transform: none;
81+
text-align: center;
82+
}
83+
84+
.dt-version-button svg {
85+
position: relative;
86+
top: 6px;
87+
}

demo/src/app/app.component.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ <h3>
1717
</a>
1818
</h3>
1919
</li>
20+
<li>
21+
<a class="dt-version-button btn-flat" data-activates='dropdown1'>
22+
DT version: '{{dtVersion}}'
23+
<svg class="caret" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"></path><path d="M0 0h24v24H0z" fill="none"></path></svg>
24+
</a>
25+
26+
<ul id='dropdown1' [(ngModel)]="dtVersion" class='dropdown-content'>
27+
<li [class.active]="dtVersion == 'v2'" (click)="onDTVersionChanged('v2')" value="v2" style="padding:0 32px">v2.x</li>
28+
<li [class.active]="dtVersion == 'v1'" (click)="onDTVersionChanged('v1')" value="v1" style="padding:0 32px">v1.x</li>
29+
</ul>
30+
</li>
31+
<li>
32+
<div class="divider"></div>
33+
</li>
2034
<li><a class="subheader">Getting Started</a></li>
2135
<li class="bold">
2236
<a routerLink="/getting-started" class="waves-effect waves-blue">Installation</a>

demo/src/app/app.component.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ export class AppComponent implements OnInit, OnDestroy {
1313

1414
routerEventsSub$: Subscription = null;
1515

16+
dtVersion = 'v2';
17+
1618
constructor(
1719
private router: Router
18-
) {}
20+
) { }
1921

2022
ngOnInit(): void {
2123
$.fn.dataTable.ext.errMode = 'none';
@@ -31,6 +33,23 @@ export class AppComponent implements OnInit, OnDestroy {
3133
$('ul.tabs').tabs();
3234
}, 600);
3335
});
36+
37+
// Init DT version picker
38+
$('.dt-version-button').dropdown({
39+
inDuration: 300,
40+
outDuration: 225,
41+
constrainWidth: true, // Does not change width of dropdown to that of the activator
42+
hover: false, // Activate on hover
43+
gutter: 14,
44+
belowOrigin: true,
45+
alignment: 'left', // Displays dropdown with edge aligned to the left of button
46+
stopPropagation: true // Stops event propagation
47+
});
48+
49+
}
50+
51+
onDTVersionChanged(v: string) {
52+
this.dtVersion = v;
3453
}
3554

3655
ngOnDestroy(): void {

demo/src/app/base-demo/base-demo.component.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h5 class="header">Description</h5>
3030
<li class="tab col">
3131
<a href="#previewTab">Preview</a>
3232
</li>
33-
<li class="tab col" *ngIf="mdInstall.length>0">
33+
<li class="tab col" *ngIf="dtVersion == 'v2' ? mdInstallV2.length>0 : mdInstall.length>0">
3434
<a href="#installTab">Installation</a>
3535
</li>
3636
<li class="tab col">
@@ -43,22 +43,22 @@ <h5 class="header">Description</h5>
4343
</div>
4444

4545
<!-- Preview -->
46-
<div id="previewTab" class=" col s12">
46+
<div id="previewTab" class="col s12">
4747
<ng-container *ngTemplateOutlet="template"></ng-container>
4848
</div>
4949

5050
<!-- Installation -->
51-
<div id="installTab" class="col s12" *ngIf="mdInstall.length > 0">
52-
<markdown [src]="mdInstall"></markdown>
51+
<div id="installTab" class="col s12" *ngIf="dtVersion == 'v2' ? mdInstallV2.length > 0 : mdInstall.length > 0">
52+
<markdown [src]="dtVersion == 'v2' ? mdInstallV2 : mdInstall"></markdown>
5353
</div>
5454

5555
<!-- HTML -->
5656
<div id="htmlTab" class="col s12">
57-
<markdown [src]="mdHTML"></markdown>
57+
<markdown [src]="dtVersion == 'v2' ? mdHTMLV2 : mdHTML"></markdown>
5858
</div>
5959

6060
<div id="typescriptTab" class="col s12">
61-
<markdown [src]="mdTS"></markdown>
61+
<markdown [src]="dtVersion == 'v2' ? mdTSV2 : mdTS"></markdown>
6262
</div>
6363
</div>
6464
</div>
Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { Component, Input, OnInit, TemplateRef } from '@angular/core';
1+
import { Component, Input, OnDestroy, OnInit, TemplateRef } from '@angular/core';
2+
import { DtVersionService } from '../dt-version.service';
3+
import { Subscription } from 'rxjs';
24

35
// needed to re-init tabs on route change
46
declare var $: JQueryStatic;
@@ -8,34 +10,41 @@ declare var $: JQueryStatic;
810
templateUrl: './base-demo.component.html',
911
styleUrls: ['./base-demo.component.css']
1012
})
11-
export class BaseDemoComponent implements OnInit {
13+
export class BaseDemoComponent implements OnInit, OnDestroy {
1214

13-
@Input()
14-
pageTitle = '';
15+
@Input() pageTitle = '';
1516

16-
@Input()
17-
mdIntro = '';
17+
@Input() mdIntro = '';
1818

19-
@Input()
20-
mdInstall = '';
19+
@Input() mdInstall = '';
20+
@Input() mdInstallV2 = '';
2121

22-
@Input()
23-
mdHTML = '';
22+
@Input() mdHTML = '';
23+
@Input() mdHTMLV2 = '';
2424

25-
@Input()
26-
mdTS = '';
25+
@Input() mdTS = '';
26+
@Input() mdTSV2 = '';
2727

28-
@Input()
29-
template: TemplateRef<any> = null;
28+
@Input() template: TemplateRef<any> = null;
3029

31-
@Input()
32-
deprecated = false;
30+
@Input() deprecated = false;
31+
32+
dtVersion = null;
33+
dtVersionSubscription$: Subscription = null;
34+
35+
constructor(
36+
private dtVersionService: DtVersionService
37+
) {}
3338

3439
ngOnInit() {
3540
// Re-init tabs on route change
3641

3742
// Init back to top
3843
this.initBackToTop();
44+
45+
this.dtVersionSubscription$ = this.dtVersionService.versionChanged$.subscribe(v => {
46+
this.dtVersion = v;
47+
});
3948
}
4049

4150
private scrollCallback() {
@@ -57,4 +66,8 @@ export class BaseDemoComponent implements OnInit {
5766
});
5867
}
5968

69+
ngOnDestroy(): void {
70+
this.dtVersionSubscription$?.unsubscribe();
71+
}
72+
6073
}

demo/src/styles.css

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ header, main, footer {
2020
}
2121

2222
.top-banner {
23-
height: 120px !important;
23+
min-height: 120px !important;
2424
}
2525

2626
.banner {
@@ -156,7 +156,7 @@ markdown h5:not(markdown.faqMarkdown) {
156156
}
157157

158158

159-
/** Fixed columns css
159+
/** Fixed columns css
160160
161161
These classes are injected by fixed columns extensions
162162
and can be tweaked here to match the colors of headers and body
@@ -184,4 +184,16 @@ table.dataTable tbody tr > .dtfc-fixed-right {
184184
div.dtfc-left-top-blocker,
185185
div.dtfc-right-top-blocker {
186186
background-color: white;
187-
}
187+
}
188+
189+
/* Dt v2 CSS messed up some stuff */
190+
.dt-search input {
191+
width: 200px !important;
192+
height: 20px !important;
193+
}
194+
195+
select.dt-input {
196+
display: inline-block !important;
197+
width: 60px;
198+
height: 40px;
199+
}

0 commit comments

Comments
 (0)