Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { Component, inject } from '@angular/core';
import { Storage, ThemingService } from '@nifi/shared';
import { OS_SETTING, Storage, ThemingService } from '@nifi/shared';

@Component({
selector: 'nifi-jolt-transform-json-ui',
Expand All @@ -31,7 +31,7 @@ export class AppComponent {
title = 'nifi-jolt-transform-json-ui';

constructor() {
let theme = this.storage.getItem('theme');
let theme = this.storage.getItem('theme') ? this.storage.getItem('theme') : OS_SETTING;

// Initially check if dark mode is enabled on system
const darkModeOn = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
Expand All @@ -42,7 +42,7 @@ export class AppComponent {
if (window.matchMedia) {
// Watch for changes of the preference
window.matchMedia('(prefers-color-scheme: dark)').addListener((e) => {
theme = this.storage.getItem('theme');
theme = this.storage.getItem('theme') ? this.storage.getItem('theme') : OS_SETTING;
this.themingService.toggleTheme(e.matches, theme);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { Component, inject } from '@angular/core';
import { ThemingService, Storage } from '@nifi/shared';
import { ThemingService, Storage, OS_SETTING } from '@nifi/shared';

@Component({
selector: 'nifi-registry-app-root',
Expand All @@ -31,7 +31,7 @@ export class AppComponent {
title = 'nifi-registry';

constructor() {
let theme = this.storage.getItem('theme');
let theme = this.storage.getItem('theme') ? this.storage.getItem('theme') : OS_SETTING;

// Initially check if dark mode is enabled on system
const darkModeOn = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
Expand All @@ -42,7 +42,7 @@ export class AppComponent {
if (window.matchMedia) {
// Watch for changes of the preference
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
theme = this.storage.getItem('theme');
theme = this.storage.getItem('theme') ? this.storage.getItem('theme') : OS_SETTING;
this.themingService.toggleTheme(e.matches, theme);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,32 @@
opacity: 0.6;
}
}

.global-menu-item {
&.selected {
@include mat.menu-overrides(
(
item-icon-color: var(--mat-sys-primary),
item-label-text-color: var(--mat-sys-primary)
)
);

.fa {
color: var(--mat-sys-primary);
}
}

&.selected:hover {
@include mat.menu-overrides(
(
item-icon-color: var(--mat-sys-primary),
item-label-text-color: var(--mat-sys-primary)
)
);

.fa {
color: var(--mat-sys-primary);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@
</button>
</mat-menu>
<mat-menu #theming="matMenu" xPosition="before">
<button mat-menu-item class="global-menu-item" (click)="toggleTheme(LIGHT_THEME)">
<button
mat-menu-item
class="global-menu-item"
[class.selected]="theme === LIGHT_THEME"
(click)="toggleTheme(LIGHT_THEME)">
@if (theme === LIGHT_THEME) {
<i class="fa fa-check primary-color mr-2"></i>
}
Expand All @@ -78,7 +82,11 @@
}
Light
</button>
<button mat-menu-item class="global-menu-item" (click)="toggleTheme(DARK_THEME)">
<button
mat-menu-item
class="global-menu-item"
[class.selected]="theme === DARK_THEME"
(click)="toggleTheme(DARK_THEME)">
@if (theme === DARK_THEME) {
<i class="fa fa-check primary-color mr-2"></i>
}
Expand All @@ -87,7 +95,11 @@
}
Dark
</button>
<button mat-menu-item class="global-menu-item" (click)="toggleTheme(OS_SETTING)">
<button
mat-menu-item
class="global-menu-item"
[class.selected]="theme === OS_SETTING"
(click)="toggleTheme(OS_SETTING)">
@if (theme === OS_SETTING || theme === null) {
<i class="fa fa-check primary-color mr-2"></i>
}
Expand All @@ -98,23 +110,35 @@
</button>
</mat-menu>
<mat-menu #animations="matMenu" xPosition="before">
<button mat-menu-item class="global-menu-item" (click)="toggleAnimations('false')">
<button
mat-menu-item
class="global-menu-item"
[class.selected]="disableAnimations === 'false'"
(click)="toggleAnimations('false')">
@if (disableAnimations === 'false') {
<i class="fa fa-check primary-color mr-2"></i>
} @else {
<i class="fa mr-2"></i>
}
Enabled
</button>
<button mat-menu-item class="global-menu-item" (click)="toggleAnimations('true')">
<button
mat-menu-item
class="global-menu-item"
[class.selected]="disableAnimations === 'true'"
(click)="toggleAnimations('true')">
@if (disableAnimations === 'true') {
<i class="fa fa-check primary-color mr-2"></i>
} @else {
<i class="fa mr-2"></i>
}
Disabled
</button>
<button mat-menu-item class="global-menu-item" (click)="toggleAnimations()">
<button
mat-menu-item
class="global-menu-item"
[class.selected]="disableAnimations === null"
(click)="toggleAnimations()">
@if (disableAnimations === null) {
<i class="fa fa-check primary-color mr-2"></i>
} @else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ export class HeaderComponent implements OnInit {

constructor() {
this.darkModeOn = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
this.theme = this.storage.getItem('theme');
this.theme = this.storage.getItem('theme') ? this.storage.getItem('theme') : OS_SETTING;
this.disableAnimations = this.storage.getItem('disable-animations');

if (window.matchMedia) {
// Watch for changes of the preference
window.matchMedia('(prefers-color-scheme: dark)').addListener((e) => {
this.darkModeOn = e.matches;
this.theme = this.storage.getItem('theme');
this.theme = this.storage.getItem('theme') ? this.storage.getItem('theme') : OS_SETTING;
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
Router
} from '@angular/router';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { Storage, ThemingService } from '@nifi/shared';
import { OS_SETTING, Storage, ThemingService } from '@nifi/shared';
import { MatDialog } from '@angular/material/dialog';
import { NiFiState } from './state';
import { Store } from '@ngrx/store';
Expand Down Expand Up @@ -102,7 +102,7 @@ export class AppComponent implements OnDestroy {
}
});

let theme = this.storage.getItem('theme');
let theme = this.storage.getItem('theme') ? this.storage.getItem('theme') : OS_SETTING;

// Initially check if dark mode is enabled on system
const darkModeOn = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
Expand All @@ -113,7 +113,7 @@ export class AppComponent implements OnDestroy {
if (window.matchMedia) {
// Watch for changes of the preference
window.matchMedia('(prefers-color-scheme: dark)').addListener((e) => {
theme = this.storage.getItem('theme');
theme = this.storage.getItem('theme') ? this.storage.getItem('theme') : OS_SETTING;
this.themingService.toggleTheme(e.matches, theme);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,32 @@
opacity: 0.6;
}
}

.global-menu-item {
&.selected {
@include mat.menu-overrides(
(
item-icon-color: var(--mat-sys-primary),
item-label-text-color: var(--mat-sys-primary)
)
);

.fa {
color: var(--mat-sys-primary);
}
}

&.selected:hover {
@include mat.menu-overrides(
(
item-icon-color: var(--mat-sys-primary),
item-label-text-color: var(--mat-sys-primary)
)
);

.fa {
color: var(--mat-sys-primary);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,27 +167,39 @@
</button>
</mat-menu>
<mat-menu #theming="matMenu" xPosition="before">
<button mat-menu-item class="global-menu-item" (click)="toggleTheme(LIGHT_THEME)">
<button
mat-menu-item
class="global-menu-item"
[class.selected]="theme === LIGHT_THEME"
(click)="toggleTheme(LIGHT_THEME)">
@if (theme === LIGHT_THEME) {
<i class="fa fa-check primary-color mr-2"></i>
<i class="fa fa-check mr-2"></i>
}
@if (theme !== LIGHT_THEME) {
<i class="fa mr-2"></i>
}
Light
</button>
<button mat-menu-item class="global-menu-item" (click)="toggleTheme(DARK_THEME)">
<button
mat-menu-item
class="global-menu-item"
[class.selected]="theme === DARK_THEME"
(click)="toggleTheme(DARK_THEME)">
@if (theme === DARK_THEME) {
<i class="fa fa-check primary-color mr-2"></i>
<i class="fa fa-check mr-2"></i>
}
@if (theme !== DARK_THEME) {
<i class="fa mr-2"></i>
}
Dark
</button>
<button mat-menu-item class="global-menu-item" (click)="toggleTheme(OS_SETTING)">
<button
mat-menu-item
class="global-menu-item"
[class.selected]="theme === OS_SETTING"
(click)="toggleTheme(OS_SETTING)">
@if (theme === OS_SETTING || theme === null) {
<i class="fa fa-check primary-color mr-2"></i>
<i class="fa fa-check mr-2"></i>
}
@if (theme !== OS_SETTING && theme !== null) {
<i class="fa mr-2"></i>
Expand All @@ -196,25 +208,37 @@
</button>
</mat-menu>
<mat-menu #animations="matMenu" xPosition="before">
<button mat-menu-item class="global-menu-item" (click)="toggleAnimations('false')">
<button
mat-menu-item
class="global-menu-item"
[class.selected]="disableAnimations === 'false'"
(click)="toggleAnimations('false')">
@if (disableAnimations === 'false') {
<i class="fa fa-check primary-color mr-2"></i>
<i class="fa fa-check mr-2"></i>
} @else {
<i class="fa mr-2"></i>
}
Enabled
</button>
<button mat-menu-item class="global-menu-item" (click)="toggleAnimations('true')">
<button
mat-menu-item
class="global-menu-item"
[class.selected]="disableAnimations === 'true'"
(click)="toggleAnimations('true')">
@if (disableAnimations === 'true') {
<i class="fa fa-check primary-color mr-2"></i>
<i class="fa fa-check mr-2"></i>
} @else {
<i class="fa mr-2"></i>
}
Disabled
</button>
<button mat-menu-item class="global-menu-item" (click)="toggleAnimations()">
<button
mat-menu-item
class="global-menu-item"
[class.selected]="disableAnimations === null"
(click)="toggleAnimations()">
@if (disableAnimations === null) {
<i class="fa fa-check primary-color mr-2"></i>
<i class="fa fa-check mr-2"></i>
} @else {
<i class="fa mr-2"></i>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ export class Navigation implements OnInit, OnDestroy {

constructor() {
this.darkModeOn = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
this.theme = this.storage.getItem('theme');
this.theme = this.storage.getItem('theme') ? this.storage.getItem('theme') : OS_SETTING;
this.disableAnimations = this.storage.getItem('disable-animations');

// Watch for changes of the preference
window.matchMedia('(prefers-color-scheme: dark)').addListener((e) => {
this.darkModeOn = e.matches;
this.theme = this.storage.getItem('theme');
this.theme = this.storage.getItem('theme') ? this.storage.getItem('theme') : OS_SETTING;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { Component, inject } from '@angular/core';
import { Storage, ThemingService } from '@nifi/shared';
import { OS_SETTING, Storage, ThemingService } from '@nifi/shared';

@Component({
selector: 'app',
Expand All @@ -31,7 +31,7 @@ export class AppComponent {
title = 'standard-content-viewer';

constructor() {
let theme = this.storage.getItem('theme');
let theme = this.storage.getItem('theme') ? this.storage.getItem('theme') : OS_SETTING;

// Initially check if dark mode is enabled on system
const darkModeOn = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
Expand All @@ -42,7 +42,7 @@ export class AppComponent {
if (window.matchMedia) {
// Watch for changes of the preference
window.matchMedia('(prefers-color-scheme: dark)').addListener((e) => {
theme = this.storage.getItem('theme');
theme = this.storage.getItem('theme') ? this.storage.getItem('theme') : OS_SETTING;
this.themingService.toggleTheme(e.matches, theme);
});
}
Expand Down
Loading