import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-l-d-mode',
  templateUrl: './l-d-mode.component.html',
  styleUrls: ['./l-d-mode.component.scss']
})
export class LDModeComponent implements OnInit {

  constructor() { }

  currentTheme: any;

  ngOnInit(): void {
    this.currentTheme = 0;
    var btn = document.getElementById('button') as HTMLButtonElement;
    btn.onclick = () => {
      this.currentTheme = 1 - this.currentTheme;
      document.querySelector('body').classList.toggle('light');
      if (btn.innerHTML === 'Light') btn.innerHTML = 'Dark';
      else btn.innerHTML = 'Light';
      var str = this.currentTheme == 1 ? "2px solid #112" : "2px solid #ddf";
      Object.assign((document.getElementsByClassName('CodeMirror')[0] as HTMLTextAreaElement).style, {
        border: str
      });
    }
  }

}
