material 3.7.3 → 3.8.0
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/NOTICE +223 -0
- package/README.md +5 -3
- package/dist/components/extended-fab/types.d.ts +3 -0
- package/dist/components/fab/types.d.ts +3 -0
- package/dist/elements/extended-fab.d.ts +1 -0
- package/dist/elements/fab.d.ts +1 -0
- package/dist/elements/preupgrade/badge.css +1 -1
- package/dist/elements/preupgrade/bottom-app-bar.css +1 -1
- package/dist/elements/preupgrade/bottom-sheet.css +1 -1
- package/dist/elements/preupgrade/button-group.css +1 -1
- package/dist/elements/preupgrade/button.css +1 -1
- package/dist/elements/preupgrade/card.css +1 -1
- package/dist/elements/preupgrade/carousel.css +1 -1
- package/dist/elements/preupgrade/checkbox.css +1 -1
- package/dist/elements/preupgrade/chips.css +1 -1
- package/dist/elements/preupgrade/datepicker.css +1 -1
- package/dist/elements/preupgrade/dialog.css +1 -1
- package/dist/elements/preupgrade/divider.css +1 -1
- package/dist/elements/preupgrade/drawer.css +1 -1
- package/dist/elements/preupgrade/extended-fab.css +1 -1
- package/dist/elements/preupgrade/fab-menu.css +1 -1
- package/dist/elements/preupgrade/fab.css +1 -1
- package/dist/elements/preupgrade/icon-button.css +1 -1
- package/dist/elements/preupgrade/list.css +1 -1
- package/dist/elements/preupgrade/loading-indicator.css +1 -1
- package/dist/elements/preupgrade/menu.css +1 -1
- package/dist/elements/preupgrade/navigation-bar.css +1 -1
- package/dist/elements/preupgrade/navigation-rail.css +1 -1
- package/dist/elements/preupgrade/progress.css +1 -1
- package/dist/elements/preupgrade/radios.css +1 -1
- package/dist/elements/preupgrade/search.css +1 -1
- package/dist/elements/preupgrade/select.css +1 -1
- package/dist/elements/preupgrade/side-sheet.css +1 -1
- package/dist/elements/preupgrade/slider.css +1 -1
- package/dist/elements/preupgrade/snackbar.css +1 -1
- package/dist/elements/preupgrade/split-button.css +1 -1
- package/dist/elements/preupgrade/switch.css +1 -1
- package/dist/elements/preupgrade/tabs.css +1 -1
- package/dist/elements/preupgrade/text-field.css +1 -1
- package/dist/elements/preupgrade/timepicker.css +1 -1
- package/dist/elements/preupgrade/toolbar.css +1 -1
- package/dist/elements/preupgrade/tooltip.css +1 -1
- package/dist/elements/preupgrade/top-app-bar.css +1 -1
- package/dist/elements/preupgrade.css +1 -1
- package/dist/styles/badge.css +1 -1
- package/dist/styles/base-lite.css +2 -2
- package/dist/styles/base.css +2 -2
- package/dist/styles/bottom-app-bar.css +1 -1
- package/dist/styles/bottom-sheet.css +1 -1
- package/dist/styles/button-group.css +1 -1
- package/dist/styles/button.css +1 -1
- package/dist/styles/card.css +1 -1
- package/dist/styles/carousel.css +1 -1
- package/dist/styles/checkbox.css +1 -1
- package/dist/styles/chips.css +1 -1
- package/dist/styles/contrast.css +2 -2
- package/dist/styles/datepicker.css +1 -1
- package/dist/styles/dialog.css +1 -1
- package/dist/styles/divider.css +1 -1
- package/dist/styles/drawer.css +1 -1
- package/dist/styles/extended-fab.css +1 -1
- package/dist/styles/fab-menu.css +1 -1
- package/dist/styles/fab.css +1 -1
- package/dist/styles/icon-button.css +1 -1
- package/dist/styles/list.css +1 -1
- package/dist/styles/loading-indicator.css +1 -1
- package/dist/styles/menu.css +1 -1
- package/dist/styles/navigation-bar.css +1 -1
- package/dist/styles/navigation-rail.css +1 -1
- package/dist/styles/progress.css +1 -1
- package/dist/styles/radios.css +1 -1
- package/dist/styles/search.css +1 -1
- package/dist/styles/select.css +1 -1
- package/dist/styles/side-sheet.css +1 -1
- package/dist/styles/slider.css +1 -1
- package/dist/styles/snackbar.css +1 -1
- package/dist/styles/split-button.css +1 -1
- package/dist/styles/switch.css +1 -1
- package/dist/styles/tabs.css +1 -1
- package/dist/styles/text-field.css +1 -1
- package/dist/styles/timepicker.css +1 -1
- package/dist/styles/toolbar.css +1 -1
- package/dist/styles/tooltip.css +1 -1
- package/dist/styles/top-app-bar.css +1 -1
- package/dist/styles/typography.css +1 -1
- package/dist/styles/utilities.css +1 -1
- package/dist/styles.css +2 -2
- package/dist/theme/image.d.ts +2 -0
- package/dist/theme/image.js +5 -0
- package/dist/theme/index.d.ts +23 -0
- package/dist/theme/index.js +32 -0
- package/dist/theme/roles.js +68 -0
- package/dist/theme/variants.d.ts +9 -0
- package/dist/theme/variants.js +17 -0
- package/dist/theme/vendor/contrast/contrast.js +72 -0
- package/dist/theme/vendor/dislike/dislike_analyzer.js +31 -0
- package/dist/theme/vendor/dynamiccolor/color_spec_2021.d.ts +63 -0
- package/dist/theme/vendor/dynamiccolor/color_spec_2021.js +663 -0
- package/dist/theme/vendor/dynamiccolor/contrast_curve.js +42 -0
- package/dist/theme/vendor/dynamiccolor/dynamic_color.d.ts +24 -0
- package/dist/theme/vendor/dynamiccolor/dynamic_color.js +264 -0
- package/dist/theme/vendor/dynamiccolor/dynamic_scheme.d.ts +87 -0
- package/dist/theme/vendor/dynamiccolor/dynamic_scheme.js +418 -0
- package/dist/theme/vendor/dynamiccolor/material_dynamic_colors.d.ts +124 -0
- package/dist/theme/vendor/dynamiccolor/material_dynamic_colors.js +311 -0
- package/dist/theme/vendor/dynamiccolor/tone_delta_pair.js +27 -0
- package/dist/theme/vendor/dynamiccolor/variant.js +28 -0
- package/dist/theme/vendor/hct/cam16.js +249 -0
- package/dist/theme/vendor/hct/hct.d.ts +23 -0
- package/dist/theme/vendor/hct/hct.js +86 -0
- package/dist/theme/vendor/hct/hct_solver.js +390 -0
- package/dist/theme/vendor/hct/viewing_conditions.js +73 -0
- package/dist/theme/vendor/palettes/tonal_palette.js +114 -0
- package/dist/theme/vendor/quantize/lab_point_provider.js +31 -0
- package/dist/theme/vendor/quantize/quantizer_celebi.js +25 -0
- package/dist/theme/vendor/quantize/quantizer_map.js +31 -0
- package/dist/theme/vendor/quantize/quantizer_wsmeans.js +178 -0
- package/dist/theme/vendor/quantize/quantizer_wu.js +342 -0
- package/dist/theme/vendor/scheme/scheme_content.js +30 -0
- package/dist/theme/vendor/scheme/scheme_expressive.js +30 -0
- package/dist/theme/vendor/scheme/scheme_fidelity.js +30 -0
- package/dist/theme/vendor/scheme/scheme_monochrome.js +30 -0
- package/dist/theme/vendor/scheme/scheme_neutral.js +30 -0
- package/dist/theme/vendor/scheme/scheme_tonal_spot.js +30 -0
- package/dist/theme/vendor/scheme/scheme_vibrant.js +30 -0
- package/dist/theme/vendor/score/score.js +100 -0
- package/dist/theme/vendor/temperature/temperature_cache.js +198 -0
- package/dist/theme/vendor/utils/color_utils.js +173 -0
- package/dist/theme/vendor/utils/image_utils.js +72 -0
- package/dist/theme/vendor/utils/math_utils.js +75 -0
- package/dist/theme/vendor/utils/string_utils.js +61 -0
- package/dist/themes/autumn-contrast.css +2 -2
- package/dist/themes/autumn.css +2 -2
- package/dist/themes/baseline-contrast.css +2 -2
- package/dist/themes/baseline.css +2 -2
- package/dist/themes/brownbeige-contrast.css +2 -2
- package/dist/themes/brownbeige.css +2 -2
- package/dist/themes/content-contrast.css +2 -2
- package/dist/themes/content.css +2 -2
- package/dist/themes/desert-contrast.css +2 -2
- package/dist/themes/desert.css +2 -2
- package/dist/themes/expressive-contrast.css +2 -2
- package/dist/themes/expressive.css +2 -2
- package/dist/themes/fidelity-contrast.css +2 -2
- package/dist/themes/fidelity.css +2 -2
- package/dist/themes/forest-contrast.css +2 -2
- package/dist/themes/forest.css +2 -2
- package/dist/themes/fruit-salad-contrast.css +2 -2
- package/dist/themes/fruit-salad.css +2 -2
- package/dist/themes/highcontrast-contrast.css +2 -2
- package/dist/themes/highcontrast.css +2 -2
- package/dist/themes/monochrome-contrast.css +2 -2
- package/dist/themes/monochrome.css +2 -2
- package/dist/themes/neutral-contrast.css +2 -2
- package/dist/themes/neutral.css +2 -2
- package/dist/themes/ocean-contrast.css +2 -2
- package/dist/themes/ocean.css +2 -2
- package/dist/themes/rainbow-contrast.css +2 -2
- package/dist/themes/rainbow.css +2 -2
- package/dist/themes/sageivory-contrast.css +2 -2
- package/dist/themes/sageivory.css +2 -2
- package/dist/themes/spring-contrast.css +2 -2
- package/dist/themes/spring.css +2 -2
- package/dist/themes/summer-contrast.css +2 -2
- package/dist/themes/summer.css +2 -2
- package/dist/themes/sunset-contrast.css +2 -2
- package/dist/themes/sunset.css +2 -2
- package/dist/themes/tealcaramel-contrast.css +2 -2
- package/dist/themes/tealcaramel.css +2 -2
- package/dist/themes/vibrant-contrast.css +2 -2
- package/dist/themes/vibrant.css +2 -2
- package/package.json +14 -1
- package/src/styles/themes/_autumn.scss +20 -2
- package/src/styles/themes/_base-theme.scss +34 -24
- package/src/styles/themes/_baseline.scss +18 -0
- package/src/styles/themes/_brownbeige.scss +30 -2
- package/src/styles/themes/_content.scss +30 -2
- package/src/styles/themes/_desert.scss +30 -2
- package/src/styles/themes/_expressive.scss +30 -2
- package/src/styles/themes/_fidelity.scss +30 -2
- package/src/styles/themes/_forest.scss +20 -2
- package/src/styles/themes/_fruit-salad.scss +30 -2
- package/src/styles/themes/_highcontrast.scss +21 -2
- package/src/styles/themes/_monochrome.scss +30 -2
- package/src/styles/themes/_neutral.scss +30 -2
- package/src/styles/themes/_ocean.scss +20 -2
- package/src/styles/themes/_rainbow.scss +30 -2
- package/src/styles/themes/_sageivory.scss +30 -2
- package/src/styles/themes/_spring.scss +20 -2
- package/src/styles/themes/_summer.scss +30 -2
- package/src/styles/themes/_sunset.scss +20 -2
- package/src/styles/themes/_tealcaramel.scss +30 -2
- package/src/styles/themes/_vibrant.scss +30 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DynamicScheme } from "./vendor/dynamiccolor/dynamic_scheme.js";
|
|
2
|
+
import { Hct } from "./vendor/hct/hct.js";
|
|
3
|
+
export { Hct };
|
|
4
|
+
export type { DynamicScheme };
|
|
5
|
+
export type SchemeFactory = (source: Hct, dark: boolean, contrastLevel: number) => DynamicScheme;
|
|
6
|
+
export declare const tonalSpot: SchemeFactory;
|
|
7
|
+
export declare const vibrant: SchemeFactory;
|
|
8
|
+
export declare const expressive: SchemeFactory;
|
|
9
|
+
export declare const fidelity: SchemeFactory;
|
|
10
|
+
export declare const content: SchemeFactory;
|
|
11
|
+
export declare const neutral: SchemeFactory;
|
|
12
|
+
export declare const monochrome: SchemeFactory;
|
|
13
|
+
export type SchemeMode = "light" | "dark";
|
|
14
|
+
export interface SchemeOptions {
|
|
15
|
+
variant?: SchemeFactory;
|
|
16
|
+
mode?: SchemeMode;
|
|
17
|
+
contrast?: number;
|
|
18
|
+
}
|
|
19
|
+
export declare function createScheme(seed: string | number | Hct, options?: SchemeOptions): DynamicScheme;
|
|
20
|
+
export interface ApplyOptions {
|
|
21
|
+
prefix?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function applyScheme(scheme: DynamicScheme, target?: Element, options?: ApplyOptions): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MaterialDynamicColors } from "./vendor/dynamiccolor/material_dynamic_colors.js";
|
|
2
|
+
import { Hct } from "./vendor/hct/hct.js";
|
|
3
|
+
import { SchemeContent } from "./vendor/scheme/scheme_content.js";
|
|
4
|
+
import { SchemeExpressive } from "./vendor/scheme/scheme_expressive.js";
|
|
5
|
+
import { SchemeFidelity } from "./vendor/scheme/scheme_fidelity.js";
|
|
6
|
+
import { SchemeMonochrome } from "./vendor/scheme/scheme_monochrome.js";
|
|
7
|
+
import { SchemeNeutral } from "./vendor/scheme/scheme_neutral.js";
|
|
8
|
+
import { SchemeTonalSpot } from "./vendor/scheme/scheme_tonal_spot.js";
|
|
9
|
+
import { SchemeVibrant } from "./vendor/scheme/scheme_vibrant.js";
|
|
10
|
+
import { argbFromHex, hexFromArgb } from "./vendor/utils/string_utils.js";
|
|
11
|
+
import { camel, SCHEME_ROLES } from "./roles.js";
|
|
12
|
+
export { Hct };
|
|
13
|
+
export const tonalSpot = (source, dark, contrast) => new SchemeTonalSpot(source, dark, contrast);
|
|
14
|
+
export const vibrant = (source, dark, contrast) => new SchemeVibrant(source, dark, contrast);
|
|
15
|
+
export const expressive = (source, dark, contrast) => new SchemeExpressive(source, dark, contrast);
|
|
16
|
+
export const fidelity = (source, dark, contrast) => new SchemeFidelity(source, dark, contrast);
|
|
17
|
+
export const content = (source, dark, contrast) => new SchemeContent(source, dark, contrast);
|
|
18
|
+
export const neutral = (source, dark, contrast) => new SchemeNeutral(source, dark, contrast);
|
|
19
|
+
export const monochrome = (source, dark, contrast) => new SchemeMonochrome(source, dark, contrast);
|
|
20
|
+
export function createScheme(seed, options = {}) {
|
|
21
|
+
const source = typeof seed === "string" ? Hct.fromInt(argbFromHex(seed)) : typeof seed === "number" ? Hct.fromInt(seed) : seed;
|
|
22
|
+
const variant = options.variant ?? tonalSpot;
|
|
23
|
+
return variant(source, options.mode === "dark", options.contrast ?? 0);
|
|
24
|
+
}
|
|
25
|
+
export function applyScheme(scheme, target = document.documentElement, options = {}) {
|
|
26
|
+
const { prefix = "mtrl" } = options;
|
|
27
|
+
const colors = new MaterialDynamicColors();
|
|
28
|
+
const { style } = target;
|
|
29
|
+
for (const role of SCHEME_ROLES) {
|
|
30
|
+
style.setProperty(`--${prefix}-sys-color-${role}`, hexFromArgb(colors[camel(role)]().getArgb(scheme)));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { MaterialDynamicColors } from "./vendor/dynamiccolor/material_dynamic_colors.js";
|
|
2
|
+
import { Hct } from "./vendor/hct/hct.js";
|
|
3
|
+
import { TonalPalette } from "./vendor/palettes/tonal_palette.js";
|
|
4
|
+
export const STATUS_ROLES = [
|
|
5
|
+
"success",
|
|
6
|
+
"on-success",
|
|
7
|
+
"warning",
|
|
8
|
+
"on-warning",
|
|
9
|
+
"info",
|
|
10
|
+
"on-info",
|
|
11
|
+
];
|
|
12
|
+
export const SCHEME_ROLES = [
|
|
13
|
+
"primary",
|
|
14
|
+
"on-primary",
|
|
15
|
+
"primary-container",
|
|
16
|
+
"on-primary-container",
|
|
17
|
+
"secondary",
|
|
18
|
+
"on-secondary",
|
|
19
|
+
"secondary-container",
|
|
20
|
+
"on-secondary-container",
|
|
21
|
+
"tertiary",
|
|
22
|
+
"on-tertiary",
|
|
23
|
+
"tertiary-container",
|
|
24
|
+
"on-tertiary-container",
|
|
25
|
+
"error",
|
|
26
|
+
"on-error",
|
|
27
|
+
"error-container",
|
|
28
|
+
"on-error-container",
|
|
29
|
+
"surface",
|
|
30
|
+
"surface-dim",
|
|
31
|
+
"surface-bright",
|
|
32
|
+
"surface-container-lowest",
|
|
33
|
+
"surface-container-low",
|
|
34
|
+
"surface-container",
|
|
35
|
+
"surface-container-high",
|
|
36
|
+
"surface-container-highest",
|
|
37
|
+
"surface-variant",
|
|
38
|
+
"on-surface",
|
|
39
|
+
"on-surface-variant",
|
|
40
|
+
"outline",
|
|
41
|
+
"outline-variant",
|
|
42
|
+
"shadow",
|
|
43
|
+
"scrim",
|
|
44
|
+
"inverse-surface",
|
|
45
|
+
"inverse-on-surface",
|
|
46
|
+
"inverse-primary",
|
|
47
|
+
"success",
|
|
48
|
+
"on-success",
|
|
49
|
+
"warning",
|
|
50
|
+
"on-warning",
|
|
51
|
+
"info",
|
|
52
|
+
"on-info",
|
|
53
|
+
];
|
|
54
|
+
export const camel = (role) => role.replace(/-([a-z])/g, (_m, c) => c.toUpperCase());
|
|
55
|
+
const proto = MaterialDynamicColors.prototype;
|
|
56
|
+
SCHEME_ROLES.slice(34).forEach((k, i) => {
|
|
57
|
+
const f = Hct.fromInt([0x7b5a, 0xdd6d06, 0x61a4][i >> 1]);
|
|
58
|
+
proto[camel(k)] = () => ({
|
|
59
|
+
getArgb: (s) => proto[i & 1 ? "onError" : "error"]().getArgb({
|
|
60
|
+
__proto__: s,
|
|
61
|
+
errorPalette: TonalPalette.fromInt(Hct.from(f.hue + Math.max(-15, Math.min(15, (((s.variant && Hct.fromInt(s.primaryPalette.tone(40)).hue) - f.hue + 540) % 360 - 180) * 0.5)), f.chroma, f.tone).toInt()),
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
export function statusRolesArgb(scheme, primaryArgb) {
|
|
66
|
+
const s = primaryArgb !== undefined ? { __proto__: scheme, primaryPalette: { tone: () => primaryArgb } } : scheme;
|
|
67
|
+
return Object.fromEntries(STATUS_ROLES.map((r) => [r, proto[camel(r)]().getArgb(s)]));
|
|
68
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Hct } from "./vendor/hct/hct.js";
|
|
2
|
+
import { type DynamicScheme, type SchemeMode } from "./index.js";
|
|
3
|
+
export type ThemeVariant = "tonal-spot" | "vibrant" | "expressive" | "fidelity" | "content" | "neutral" | "monochrome";
|
|
4
|
+
export interface NamedSchemeOptions {
|
|
5
|
+
variant?: ThemeVariant;
|
|
6
|
+
mode?: SchemeMode;
|
|
7
|
+
contrast?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function createSchemeByName(seed: string | number | Hct, options?: NamedSchemeOptions): DynamicScheme;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { content, createScheme, expressive, fidelity, monochrome, neutral, tonalSpot, vibrant, } from "./index.js";
|
|
2
|
+
const VARIANTS = {
|
|
3
|
+
"tonal-spot": tonalSpot,
|
|
4
|
+
vibrant,
|
|
5
|
+
expressive,
|
|
6
|
+
fidelity,
|
|
7
|
+
content,
|
|
8
|
+
neutral,
|
|
9
|
+
monochrome,
|
|
10
|
+
};
|
|
11
|
+
export function createSchemeByName(seed, options = {}) {
|
|
12
|
+
return createScheme(seed, {
|
|
13
|
+
variant: VARIANTS[options.variant ?? "tonal-spot"],
|
|
14
|
+
mode: options.mode,
|
|
15
|
+
contrast: options.contrast,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
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 * as utils from "../utils/color_utils.js";
|
|
18
|
+
import * as math from "../utils/math_utils.js";
|
|
19
|
+
export class Contrast {
|
|
20
|
+
static ratioOfTones(toneA, toneB) {
|
|
21
|
+
toneA = math.clampDouble(0.0, 100.0, toneA);
|
|
22
|
+
toneB = math.clampDouble(0.0, 100.0, toneB);
|
|
23
|
+
return Contrast.ratioOfYs(utils.yFromLstar(toneA), utils.yFromLstar(toneB));
|
|
24
|
+
}
|
|
25
|
+
static ratioOfYs(y1, y2) {
|
|
26
|
+
const lighter = y1 > y2 ? y1 : y2;
|
|
27
|
+
const darker = (lighter === y2) ? y1 : y2;
|
|
28
|
+
return (lighter + 5.0) / (darker + 5.0);
|
|
29
|
+
}
|
|
30
|
+
static lighter(tone, ratio) {
|
|
31
|
+
if (tone < 0.0 || tone > 100.0) {
|
|
32
|
+
return -1.0;
|
|
33
|
+
}
|
|
34
|
+
const darkY = utils.yFromLstar(tone);
|
|
35
|
+
const lightY = ratio * (darkY + 5.0) - 5.0;
|
|
36
|
+
const realContrast = Contrast.ratioOfYs(lightY, darkY);
|
|
37
|
+
const delta = Math.abs(realContrast - ratio);
|
|
38
|
+
if (realContrast < ratio && delta > 0.04) {
|
|
39
|
+
return -1;
|
|
40
|
+
}
|
|
41
|
+
const returnValue = utils.lstarFromY(lightY) + 0.4;
|
|
42
|
+
if (returnValue < 0 || returnValue > 100) {
|
|
43
|
+
return -1;
|
|
44
|
+
}
|
|
45
|
+
return returnValue;
|
|
46
|
+
}
|
|
47
|
+
static darker(tone, ratio) {
|
|
48
|
+
if (tone < 0.0 || tone > 100.0) {
|
|
49
|
+
return -1.0;
|
|
50
|
+
}
|
|
51
|
+
const lightY = utils.yFromLstar(tone);
|
|
52
|
+
const darkY = ((lightY + 5.0) / ratio) - 5.0;
|
|
53
|
+
const realContrast = Contrast.ratioOfYs(lightY, darkY);
|
|
54
|
+
const delta = Math.abs(realContrast - ratio);
|
|
55
|
+
if (realContrast < ratio && delta > 0.04) {
|
|
56
|
+
return -1;
|
|
57
|
+
}
|
|
58
|
+
const returnValue = utils.lstarFromY(darkY) - 0.4;
|
|
59
|
+
if (returnValue < 0 || returnValue > 100) {
|
|
60
|
+
return -1;
|
|
61
|
+
}
|
|
62
|
+
return returnValue;
|
|
63
|
+
}
|
|
64
|
+
static lighterUnsafe(tone, ratio) {
|
|
65
|
+
const lighterSafe = Contrast.lighter(tone, ratio);
|
|
66
|
+
return (lighterSafe < 0.0) ? 100.0 : lighterSafe;
|
|
67
|
+
}
|
|
68
|
+
static darkerUnsafe(tone, ratio) {
|
|
69
|
+
const darkerSafe = Contrast.darker(tone, ratio);
|
|
70
|
+
return (darkerSafe < 0.0) ? 0.0 : darkerSafe;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { Hct } from "../hct/hct.js";
|
|
18
|
+
export class DislikeAnalyzer {
|
|
19
|
+
static isDisliked(hct) {
|
|
20
|
+
const huePasses = Math.round(hct.hue) >= 90.0 && Math.round(hct.hue) <= 111.0;
|
|
21
|
+
const chromaPasses = Math.round(hct.chroma) > 16.0;
|
|
22
|
+
const tonePasses = Math.round(hct.tone) < 65.0;
|
|
23
|
+
return huePasses && chromaPasses && tonePasses;
|
|
24
|
+
}
|
|
25
|
+
static fixIfDisliked(hct) {
|
|
26
|
+
if (DislikeAnalyzer.isDisliked(hct)) {
|
|
27
|
+
return Hct.from(hct.hue, hct.chroma, 70.0);
|
|
28
|
+
}
|
|
29
|
+
return hct;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export class ColorSpecDelegateImpl2021 {
|
|
2
|
+
primaryPaletteKeyColor(): DynamicColor;
|
|
3
|
+
secondaryPaletteKeyColor(): DynamicColor;
|
|
4
|
+
tertiaryPaletteKeyColor(): DynamicColor;
|
|
5
|
+
neutralPaletteKeyColor(): DynamicColor;
|
|
6
|
+
neutralVariantPaletteKeyColor(): DynamicColor;
|
|
7
|
+
errorPaletteKeyColor(): DynamicColor;
|
|
8
|
+
background(): DynamicColor;
|
|
9
|
+
onBackground(): DynamicColor;
|
|
10
|
+
surface(): DynamicColor;
|
|
11
|
+
surfaceDim(): DynamicColor;
|
|
12
|
+
surfaceBright(): DynamicColor;
|
|
13
|
+
surfaceContainerLowest(): DynamicColor;
|
|
14
|
+
surfaceContainerLow(): DynamicColor;
|
|
15
|
+
surfaceContainer(): DynamicColor;
|
|
16
|
+
surfaceContainerHigh(): DynamicColor;
|
|
17
|
+
surfaceContainerHighest(): DynamicColor;
|
|
18
|
+
onSurface(): DynamicColor;
|
|
19
|
+
surfaceVariant(): DynamicColor;
|
|
20
|
+
onSurfaceVariant(): DynamicColor;
|
|
21
|
+
inverseSurface(): DynamicColor;
|
|
22
|
+
inverseOnSurface(): DynamicColor;
|
|
23
|
+
outline(): DynamicColor;
|
|
24
|
+
outlineVariant(): DynamicColor;
|
|
25
|
+
shadow(): DynamicColor;
|
|
26
|
+
scrim(): DynamicColor;
|
|
27
|
+
surfaceTint(): DynamicColor;
|
|
28
|
+
primary(): DynamicColor;
|
|
29
|
+
primaryDim(): undefined;
|
|
30
|
+
onPrimary(): DynamicColor;
|
|
31
|
+
primaryContainer(): DynamicColor;
|
|
32
|
+
onPrimaryContainer(): DynamicColor;
|
|
33
|
+
inversePrimary(): DynamicColor;
|
|
34
|
+
secondary(): DynamicColor;
|
|
35
|
+
secondaryDim(): undefined;
|
|
36
|
+
onSecondary(): DynamicColor;
|
|
37
|
+
secondaryContainer(): DynamicColor;
|
|
38
|
+
onSecondaryContainer(): DynamicColor;
|
|
39
|
+
tertiary(): DynamicColor;
|
|
40
|
+
tertiaryDim(): undefined;
|
|
41
|
+
onTertiary(): DynamicColor;
|
|
42
|
+
tertiaryContainer(): DynamicColor;
|
|
43
|
+
onTertiaryContainer(): DynamicColor;
|
|
44
|
+
error(): DynamicColor;
|
|
45
|
+
errorDim(): undefined;
|
|
46
|
+
onError(): DynamicColor;
|
|
47
|
+
errorContainer(): DynamicColor;
|
|
48
|
+
onErrorContainer(): DynamicColor;
|
|
49
|
+
primaryFixed(): DynamicColor;
|
|
50
|
+
primaryFixedDim(): DynamicColor;
|
|
51
|
+
onPrimaryFixed(): DynamicColor;
|
|
52
|
+
onPrimaryFixedVariant(): DynamicColor;
|
|
53
|
+
secondaryFixed(): DynamicColor;
|
|
54
|
+
secondaryFixedDim(): DynamicColor;
|
|
55
|
+
onSecondaryFixed(): DynamicColor;
|
|
56
|
+
onSecondaryFixedVariant(): DynamicColor;
|
|
57
|
+
tertiaryFixed(): DynamicColor;
|
|
58
|
+
tertiaryFixedDim(): DynamicColor;
|
|
59
|
+
onTertiaryFixed(): DynamicColor;
|
|
60
|
+
onTertiaryFixedVariant(): DynamicColor;
|
|
61
|
+
highestSurface(s: any): DynamicColor;
|
|
62
|
+
}
|
|
63
|
+
import { DynamicColor } from "./dynamic_color.js";
|