-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(): added dropdown for nestjs versions #1638
Open
Tony133
wants to merge
15
commits into
nestjs:master
Choose a base branch
from
Tony133:feat/dropdowns-versions-nest
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
092cf1e
feat(): added dropdown for nestjs versions
Tony133 ccec7bf
feat(): update dropdown
Tony133 c0a02be
feat(): updated
Tony133 016091c
feat(): updated
Tony133 b382090
feat(): improvement
Tony133 a54749c
feat(): added link for nest v8
Tony133 4a6b5c6
chore(deps): resolved conflits
Tony133 4c81eed
chore(deps): resolved conflits
Tony133 afedda4
chore(deps): resolved conflits
Tony133 af41c95
feat(): update versions component
Tony133 4df00df
chore(): resolve conflicts
Tony133 99857fc
chore(): resolved conflicts
Tony133 126c2f7
docs: tiny typo
ATeals b5e0258
Merge pull request #3079 from ATeals/master
kamilmysliwiec 6a3eca8
Merge branch 'master' into feat/dropdowns-versions-nest
Tony133 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,5 +82,10 @@ | |
> | ||
</li> | ||
</ul> | ||
<ul> | ||
<li> | ||
<app-versions></app-versions> | ||
</li> | ||
</ul> | ||
</div> | ||
</header> |
22 changes: 22 additions & 0 deletions
22
src/app/homepage/header/versions/services/versions.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Injectable } from '@angular/core'; | ||
import { Observable, throwError } from 'rxjs'; | ||
import { catchError } from 'rxjs/operators'; | ||
|
||
export default class Versions { | ||
version: String; | ||
} | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class VersionsService { | ||
constructor(private readonly httpClient: HttpClient) {} | ||
|
||
addToVersionLatest(): Observable<Versions[]> { | ||
const urlVersionsLatest = 'https://registry.npmjs.org/@nestjs/core/latest'; | ||
return this.httpClient.get<Versions[]>(urlVersionsLatest).pipe( | ||
catchError((err) => { | ||
return throwError(err); | ||
}), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<div | ||
class="dropdown dropdown-item" | ||
[class.opened]="isOpen" | ||
> | ||
<a | ||
href="#" | ||
class="drop-wrapper menu-wrapper" | ||
(click)="toggle()" | ||
> | ||
Versions | ||
<svg | ||
class="arrow-icon" | ||
width="20" | ||
height="20" | ||
viewBox="0 0 1792 1792" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
d="M1171 960q0 13-10 23l-466 466q-10 10-23 10t-23-10l-50-50q-10-10-10-23t10-23l393-393-393-393q-10-10-10-23t10-23l50-50q10-10 23-10t23 10l466 466q10 10 10 23z" | ||
/> | ||
</svg> | ||
</a> | ||
<div class="dropdown-content" [@openCloseAnimation]="isOpen"> | ||
<a *ngIf="linkLatest != true" class="dropdown-item" href="#">Latest(v{{ versions }})</a> | ||
<div class="dropdown-divider"></div> | ||
<a href="https://docs.nestjs.com/v8/" target="_blank">8.x</a> | ||
<a href="https://docs.nestjs.com/v7/" target="_blank">7.x</a> | ||
<a href="https://docs.nestjs.com/v6/" target="_blank">6.x</a> | ||
<a href="https://docs.nestjs.com/v5/" target="_blank">5.x</a> | ||
<a href="https://docs.nestjs.com/v4/" target="_blank">4.x</a> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
@import '../../../../scss/variables.scss'; | ||
@import '../../../../scss/utils.scss'; | ||
|
||
.drop-wrapper { | ||
padding: 16px; | ||
border: none; | ||
text-transform: uppercase; | ||
color: $white-color; | ||
font-size: 14px; | ||
font-weight: 600; | ||
&:hover { | ||
color: $red-color; | ||
} | ||
} | ||
|
||
.dropdown { | ||
position: relative; | ||
display: inline-block; | ||
} | ||
|
||
.dropdown-content { | ||
display: none; | ||
position: absolute; | ||
background-color: $silver-color; | ||
min-width: 160px; | ||
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); | ||
z-index: 1; | ||
margin-left: 8px; | ||
border-bottom-left-radius: 4px; | ||
border-bottom-right-radius: 4px; | ||
} | ||
|
||
.dropdown-content a { | ||
color: $black-color; | ||
padding: 12px 16px; | ||
text-decoration: none; | ||
display: block; | ||
&:hover { | ||
color: $red-color; | ||
} | ||
} | ||
|
||
svg { | ||
fill: $white-color; | ||
} | ||
|
||
.arrow-icon { | ||
@extend .transition; | ||
@include transform(rotate(90deg)); | ||
|
||
position: absolute; | ||
top: 1px; | ||
right: -10px; | ||
font-size: 20px; | ||
cursor: pointer; | ||
} | ||
|
||
.dropdown-item { | ||
ul { | ||
margin: 10px 0 15px; | ||
} | ||
|
||
&.opened { | ||
.arrow-icon { | ||
@include transform(rotate(-90deg)); | ||
fill: $red-color; | ||
} | ||
} | ||
} | ||
|
||
.dropdown:hover .dropdown-content { | ||
display: block; | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
src/app/homepage/header/versions/versions.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { VersionsComponent } from './versions.component'; | ||
|
||
describe('VersionsComponent', () => { | ||
let component: VersionsComponent; | ||
let fixture: ComponentFixture<VersionsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ VersionsComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(VersionsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
Input, | ||
OnInit, | ||
} from '@angular/core'; | ||
import { openCloseAnimation } from '../../../common'; | ||
import { VersionsService } from './services/versions.service'; | ||
|
||
export default class Versions { | ||
version: String; | ||
} | ||
|
||
@Component({ | ||
selector: 'app-versions', | ||
templateUrl: './versions.component.html', | ||
styleUrls: ['./versions.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
animations: [openCloseAnimation], | ||
}) | ||
export class VersionsComponent implements OnInit { | ||
@Input() isOpen = false; | ||
@Input() icon: string; | ||
|
||
versions: Versions[]; | ||
linkLatest: boolean = false; | ||
|
||
constructor(private readonly versionsService: VersionsService) {} | ||
|
||
toggle() { | ||
this.isOpen = !this.isOpen; | ||
} | ||
|
||
ngOnInit(): void { | ||
this.versionsService.addToVersionLatest().subscribe({ | ||
next: (data) => { | ||
this.versions = data['version']; | ||
}, | ||
error: (error) => { | ||
this.linkLatest = true; | ||
throw error; | ||
}, | ||
}); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't this behavior be better? I mean, if one want to see the docs of another version, they problably don't care about the current one