tbonelee commented on code in PR #5078:
URL: https://github.com/apache/zeppelin/pull/5078#discussion_r2399313993


##########
zeppelin-web-angular/src/app/share/theme-toggle/theme-toggle.component.ts:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, 
OnInit } from '@angular/core';
+import { Subject } from 'rxjs';
+import { takeUntil } from 'rxjs/operators';
+
+import { ThemeMode, ThemeService } from '../../services/theme.service';
+
+@Component({
+  selector: 'zeppelin-theme-toggle',
+  templateUrl: './theme-toggle.component.html',
+  styleUrls: ['./theme-toggle.component.less'],
+  changeDetection: ChangeDetectionStrategy.OnPush
+})
+export class ThemeToggleComponent implements OnInit, OnDestroy {
+  private destroy$ = new Subject();
+  currentTheme: ThemeMode = 'light';
+  isDarkMode = false;
+
+  constructor(private themeService: ThemeService, private cdr: 
ChangeDetectorRef) {}
+
+  ngOnInit() {
+    this.currentTheme = this.themeService.getCurrentTheme();
+    this.isDarkMode = this.currentTheme === 'dark';
+
+    this.themeService.theme$.pipe(takeUntil(this.destroy$)).subscribe(theme => 
{
+      if (this.currentTheme !== theme) {
+        this.currentTheme = theme;
+        this.isDarkMode = theme === 'dark';
+        this.cdr.markForCheck();
+      }
+    });
+  }
+
+  ngOnDestroy() {
+    this.destroy$.next();
+    this.destroy$.complete();
+  }
+
+  toggleTheme() {
+    this.themeService.toggleTheme();
+  }
+
+  setTheme(theme: ThemeMode) {
+    this.themeService.setTheme(theme);
+  }
+
+  getThemeIcon(): string {
+    if (this.currentTheme === 'system') {
+      return '🤖';
+    }
+    return this.currentTheme === 'dark' ? '🌙' : '☀️';
+  }
+}

Review Comment:
   Could you internalize those assets? We may need to account for environments 
like intranet. Also, we might need to add a line to the LICENSE file (to be 
confirmed). If the font files need to be excluded from the RAT check, please 
refer to `/pom.xml`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to