@udixio/theme 1.0.0-beta.5 → 1.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.container.d.ts +5 -0
- package/dist/app.module.d.ts +2 -2
- package/dist/app.service.d.ts +4 -1
- package/dist/color/color-manager.service.d.ts +4 -2
- package/dist/color/color.module.d.ts +2 -2
- package/dist/color/color.service.d.ts +4 -2
- package/dist/index.d.ts +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/theme/services/theme.service.d.ts +6 -3
- package/dist/theme/services/variant.service.d.ts +4 -2
- package/dist/theme/theme.module.d.ts +2 -2
- package/dist/theme.cjs.development.js +179 -509
- package/dist/theme.cjs.development.js.map +1 -1
- package/dist/theme.cjs.production.min.js +1 -1
- package/dist/theme.cjs.production.min.js.map +1 -1
- package/dist/theme.esm.js +169 -508
- package/dist/theme.esm.js.map +1 -1
- package/package.json +6 -13
- package/src/app.container.ts +38 -0
- package/src/app.module.ts +5 -8
- package/src/app.service.spec.ts +1 -1
- package/src/app.service.ts +12 -6
- package/src/color/color-manager.service.ts +4 -3
- package/src/color/color.module.ts +6 -8
- package/src/color/color.service.ts +8 -3
- package/src/index.ts +1 -1
- package/src/main.ts +3 -8
- package/src/theme/services/scheme.service.ts +0 -2
- package/src/theme/services/theme.service.ts +12 -6
- package/src/theme/services/variant.service.ts +4 -3
- package/src/theme/theme.module.ts +8 -9
package/src/app.module.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { asClass } from 'awilix';
|
|
2
2
|
import { AppService } from './app.service';
|
|
3
|
-
import {
|
|
4
|
-
import { ThemeModule } from './theme/theme.module';
|
|
3
|
+
import { Module } from './app.container';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
})
|
|
10
|
-
export class AppModule {}
|
|
5
|
+
export const AppModule: Module = {
|
|
6
|
+
appService: asClass(AppService).singleton(),
|
|
7
|
+
};
|
package/src/app.service.spec.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Test, TestingModule } from '@nestjs/testing';
|
|
2
2
|
import { AppService } from '../src/app.service';
|
|
3
|
-
import { AppModule } from '
|
|
3
|
+
import { AppModule } from './app.container';
|
|
4
4
|
|
|
5
5
|
describe('AppController (e2e)', () => {
|
|
6
6
|
let appService: AppService;
|
package/src/app.service.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
1
|
import { ColorService } from './color/color.service';
|
|
3
2
|
import { ThemeService } from './theme/services/theme.service';
|
|
4
3
|
|
|
5
|
-
@Injectable()
|
|
6
4
|
export class AppService {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
public colorService: ColorService;
|
|
6
|
+
public themeService: ThemeService;
|
|
7
|
+
constructor({
|
|
8
|
+
colorService,
|
|
9
|
+
themeService,
|
|
10
|
+
}: {
|
|
11
|
+
colorService: ColorService;
|
|
12
|
+
themeService: ThemeService;
|
|
13
|
+
}) {
|
|
14
|
+
this.colorService = colorService;
|
|
15
|
+
this.themeService = themeService;
|
|
16
|
+
}
|
|
11
17
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
1
|
import { ContrastCurve, ToneDeltaPair } from '../material-color-utilities';
|
|
3
2
|
import { DynamicColor } from '../material-color-utilities/dynamic_color';
|
|
4
3
|
import { SchemeEntity } from '../theme/entities/scheme.entity';
|
|
@@ -20,10 +19,12 @@ export const highestSurface = (
|
|
|
20
19
|
: colorManagerService.get('surfaceDim').getDynamicColor();
|
|
21
20
|
};
|
|
22
21
|
|
|
23
|
-
@Injectable()
|
|
24
22
|
export class ColorManagerService {
|
|
25
23
|
private colorMap = new Map<string, ColorEntity>();
|
|
26
|
-
|
|
24
|
+
private readonly schemeService: SchemeService;
|
|
25
|
+
constructor({ schemeService }: { schemeService: SchemeService }) {
|
|
26
|
+
this.schemeService = schemeService;
|
|
27
|
+
}
|
|
27
28
|
|
|
28
29
|
createOrUpdate(key: string, args: Partial<ColorOptions>): ColorEntity {
|
|
29
30
|
let colorEntity = this.colorMap.get(key);
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { ColorService } from './color.service';
|
|
2
|
-
import { Module } from '@nestjs/common';
|
|
3
2
|
import { ColorManagerService } from './color-manager.service';
|
|
4
|
-
import {
|
|
3
|
+
import { asClass } from 'awilix';
|
|
4
|
+
import { Module } from '../app.container';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})
|
|
11
|
-
export class ColorModule {}
|
|
6
|
+
export const ColorModule: Module = {
|
|
7
|
+
colorManagerService: asClass(ColorManagerService).singleton(),
|
|
8
|
+
colorService: asClass(ColorService).singleton(),
|
|
9
|
+
};
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
1
|
import { ColorManagerService } from './color-manager.service';
|
|
3
2
|
import { ColorInterface } from './color.interface';
|
|
4
3
|
import { ColorEntity, ColorOptions } from './entities/color.entity';
|
|
5
4
|
import { defaultColors, DynamicColorKey } from './models/default-color.model';
|
|
6
5
|
|
|
7
|
-
@Injectable()
|
|
8
6
|
export class ColorService implements ColorInterface {
|
|
9
|
-
|
|
7
|
+
private readonly colorManagerService: ColorManagerService;
|
|
8
|
+
constructor({
|
|
9
|
+
colorManagerService,
|
|
10
|
+
}: {
|
|
11
|
+
colorManagerService: ColorManagerService;
|
|
12
|
+
}) {
|
|
13
|
+
this.colorManagerService = colorManagerService;
|
|
14
|
+
}
|
|
10
15
|
|
|
11
16
|
getAllColors() {
|
|
12
17
|
return this.colorManagerService.getAll();
|
package/src/index.ts
CHANGED
package/src/main.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { AppModule } from './app.module';
|
|
1
|
+
import AppContainer from './app.container';
|
|
3
2
|
import { AppService } from './app.service';
|
|
4
3
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
const appService = app.get(AppService);
|
|
8
|
-
|
|
9
|
-
const close = () => app.close();
|
|
10
|
-
return [appService, close];
|
|
4
|
+
export function main(): AppService {
|
|
5
|
+
return AppContainer.resolve<AppService>('appService');
|
|
11
6
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
1
|
import { SchemeEntity, SchemeOptions } from '../entities/scheme.entity';
|
|
3
2
|
import {
|
|
4
3
|
argbFromHex,
|
|
@@ -15,7 +14,6 @@ export type SchemeServiceOptions = Omit<
|
|
|
15
14
|
palettes: Record<string, (sourceColorHct: Hct) => TonalPalette>;
|
|
16
15
|
};
|
|
17
16
|
|
|
18
|
-
@Injectable()
|
|
19
17
|
export class SchemeService {
|
|
20
18
|
private schemeEntity?: SchemeEntity;
|
|
21
19
|
private options?: SchemeServiceOptions;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DynamicColor } from '@material/material-color-utilities';
|
|
2
|
-
import { Injectable } from '@nestjs/common';
|
|
3
2
|
import { SchemeService, SchemeServiceOptions } from './scheme.service';
|
|
4
3
|
import { VariantService } from './variant.service';
|
|
5
4
|
import { VariantEntity } from '../entities/variant.entity';
|
|
@@ -12,12 +11,19 @@ const colorPaletteKeyColor = DynamicColor.fromPalette({
|
|
|
12
11
|
tone: (s) => s.primaryPalette.keyColor.tone,
|
|
13
12
|
});
|
|
14
13
|
|
|
15
|
-
@Injectable()
|
|
16
14
|
export class ThemeService {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
private readonly schemeService: SchemeService;
|
|
16
|
+
private readonly variantService: VariantService;
|
|
17
|
+
constructor({
|
|
18
|
+
schemeService,
|
|
19
|
+
variantService,
|
|
20
|
+
}: {
|
|
21
|
+
schemeService: SchemeService;
|
|
22
|
+
variantService: VariantService;
|
|
23
|
+
}) {
|
|
24
|
+
this.schemeService = schemeService;
|
|
25
|
+
this.variantService = variantService;
|
|
26
|
+
|
|
21
27
|
// this.addPalette({key: "primary", addDefaultColors: true})
|
|
22
28
|
// this.addPalette({key: "secondary", addDefaultColors: true})
|
|
23
29
|
// this.addPalette({key: "tertiary", addDefaultColors: true})
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { SchemeService } from './scheme.service';
|
|
2
2
|
import { VariantEntity } from '../entities/variant.entity';
|
|
3
|
-
import { Injectable } from '@nestjs/common';
|
|
4
3
|
import { TonalPalette } from '@material/material-color-utilities';
|
|
5
4
|
|
|
6
|
-
@Injectable()
|
|
7
5
|
export class VariantService {
|
|
8
|
-
|
|
6
|
+
private readonly schemeService: SchemeService;
|
|
7
|
+
constructor({ schemeService }: { schemeService: SchemeService }) {
|
|
8
|
+
this.schemeService = schemeService;
|
|
9
|
+
}
|
|
9
10
|
|
|
10
11
|
set(variantEntity: VariantEntity) {
|
|
11
12
|
if (!variantEntity.palettes.error) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { VariantService } from './services/variant.service';
|
|
1
|
+
import { SchemeService, ThemeService, VariantService } from './services';
|
|
2
|
+
import { asClass } from 'awilix';
|
|
3
|
+
import { Module } from '../app.container';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export const ThemeModule: Module = {
|
|
6
|
+
schemeService: asClass(SchemeService).singleton(),
|
|
7
|
+
variantService: asClass(VariantService).singleton(),
|
|
8
|
+
themeService: asClass(ThemeService).singleton(),
|
|
9
|
+
};
|