jjranalli/nightwind

Help setting up for an Angular project

andreapesci opened this issue · 2 comments

Hi!

First of all great project, takes away a big part of the hassle of managing the dark mode, handling a big part of it without even worrying about.

Although i couldn't find a way to initialize it for an Angular project (if it does even support it), i could only find react, nextjs or play js in your docs.

Could you share some information on how to get going?

Thanks in advance

Hey,

right now the types declarations file is missing so you can't get it working out of the box.
There is an open pull request for that issue but it's already open for more than a year, so I guess you should not wait for it to get merged: #36

If you want to get it running with your angular project you just have to create that file from the project yourself (helper.d.ts).
After that you can import nightwind and use the functions:

import nightwind from "nightwind/helper";

@Component({
  ...
})
export class AppComponent implements OnInit {

  ngOnInit(): void {
    // init nightwind
    nightwind.init();
    // enable nightwind dark mode
    nightwind.enable(true);
  }
}

Not quite - nightwind.init() returns a string/script that belongs in a <script> tag in the head. It belongs in the <head> to avoid the lightmode flash. See the readme. Basically, you need to do the equivalent of <script>{nightwind.init()}</script> in Angular.