@udixio/theme 1.0.0-beta.10

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.
Files changed (100) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -0
  3. package/dist/app.container.d.ts +5 -0
  4. package/dist/app.module.d.ts +2 -0
  5. package/dist/app.service.d.ts +13 -0
  6. package/dist/color/color.interface.d.ts +8 -0
  7. package/dist/color/color.module.d.ts +2 -0
  8. package/dist/color/entities/color.entity.d.ts +42 -0
  9. package/dist/color/entities/index.d.ts +1 -0
  10. package/dist/color/index.d.ts +5 -0
  11. package/dist/color/models/default-color.model.d.ts +3 -0
  12. package/dist/color/models/index.d.ts +1 -0
  13. package/dist/color/services/color-manager.service.d.ts +18 -0
  14. package/dist/color/services/color.service.d.ts +21 -0
  15. package/dist/color/services/index.d.ts +2 -0
  16. package/dist/config/config.interface.d.ts +13 -0
  17. package/dist/config/config.module.d.ts +2 -0
  18. package/dist/config/config.service.d.ts +12 -0
  19. package/dist/config/index.d.ts +3 -0
  20. package/dist/index.d.ts +11 -0
  21. package/dist/index.js +8 -0
  22. package/dist/main.d.ts +3 -0
  23. package/dist/material-color-utilities/contrastCurve.d.ts +46 -0
  24. package/dist/material-color-utilities/dynamic_color.d.ts +171 -0
  25. package/dist/material-color-utilities/index.d.ts +3 -0
  26. package/dist/material-color-utilities/toneDeltaPair.d.ts +60 -0
  27. package/dist/plugin/index.d.ts +3 -0
  28. package/dist/plugin/plugin.abstract.d.ts +6 -0
  29. package/dist/plugin/plugin.module.d.ts +2 -0
  30. package/dist/plugin/plugin.service.d.ts +10 -0
  31. package/dist/plugins/tailwind/Tailwind.plugin.d.ts +14 -0
  32. package/dist/plugins/tailwind/index.d.ts +3 -0
  33. package/dist/plugins/tailwind/main.d.ts +10 -0
  34. package/dist/plugins/tailwind/plugins-tailwind/index.d.ts +2 -0
  35. package/dist/plugins/tailwind/plugins-tailwind/state.d.ts +4 -0
  36. package/dist/plugins/tailwind/plugins-tailwind/themer.d.ts +4 -0
  37. package/dist/theme/entities/index.d.ts +2 -0
  38. package/dist/theme/entities/scheme.entity.d.ts +15 -0
  39. package/dist/theme/entities/variant.entity.d.ts +7 -0
  40. package/dist/theme/index.d.ts +4 -0
  41. package/dist/theme/models/index.d.ts +1 -0
  42. package/dist/theme/models/variant.model.d.ts +8 -0
  43. package/dist/theme/services/index.d.ts +3 -0
  44. package/dist/theme/services/scheme.service.d.ts +17 -0
  45. package/dist/theme/services/theme.service.d.ts +22 -0
  46. package/dist/theme/services/variant.service.d.ts +13 -0
  47. package/dist/theme/theme.module.d.ts +2 -0
  48. package/dist/theme.cjs.development.js +2193 -0
  49. package/dist/theme.cjs.development.js.map +1 -0
  50. package/dist/theme.cjs.production.min.js +2 -0
  51. package/dist/theme.cjs.production.min.js.map +1 -0
  52. package/dist/theme.esm.js +2157 -0
  53. package/dist/theme.esm.js.map +1 -0
  54. package/package.json +95 -0
  55. package/src/app.container.ts +46 -0
  56. package/src/app.module.ts +7 -0
  57. package/src/app.service.spec.ts +15 -0
  58. package/src/app.service.ts +23 -0
  59. package/src/color/color.interface.ts +13 -0
  60. package/src/color/color.module.ts +9 -0
  61. package/src/color/entities/color.entity.ts +71 -0
  62. package/src/color/entities/index.ts +1 -0
  63. package/src/color/index.ts +5 -0
  64. package/src/color/models/default-color.model.ts +300 -0
  65. package/src/color/models/index.ts +1 -0
  66. package/src/color/services/color-manager.service.ts +191 -0
  67. package/src/color/services/color.service.spec.ts +28 -0
  68. package/src/color/services/color.service.ts +75 -0
  69. package/src/color/services/index.ts +2 -0
  70. package/src/config/config.interface.ts +14 -0
  71. package/src/config/config.module.ts +7 -0
  72. package/src/config/config.service.ts +74 -0
  73. package/src/config/index.ts +3 -0
  74. package/src/index.ts +11 -0
  75. package/src/main.ts +14 -0
  76. package/src/material-color-utilities/contrastCurve.ts +63 -0
  77. package/src/material-color-utilities/dynamic_color.ts +450 -0
  78. package/src/material-color-utilities/index.ts +3 -0
  79. package/src/material-color-utilities/toneDeltaPair.ts +64 -0
  80. package/src/plugin/index.ts +3 -0
  81. package/src/plugin/plugin.abstract.ts +8 -0
  82. package/src/plugin/plugin.module.ts +7 -0
  83. package/src/plugin/plugin.service.ts +30 -0
  84. package/src/plugins/tailwind/Tailwind.plugin.ts +53 -0
  85. package/src/plugins/tailwind/index.ts +3 -0
  86. package/src/plugins/tailwind/main.ts +18 -0
  87. package/src/plugins/tailwind/plugins-tailwind/index.ts +2 -0
  88. package/src/plugins/tailwind/plugins-tailwind/state.ts +88 -0
  89. package/src/plugins/tailwind/plugins-tailwind/themer.ts +53 -0
  90. package/src/theme/entities/index.ts +2 -0
  91. package/src/theme/entities/scheme.entity.ts +44 -0
  92. package/src/theme/entities/variant.entity.ts +39 -0
  93. package/src/theme/index.ts +4 -0
  94. package/src/theme/models/index.ts +1 -0
  95. package/src/theme/models/variant.model.ts +63 -0
  96. package/src/theme/services/index.ts +3 -0
  97. package/src/theme/services/scheme.service.ts +80 -0
  98. package/src/theme/services/theme.service.ts +74 -0
  99. package/src/theme/services/variant.service.ts +52 -0
  100. package/src/theme/theme.module.ts +9 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 vigreux-joël
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ <p align="center">
2
+ <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
3
+ </p>
4
+
5
+ [circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
6
+ [circleci-url]: https://circleci.com/gh/nestjs/nest
7
+
8
+ <p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
11
+ <a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
12
+ <a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
13
+ <a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
14
+ <a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
15
+ <a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
16
+ <a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
17
+ <a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
18
+ <a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
19
+ <a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
20
+ <a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
21
+ </p>
22
+ <!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
23
+ [![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
24
+
25
+ ## Description
26
+
27
+ [Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ $ npm install
33
+ ```
34
+
35
+ ## Running the app
36
+
37
+ ```bash
38
+ # development
39
+ $ npm run start
40
+
41
+ # watch mode
42
+ $ npm run start:dev
43
+
44
+ # production mode
45
+ $ npm run start:prod
46
+ ```
47
+
48
+ ## Test
49
+
50
+ ```bash
51
+ # unit tests
52
+ $ npm run test
53
+
54
+ # e2e tests
55
+ $ npm run test:e2e
56
+
57
+ # test coverage
58
+ $ npm run test:cov
59
+ ```
60
+
61
+ ## Support
62
+
63
+ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
64
+
65
+ ## Stay in touch
66
+
67
+ - Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
68
+ - Website - [https://nestjs.com](https://nestjs.com/)
69
+ - Twitter - [@nestframework](https://twitter.com/nestframework)
70
+
71
+ ## License
72
+
73
+ Nest is [MIT licensed](LICENSE).
@@ -0,0 +1,5 @@
1
+ import { AwilixContainer, BuildResolver, DisposableResolver } from 'awilix';
2
+ export type Module = Record<string, BuildResolver<any> & DisposableResolver<any>>;
3
+ export declare function importContainer(container: AwilixContainer, services: Module[]): AwilixContainer<any>;
4
+ declare const AppContainer: AwilixContainer<any>;
5
+ export default AppContainer;
@@ -0,0 +1,2 @@
1
+ import { Module } from './app.container';
2
+ export declare const AppModule: Module;
@@ -0,0 +1,13 @@
1
+ import { ColorService } from './color';
2
+ import { ThemeService } from './theme';
3
+ import { PluginService } from './plugin/plugin.service';
4
+ export declare class AppService {
5
+ colorService: ColorService;
6
+ themeService: ThemeService;
7
+ pluginService: PluginService;
8
+ constructor({ colorService, themeService, pluginService, }: {
9
+ colorService: ColorService;
10
+ themeService: ThemeService;
11
+ pluginService: PluginService;
12
+ });
13
+ }
@@ -0,0 +1,8 @@
1
+ import { ColorEntity, ColorOptions } from './entities/color.entity';
2
+ export interface ColorInterface {
3
+ addColor(key: string, color: ColorOptions): ColorEntity;
4
+ removeColor(key: string): boolean;
5
+ getColor(key: string): ColorEntity;
6
+ updateColor(key: string, newColor: ColorOptions): ColorEntity;
7
+ getColors(): ReadonlyMap<string, ColorEntity>;
8
+ }
@@ -0,0 +1,2 @@
1
+ import { Module } from '../app.container';
2
+ export declare const ColorModule: Module;
@@ -0,0 +1,42 @@
1
+ import { TonalPalette } from '@material/material-color-utilities';
2
+ import { SchemeEntity } from '../../theme/entities/scheme.entity';
3
+ import { DynamicColor } from '../../material-color-utilities/dynamic_color';
4
+ import { ContrastCurve } from '../../material-color-utilities';
5
+ import { SchemeService } from '../../theme/services/scheme.service';
6
+ import { ColorManagerService } from '../services/color-manager.service';
7
+ export interface ColorOptions {
8
+ palette: (scheme: SchemeEntity) => TonalPalette;
9
+ tone: (scheme: SchemeEntity) => number;
10
+ isBackground?: boolean;
11
+ background?: (scheme: SchemeEntity) => DynamicColor;
12
+ secondBackground?: (scheme: SchemeEntity) => DynamicColor;
13
+ contrastCurve?: ContrastCurve;
14
+ toneDeltaPair?: (scheme: SchemeEntity) => {
15
+ roleA: DynamicColor;
16
+ readonly roleB: DynamicColor;
17
+ readonly delta: number;
18
+ readonly polarity: 'darker' | 'lighter' | 'nearer' | 'farther';
19
+ readonly stayTogether: boolean;
20
+ };
21
+ }
22
+ export declare class ColorEntity {
23
+ private option;
24
+ private schemeService;
25
+ private colorService;
26
+ private dynamicColor;
27
+ constructor(option: ColorOptions & {
28
+ name: string;
29
+ }, schemeService: SchemeService, colorService: ColorManagerService);
30
+ update(args: Partial<ColorOptions & {
31
+ name: string;
32
+ }>): void;
33
+ getHex(): string;
34
+ getArgb(): number;
35
+ getRgb(): {
36
+ r: number;
37
+ g: number;
38
+ b: number;
39
+ };
40
+ getName(): string;
41
+ getDynamicColor(): DynamicColor;
42
+ }
@@ -0,0 +1 @@
1
+ export * from './color.entity';
@@ -0,0 +1,5 @@
1
+ export * from './color.interface';
2
+ export * from './color.module';
3
+ export * from './entities';
4
+ export * from './models';
5
+ export * from './services';
@@ -0,0 +1,3 @@
1
+ import { AddColorsOptions } from '../services/color.service';
2
+ export type DynamicColorKey = 'background' | 'onBackground' | 'surface' | 'surfaceDim' | 'surfaceBright' | 'surfaceContainerLowest' | 'surfaceContainerLow' | 'surfaceContainer' | 'surfaceContainerHigh' | 'surfaceContainerHighest' | 'onSurface' | 'surfaceVariant' | 'onSurfaceVariant' | 'inverseSurface' | 'inverseOnSurface' | 'outline' | 'outlineVariant' | 'shadow' | 'scrim' | 'surfaceTint' | 'primary' | 'onPrimary' | 'primaryContainer' | 'onPrimaryContainer' | 'inversePrimary' | 'secondary' | 'onSecondary' | 'secondaryContainer' | 'onSecondaryContainer' | 'tertiary' | 'onTertiary' | 'tertiaryContainer' | 'onTertiaryContainer' | 'error' | 'onError' | 'errorContainer' | 'onErrorContainer' | 'primaryFixed' | 'primaryFixedDim' | 'onPrimaryFixed' | 'onPrimaryFixedVariant' | 'secondaryFixed' | 'secondaryFixedDim' | 'onSecondaryFixed' | 'onSecondaryFixedVariant' | 'tertiaryFixed' | 'tertiaryFixedDim' | 'onTertiaryFixed' | 'onTertiaryFixedVariant';
3
+ export declare const defaultColors: AddColorsOptions;
@@ -0,0 +1 @@
1
+ export * from './default-color.model';
@@ -0,0 +1,18 @@
1
+ import { DynamicColor } from '../../material-color-utilities/dynamic_color';
2
+ import { SchemeEntity } from '../../theme/entities/scheme.entity';
3
+ import { ColorEntity, ColorOptions } from '../entities/color.entity';
4
+ import { SchemeService } from '../../theme/services/scheme.service';
5
+ import { ColorService } from './color.service';
6
+ export declare const highestSurface: (s: SchemeEntity, colorService: ColorManagerService | ColorService) => DynamicColor;
7
+ export declare class ColorManagerService {
8
+ private colorMap;
9
+ private readonly schemeService;
10
+ constructor({ schemeService }: {
11
+ schemeService: SchemeService;
12
+ });
13
+ createOrUpdate(key: string, args: Partial<ColorOptions>): ColorEntity;
14
+ remove(key: string): boolean;
15
+ get(key: string): ColorEntity;
16
+ getAll(): ReadonlyMap<string, ColorEntity>;
17
+ addFromPalette(key: string): void;
18
+ }
@@ -0,0 +1,21 @@
1
+ import { ColorManagerService } from './color-manager.service';
2
+ import { ColorInterface } from '../color.interface';
3
+ import { ColorEntity, ColorOptions } from '../entities';
4
+ type AddColors = {
5
+ colors?: Record<string, Partial<ColorOptions>>;
6
+ fromPalettes?: string[] | string;
7
+ };
8
+ export type AddColorsOptions = AddColors | ((colorService: ColorService) => AddColors);
9
+ export declare class ColorService implements ColorInterface {
10
+ private readonly colorManagerService;
11
+ constructor({ colorManagerService, }: {
12
+ colorManagerService: ColorManagerService;
13
+ });
14
+ getColors(): ReadonlyMap<string, ColorEntity>;
15
+ addColor(key: string, color: Partial<ColorOptions>): ColorEntity;
16
+ addColors(args: AddColorsOptions | AddColorsOptions[]): void;
17
+ getColor(key: string): ColorEntity;
18
+ removeColor(key: string): boolean;
19
+ updateColor(key: string, newColor: Partial<ColorOptions>): ColorEntity;
20
+ }
21
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './color-manager.service';
2
+ export * from './color.service';
@@ -0,0 +1,13 @@
1
+ import { VariantEntity } from '../theme';
2
+ import { AddColorsOptions } from '../color';
3
+ import { PluginConstructor } from '../plugin/plugin.service';
4
+ export interface ConfigInterface {
5
+ sourceColor: string;
6
+ contrastLevel?: 0;
7
+ isDark?: boolean;
8
+ variant?: VariantEntity;
9
+ colors?: AddColorsOptions | AddColorsOptions[];
10
+ useDefaultColors?: boolean;
11
+ palettes?: Record<string, string>;
12
+ plugins?: (PluginConstructor | [PluginConstructor, object])[];
13
+ }
@@ -0,0 +1,2 @@
1
+ import { Module } from '../app.container';
2
+ export declare const ConfigModule: Module;
@@ -0,0 +1,12 @@
1
+ import { ConfigInterface } from './config.interface';
2
+ import { AppService } from '../app.service';
3
+ export declare function defineConfig(configObject: ConfigInterface): ConfigInterface;
4
+ export declare class ConfigService {
5
+ configPath: string;
6
+ private appService;
7
+ constructor({ appService }: {
8
+ appService: AppService;
9
+ });
10
+ loadConfig(): Promise<void>;
11
+ private getConfig;
12
+ }
@@ -0,0 +1,3 @@
1
+ export * from './config.interface';
2
+ export * from './config.module';
3
+ export * from './config.service';
@@ -0,0 +1,11 @@
1
+ export { default as AppContainer } from './app.container';
2
+ export * from './app.container';
3
+ export * from './app.module';
4
+ export * from './app.service';
5
+ export * from './color';
6
+ export * from './config';
7
+ export * from './main';
8
+ export * from './material-color-utilities';
9
+ export * from './plugin';
10
+ export * from './plugins/tailwind';
11
+ export * from './theme';
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./theme.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./theme.cjs.development.js')
8
+ }
package/dist/main.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { AppService } from './app.service';
2
+ export declare function bootstrap(): AppService;
3
+ export declare function bootstrapFromConfig(path?: string): Promise<AppService>;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * A class containing a value that changes with the contrast level.
19
+ *
20
+ * Usually represents the contrast requirements for a dynamic color on its
21
+ * background. The four values correspond to values for contrast levels -1.0,
22
+ * 0.0, 0.5, and 1.0, respectively.
23
+ */
24
+ export declare class ContrastCurve {
25
+ readonly low: number;
26
+ readonly normal: number;
27
+ readonly medium: number;
28
+ readonly high: number;
29
+ /**
30
+ * Creates a `ContrastCurve` object.
31
+ *
32
+ * @param low Value for contrast level -1.0
33
+ * @param normal Value for contrast level 0.0
34
+ * @param medium Value for contrast level 0.5
35
+ * @param high Value for contrast level 1.0
36
+ */
37
+ constructor(low: number, normal: number, medium: number, high: number);
38
+ /**
39
+ * Returns the value at a given contrast level.
40
+ *
41
+ * @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0
42
+ * is the lowest; 1.0 is the highest.
43
+ * @return The value. For contrast ratios, a number between 1.0 and 21.0.
44
+ */
45
+ get(contrastLevel: number): number;
46
+ }
@@ -0,0 +1,171 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Hct, TonalPalette } from '@material/material-color-utilities';
18
+ import { ContrastCurve } from './contrastCurve';
19
+ import { ToneDeltaPair } from './toneDeltaPair';
20
+ import { SchemeEntity } from '../theme/entities/scheme.entity';
21
+ /**
22
+ * @param name The name of the dynamic color. Defaults to empty.
23
+ * @param palette Function that provides a TonalPalette given
24
+ * SchemeEntity. A TonalPalette is defined by a hue and chroma, so this
25
+ * replaces the need to specify hue/chroma. By providing a tonal palette, when
26
+ * contrast adjustments are made, intended chroma can be preserved.
27
+ * @param tone Function that provides a tone given SchemeEntity.
28
+ * @param isBackground Whether this dynamic color is a background, with
29
+ * some other color as the foreground. Defaults to false.
30
+ * @param background The background of the dynamic color (as a function of a
31
+ * `SchemeEntity`), if it exists.
32
+ * @param secondBackground A second background of the dynamic color (as a
33
+ * function of a `SchemeEntity`), if it
34
+ * exists.
35
+ * @param contrastCurve A `ContrastCurve` object specifying how its contrast
36
+ * against its background should behave in various contrast levels options.
37
+ * @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta
38
+ * constraint between two colors. One of them must be the color being
39
+ * constructed.
40
+ */
41
+ interface FromPaletteOptions {
42
+ name?: string;
43
+ palette: (scheme: SchemeEntity) => TonalPalette;
44
+ tone: (scheme: SchemeEntity) => number;
45
+ isBackground?: boolean;
46
+ background?: (scheme: SchemeEntity) => DynamicColor;
47
+ secondBackground?: (scheme: SchemeEntity) => DynamicColor;
48
+ contrastCurve?: ContrastCurve;
49
+ toneDeltaPair?: (scheme: SchemeEntity) => ToneDeltaPair;
50
+ }
51
+ /**
52
+ * A color that adjusts itself based on UI state provided by SchemeEntity.
53
+ *
54
+ * Colors without backgrounds do not change tone when contrast changes. Colors
55
+ * with backgrounds become closer to their background as contrast lowers, and
56
+ * further when contrast increases.
57
+ *
58
+ * Prefer static constructors. They require either a hexcode, a palette and
59
+ * tone, or a hue and chroma. Optionally, they can provide a background
60
+ * DynamicColor.
61
+ */
62
+ export declare class DynamicColor {
63
+ readonly name: string;
64
+ readonly palette: (scheme: SchemeEntity) => TonalPalette;
65
+ readonly tone: (scheme: SchemeEntity) => number;
66
+ readonly isBackground: boolean;
67
+ readonly background?: ((scheme: SchemeEntity) => DynamicColor) | undefined;
68
+ readonly secondBackground?: ((scheme: SchemeEntity) => DynamicColor) | undefined;
69
+ readonly contrastCurve?: ContrastCurve | undefined;
70
+ readonly toneDeltaPair?: ((scheme: SchemeEntity) => ToneDeltaPair) | undefined;
71
+ private readonly hctCache;
72
+ /**
73
+ * The base constructor for DynamicColor.
74
+ *
75
+ * _Strongly_ prefer using one of the convenience constructors. This class is
76
+ * arguably too flexible to ensure it can support any scenario. Functional
77
+ * arguments allow overriding without risks that come with subclasses.
78
+ *
79
+ * For example, the default behavior of adjust tone at max contrast
80
+ * to be at a 7.0 ratio with its background is principled and
81
+ * matches accessibility guidance. That does not mean it's the desired
82
+ * approach for _every_ design system, and every color pairing,
83
+ * always, in every case.
84
+ *
85
+ * @param name The name of the dynamic color. Defaults to empty.
86
+ * @param palette Function that provides a TonalPalette given
87
+ * SchemeEntity. A TonalPalette is defined by a hue and chroma, so this
88
+ * replaces the need to specify hue/chroma. By providing a tonal palette, when
89
+ * contrast adjustments are made, intended chroma can be preserved.
90
+ * @param tone Function that provides a tone, given a SchemeEntity.
91
+ * @param isBackground Whether this dynamic color is a background, with
92
+ * some other color as the foreground. Defaults to false.
93
+ * @param background The background of the dynamic color (as a function of a
94
+ * `SchemeEntity`), if it exists.
95
+ * @param secondBackground A second background of the dynamic color (as a
96
+ * function of a `SchemeEntity`), if it
97
+ * exists.
98
+ * @param contrastCurve A `ContrastCurve` object specifying how its contrast
99
+ * against its background should behave in various contrast levels options.
100
+ * @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta
101
+ * constraint between two colors. One of them must be the color being
102
+ * constructed.
103
+ */
104
+ constructor(name: string, palette: (scheme: SchemeEntity) => TonalPalette, tone: (scheme: SchemeEntity) => number, isBackground: boolean, background?: ((scheme: SchemeEntity) => DynamicColor) | undefined, secondBackground?: ((scheme: SchemeEntity) => DynamicColor) | undefined, contrastCurve?: ContrastCurve | undefined, toneDeltaPair?: ((scheme: SchemeEntity) => ToneDeltaPair) | undefined);
105
+ /**
106
+ * Create a DynamicColor defined by a TonalPalette and HCT tone.
107
+ *
108
+ * @param args Functions with SchemeEntity as input. Must provide a palette
109
+ * and tone. May provide a background DynamicColor and ToneDeltaConstraint.
110
+ */
111
+ static fromPalette(args: FromPaletteOptions): DynamicColor;
112
+ /**
113
+ * Given a background tone, find a foreground tone, while ensuring they reach
114
+ * a contrast ratio that is as close to [ratio] as possible.
115
+ *
116
+ * @param bgTone Tone in HCT. Range is 0 to 100, undefined behavior when it
117
+ * falls outside that range.
118
+ * @param ratio The contrast ratio desired between bgTone and the return
119
+ * value.
120
+ */
121
+ static foregroundTone(bgTone: number, ratio: number): number;
122
+ /**
123
+ * Returns whether [tone] prefers a light foreground.
124
+ *
125
+ * People prefer white foregrounds on ~T60-70. Observed over time, and also
126
+ * by Andrew Somers during research for APCA.
127
+ *
128
+ * T60 used as to create the smallest discontinuity possible when skipping
129
+ * down to T49 in order to ensure light foregrounds.
130
+ * Since `tertiaryContainer` in dark monochrome scheme requires a tone of
131
+ * 60, it should not be adjusted. Therefore, 60 is excluded here.
132
+ */
133
+ static tonePrefersLightForeground(tone: number): boolean;
134
+ /**
135
+ * Returns whether [tone] can reach a contrast ratio of 4.5 with a lighter
136
+ * color.
137
+ */
138
+ static toneAllowsLightForeground(tone: number): boolean;
139
+ /**
140
+ * Adjust a tone such that white has 4.5 contrast, if the tone is
141
+ * reasonably close to supporting it.
142
+ */
143
+ static enableLightForeground(tone: number): number;
144
+ /**
145
+ * Return a ARGB integer (i.e. a hex code).
146
+ *
147
+ * @param scheme Defines the conditions of the user interface, for example,
148
+ * whether or not it is dark mode or light mode, and what the desired
149
+ * contrast level is.
150
+ */
151
+ getArgb(scheme: SchemeEntity): number;
152
+ /**
153
+ * Return a color, expressed in the HCT color space, that this
154
+ * DynamicColor is under the conditions in scheme.
155
+ *
156
+ * @param scheme Defines the conditions of the user interface, for example,
157
+ * whether or not it is dark mode or light mode, and what the desired
158
+ * contrast level is.
159
+ */
160
+ getHct(scheme: SchemeEntity): Hct;
161
+ /**
162
+ * Return a tone, T in the HCT color space, that this DynamicColor is under
163
+ * the conditions in scheme.
164
+ *
165
+ * @param scheme Defines the conditions of the user interface, for example,
166
+ * whether or not it is dark mode or light mode, and what the desired
167
+ * contrast level is.
168
+ */
169
+ getTone(scheme: SchemeEntity): number;
170
+ }
171
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './contrastCurve';
2
+ export * from './dynamic_color';
3
+ export * from './toneDeltaPair';
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { DynamicColor } from './dynamic_color';
18
+ /**
19
+ * Describes the different in tone between colors.
20
+ */
21
+ export type TonePolarity = 'darker' | 'lighter' | 'nearer' | 'farther';
22
+ /**
23
+ * Documents a constraint between two DynamicColors, in which their tones must
24
+ * have a certain distance from each other.
25
+ *
26
+ * Prefer a DynamicColor with a background, this is for special cases when
27
+ * designers want tonal distance, literally contrast, between two colors that
28
+ * don't have a background / foreground relationship or a contrast guarantee.
29
+ */
30
+ export declare class ToneDeltaPair {
31
+ readonly roleA: DynamicColor;
32
+ readonly roleB: DynamicColor;
33
+ readonly delta: number;
34
+ readonly polarity: TonePolarity;
35
+ readonly stayTogether: boolean;
36
+ /**
37
+ * Documents a constraint in tone distance between two DynamicColors.
38
+ *
39
+ * The polarity is an adjective that describes "A", compared to "B".
40
+ *
41
+ * For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that
42
+ * A's tone should be at least 15 darker than B's.
43
+ *
44
+ * 'nearer' and 'farther' describes closeness to the surface roles. For
45
+ * instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A
46
+ * should be 10 lighter than B in light mode, and 10 darker than B in dark
47
+ * mode.
48
+ *
49
+ * @param roleA The first role in a pair.
50
+ * @param roleB The second role in a pair.
51
+ * @param delta Required difference between tones. Absolute value, negative
52
+ * values have undefined behavior.
53
+ * @param polarity The relative relation between tones of roleA and roleB,
54
+ * as described above.
55
+ * @param stayTogether Whether these two roles should stay on the same side of
56
+ * the "awkward zone" (T50-59). This is necessary for certain cases where
57
+ * one role has two backgrounds.
58
+ */
59
+ constructor(roleA: DynamicColor, roleB: DynamicColor, delta: number, polarity: TonePolarity, stayTogether: boolean);
60
+ }
@@ -0,0 +1,3 @@
1
+ export * from './plugin.abstract';
2
+ export * from './plugin.module';
3
+ export * from './plugin.service';
@@ -0,0 +1,6 @@
1
+ import { AppService } from '../app.service';
2
+ export declare abstract class PluginAbstract {
3
+ static dependencies: (new () => PluginAbstract)[];
4
+ protected abstract appService: AppService;
5
+ protected abstract options: object;
6
+ }
@@ -0,0 +1,2 @@
1
+ import { Module } from '../app.container';
2
+ export declare const PluginModule: Module;
@@ -0,0 +1,10 @@
1
+ import { PluginAbstract } from './plugin.abstract';
2
+ import { AppService } from '../app.service';
3
+ export type PluginConstructor = new (appService: AppService, options: any) => PluginAbstract;
4
+ export declare class PluginService {
5
+ private pluginInstances;
6
+ private pluginConstructors;
7
+ addPlugin(plugin: PluginConstructor, config: object): void;
8
+ loadPlugins(appService: AppService): void;
9
+ getPlugin<T extends PluginAbstract>(plugin: new (appService: AppService, options: any) => T): T;
10
+ }
@@ -0,0 +1,14 @@
1
+ import { PluginAbstract } from '../../plugin/plugin.abstract';
2
+ import { AppService } from '../../app.service';
3
+ import { Theme } from './main';
4
+ interface TailwindPluginOptions {
5
+ darkMode: 'class' | 'media';
6
+ }
7
+ export declare class TailwindPlugin extends PluginAbstract {
8
+ protected appService: AppService;
9
+ protected options: TailwindPluginOptions;
10
+ constructor(appService: AppService, options: TailwindPluginOptions);
11
+ static config(options: TailwindPluginOptions): TailwindPluginOptions;
12
+ getTheme(): Theme;
13
+ }
14
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './main';
2
+ export * from './plugins-tailwind';
3
+ export * from './Tailwind.plugin';