-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
�feat: Added dark mode theme to the docs
- Loading branch information
1 parent
faba156
commit 35b218c
Showing
16 changed files
with
1,937 additions
and
190 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,8 +1,62 @@ | ||
import { Component } from '@angular/core'; | ||
import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-social-wrapper', | ||
templateUrl: './social-wrapper.component.html', | ||
styleUrls: ['./social-wrapper.component.scss'] | ||
styleUrls: ['./social-wrapper.component.scss'], | ||
}) | ||
export class SocialWrapperComponent {} | ||
export class SocialWrapperComponent implements OnInit { | ||
|
||
public theme: string = ''; | ||
|
||
constructor( | ||
private readonly changeDetectoRef: ChangeDetectorRef | ||
) {} | ||
|
||
ngOnInit(): void { | ||
if (localStorage.getItem('color-theme')) { | ||
if (localStorage.getItem('color-theme') === 'light') { | ||
this.theme = 'light'; | ||
} else { | ||
this.theme = 'dark'; | ||
} | ||
|
||
// if NOT set via local storage previously | ||
} else { | ||
if (document.documentElement.classList.contains('dark')) { | ||
this.theme = 'light'; | ||
} else { | ||
this.theme = 'dark'; | ||
} | ||
} | ||
this.changeDetectoRef.detectChanges(); | ||
} | ||
|
||
changeTheme(): void { | ||
// if set via local storage previously | ||
if (localStorage.getItem('color-theme')) { | ||
if (localStorage.getItem('color-theme') === 'light') { | ||
document.documentElement.classList.add('dark'); | ||
localStorage.setItem('color-theme', 'dark'); | ||
this.theme = 'dark'; | ||
} else { | ||
document.documentElement.classList.remove('dark'); | ||
localStorage.setItem('color-theme', 'light'); | ||
this.theme = 'light'; | ||
} | ||
|
||
// if NOT set via local storage previously | ||
} else { | ||
if (document.documentElement.classList.contains('dark')) { | ||
document.documentElement.classList.remove('dark'); | ||
localStorage.setItem('color-theme', 'light'); | ||
this.theme = 'light'; | ||
} else { | ||
document.documentElement.classList.add('dark'); | ||
localStorage.setItem('color-theme', 'dark'); | ||
this.theme = 'dark'; | ||
} | ||
} | ||
this.changeDetectoRef.detectChanges(); | ||
} | ||
} |
Oops, something went wrong.