Skip to content

Commit

Permalink
chore: theme toggle icon tiny improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Aug 15, 2024
1 parent 131af41 commit e0261ae
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@
rel="nofollow">
<i class="fa-brands fa-discord"></i>
</a>
<app-theme-mode-toggle></app-theme-mode-toggle>
</div>
7 changes: 2 additions & 5 deletions src/app/common/social-wrapper/social-wrapper.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
.social-wrapper {
@extend .center-top;
float: right;
padding-right: 40px;
position: relative;
display: flex;

Expand Down Expand Up @@ -41,18 +40,16 @@
color: var(--primary);
}
}
@include media(medium) {
padding-right: 20px;
}

@include media(small) {
top: 0;
transform: none;
padding-right: 0;

a {
display: none;
}
}

@media print {
display: none;
}
Expand Down
1 change: 1 addition & 0 deletions src/app/homepage/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
</div>
</button>
<ng-content></ng-content>
<app-theme-mode-toggle></app-theme-mode-toggle>
<app-social-wrapper></app-social-wrapper>
<div class="menu-wrapper">
<div class="search-wrapper" id="search">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
@import '../../../../scss//utils.scss';
@use '../../../../scss/utils';

:host {
display: block;
display: flex;
@extend .center-top;
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
float: right;
padding-right: 40px;

@include utils.media(medium) {
padding-right: 20px;
}

@include utils.media(small) {
position: absolute;
right: 20px;
padding-right: 0;
}
}

.theme-mode-toggle {
Expand All @@ -29,31 +42,40 @@
padding-left: 15px;
position: relative;

@include media(small) {
@include utils.media(small) {
padding: 0;
margin: 0;
}

.material-icons {
font-size: 20px;
cursor: pointer;
@include utils.text-gradient();

@include utils.media(small) {
background: #fff;
}

&::before {
content: '';
position: absolute;
background: #fff;
opacity: 0.2;
left: 2px;
top: 0;
left: 0px;
top: 2px;
bottom: 2px;
width: 2px;
}

&:hover {
color: var(--primary);
background: #fff;

@include utils.media(small) {
@include utils.text-gradient();
}
}

@include media(small) {
@include utils.media(small) {
font-size: 24px;

&::before {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ export class ThemeModeToggleComponent implements OnInit {
) {}

ngOnInit() {
const userPrefersTheme =
this.mediaMatcher.matchMedia &&
this.mediaMatcher.matchMedia('(prefers-color-scheme: light)').matches;
// In case the user has used the toggle button, we prioritize it over the
// system settings
this.setThemeMode(this.getUserSettingsIsDarkMode() || userPrefersTheme);
// This is commented out because by default the theme mode is set to light (at least for now)
// const userPrefersTheme =
// this.mediaMatcher.matchMedia &&
// this.mediaMatcher.matchMedia('(prefers-color-scheme: light)').matches;
// this.setThemeMode(this.getUserSettingsIsDarkMode() || userPrefersTheme);

const isDarkMode = this.getUserSettingsIsDarkMode();
this.setThemeMode(isDarkMode);
}

toggleThemeMode() {
Expand Down

0 comments on commit e0261ae

Please sign in to comment.