Skip to content

Commit 06557cc

Browse files
committed
chore: fix lint issues & migrate to function-based DI
1 parent c3d7a7f commit 06557cc

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

eslint.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export default tseslint.config(
1212
processor: angularEslint.processInlineTemplates,
1313
languageOptions: {
1414
parserOptions: {
15-
project: true,
15+
projectService: true,
16+
tsconfigRootDir: import.meta.dirname,
1617
},
1718
},
1819
rules: {

projects/material-css-vars/src/lib/material-css-vars.service.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
2-
Inject,
32
Injectable,
43
Renderer2,
54
RendererFactory2,
65
RendererStyleFlags2,
76
DOCUMENT,
87
isDevMode,
8+
inject,
99
} from "@angular/core";
1010
import { Numberify, RGBA, TinyColor } from "@ctrl/tinycolor";
1111
import {
@@ -52,13 +52,11 @@ export class MaterialCssVarsService {
5252
private ROOT: HTMLElement;
5353
private readonly _black = new TinyColor("#000000");
5454
private readonly _white = new TinyColor("#ffffff");
55+
private readonly document = inject(DOCUMENT);
5556

56-
constructor(
57-
rendererFactory: RendererFactory2,
58-
@Inject(DOCUMENT) private document: Document,
59-
@Inject(MATERIAL_CSS_VARS_CFG) cfg: MaterialCssVariablesConfig,
60-
) {
61-
this.renderer = rendererFactory.createRenderer(null, null);
57+
constructor() {
58+
this.renderer = inject(RendererFactory2).createRenderer(null, null);
59+
const cfg = inject(MATERIAL_CSS_VARS_CFG);
6260
this.ROOT = this._getRootElement(cfg.rootSelector);
6361

6462
this.cfg = {

src/app/app.component.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Component } from "@angular/core";
1+
import { Component, inject } from "@angular/core";
22
import {
33
ThemePalette,
44
MatOptionModule,
55
MatNativeDateModule,
66
} from "@angular/material/core";
7-
import { MatDialog, MatDialogModule } from "@angular/material/dialog";
7+
import { MatDialogModule } from "@angular/material/dialog";
88
import { MatSnackBar, MatSnackBarModule } from "@angular/material/snack-bar";
99
import { MaterialCssVarsService } from "../../projects/material-css-vars/src/lib/material-css-vars.service";
1010
import {
@@ -133,11 +133,10 @@ export class AppComponent {
133133
allComplete = false;
134134
someComplete = false;
135135

136-
constructor(
137-
private _dialog: MatDialog,
138-
private _snackbar: MatSnackBar,
139-
public materialCssVarsService: MaterialCssVarsService,
140-
) {
136+
readonly materialCssVarsService = inject(MaterialCssVarsService);
137+
private readonly _snackbar = inject(MatSnackBar);
138+
139+
constructor() {
141140
this.toggleTheme();
142141
// this.onPrimaryChange(this.primary);
143142
// this.onAccentChange(this.accent);

0 commit comments

Comments
 (0)