@@ -15,6 +15,7 @@ import {
1515 ModalMessageComponent ,
1616 DialogInfo ,
1717} from '../modal-message/modal-message.component' ;
18+ import { ThemeService } from '../../service/theme.service' ;
1819
1920export interface activitySchema {
2021 uuid : string ;
@@ -83,28 +84,53 @@ export class CircularHeatmapComponent implements OnInit {
8384 constructor (
8485 private yaml : ymlService ,
8586 private router : Router ,
87+ private themeService : ThemeService ,
8688 public modal : ModalMessageComponent
8789 ) {
8890 this . showOverlay = false ;
8991 this . showFilters = true ;
9092 this . theme = 'light' ;
93+ this . theme = this . themeService . getTheme ( ) ;
94+
9195 this . theme_colors = this . themes [ this . theme ] ;
9296 }
9397
9498 ngOnInit ( ) : void {
95- console . log ( `${ this . perfNow ( ) } s: ngOnInit` ) ;
96- this . theme = localStorage . getItem ( 'theme' ) || 'light' ;
97- this . theme_colors = this . themes [ this . theme ] ;
99+ const savedTheme = this . themeService . getTheme ( ) || 'light' ;
100+ this . themeService . setTheme ( savedTheme ) ; // sets .light-theme or .dark-theme
101+
102+ requestAnimationFrame ( ( ) => {
103+ // Now the DOM has the correct class and CSS vars are live
104+ const css = getComputedStyle ( document . body ) ;
105+ this . theme_colors = {
106+ background : css . getPropertyValue ( '--heatmap-background' ) . trim ( ) ,
107+ filled : css . getPropertyValue ( '--heatmap-filled' ) . trim ( ) ,
108+ disabled : css . getPropertyValue ( '--heatmap-disabled' ) . trim ( ) ,
109+ cursor : css . getPropertyValue ( '--heatmap-cursor' ) . trim ( ) ,
110+ stroke : css . getPropertyValue ( '--heatmap-stroke' ) . trim ( ) ,
111+ } ;
98112
99- // Ensure that Levels and Teams load before MaturityData
100- // using promises, since ngOnInit does not support async/await
101- this . LoadMaturityLevels ( )
102- . then ( ( ) => this . LoadTeamsFromMetaYaml ( ) )
103- . then ( ( ) => this . LoadMaturityDataFromGeneratedYaml ( ) )
104- . then ( ( ) => {
105- console . log ( `${ this . perfNow ( ) } s: set filters: ${ this . chips ?. length } ` ) ;
106- this . matChipsArray = this . chips . toArray ( ) ;
107- } ) ;
113+ this . LoadMaturityLevels ( )
114+ . then ( ( ) => this . LoadTeamsFromMetaYaml ( ) )
115+ . then ( ( ) => this . LoadMaturityDataFromGeneratedYaml ( ) )
116+ . then ( ( ) => {
117+ this . matChipsArray = this . chips . toArray ( ) ;
118+ } ) ;
119+ } ) ;
120+
121+ // Reactively handle theme changes (if user toggles later)
122+ this . themeService . theme$ . subscribe ( ( theme : string ) => {
123+ const css = getComputedStyle ( document . body ) ;
124+ this . theme_colors = {
125+ background : css . getPropertyValue ( '--heatmap-background' ) . trim ( ) ,
126+ filled : css . getPropertyValue ( '--heatmap-filled' ) . trim ( ) ,
127+ disabled : css . getPropertyValue ( '--heatmap-disabled' ) . trim ( ) ,
128+ cursor : css . getPropertyValue ( '--heatmap-cursor' ) . trim ( ) ,
129+ stroke : css . getPropertyValue ( '--heatmap-stroke' ) . trim ( ) ,
130+ } ;
131+
132+ this . reColorHeatmap ( ) ; // repaint segments with new theme
133+ } ) ;
108134 }
109135
110136 @ViewChildren ( MatChip ) chips ! : QueryList < MatChip > ;
@@ -569,7 +595,7 @@ export class CircularHeatmapComponent implements OnInit {
569595 . startAngle ( sa )
570596 . endAngle ( ea )
571597 )
572- . attr ( 'stroke' , '#252525' )
598+ . attr ( 'stroke' , _self . theme_colors [ 'stroke' ] )
573599 . attr ( 'fill' , function ( d ) {
574600 return color ( accessor ( d ) ) ;
575601 } ) ;
0 commit comments